[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kio/kio
From:       Dawit Alemayehu <adawit () kde ! org>
Date:       2010-12-01 0:10:35
Message-ID: 20101201001035.1A986AC8A3 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1202463 by adawit:

Reduced if statement nesting where possible

 M  +17 -12    accessmanagerreply_p.cpp  


--- trunk/KDE/kdelibs/kio/kio/accessmanagerreply_p.cpp #1202462:1202463
@@ -120,29 +120,34 @@
             setSslConfiguration(sslConfig);
 
         // Set the raw header information...
-        const QString headers = job->queryMetaData(QL1S("HTTP-Headers"));
-        if (!headers.isEmpty()) {
-            const QStringList httpHeaders (headers.split(QL1C('\n')));
+        const QStringList httpHeaders \
(job->queryMetaData(QL1S("HTTP-Headers")).split(QL1C('\n')));  Q_FOREACH(const \
QString& httpHeader, httpHeaders) {  int index = httpHeader.indexOf(QL1C(':'));
                  // Ignore the HTTP status line...
-                if (index == -1 && httpHeader.startsWith(QL1S("HTTP/"), \
Qt::CaseInsensitive)) { +            if (index == -1) {
+                // Except for the status line, all HTTP headers must be a name/value \
pair,i.e "<name>:<value>" +                if (!httpHeader.startsWith(QL1S("HTTP/"), \
Qt::CaseInsensitive)) +                  continue;
+
+                // Further validate the status line to make sure it contains the \
response code...  index = httpHeader.indexOf(responseCode);
-                    if (index > -1) {
+                if (index == -1)
+                   continue;                
+
+                // Assign the status/reason pharse...
                         index += responseCode.length();
-                        if (index < httpHeader.length()) {
-                            const QString& reasonPhrase = \
                httpHeader.mid(index).trimmed();
-                            setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, \
                reasonPhrase);
-                            //kDebug(7044) << "Set reason phrase to" << \
                reasonPhrase;
-                        }
-                    }
+                if (index < httpHeader.length())
+                    setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, \
httpHeader.mid(index).trimmed());  continue;
                 }
+
                 const QString headerName = httpHeader.left(index);
                 QString headerValue = httpHeader.mid(index+1);
+
                 // Skip setting cookies since they are automatically handled by \
                kio_http...
                 if (headerName.startsWith(QL1S("set-cookie"), Qt::CaseInsensitive))
                     continue;
+            
                 // Without overridding the corrected mime-type sent by kio_http, add
                 // back the "charset=" portion of the content-type header if \
                present.
                 if (headerName.startsWith(QL1S("content-type"), \
Qt::CaseInsensitive)) { @@ -156,10 +161,10 @@
                         //kDebug(7044) << "Changed mime-type from" << mimeType << \
"to" << headerValue;  }
                 }
+            
                 // kDebug(7044) << "Adding header:" << headerName << ":" << \
                headerValue;
                 setRawHeader(headerName.trimmed().toUtf8(), \
headerValue.trimmed().toUtf8());  }
-        }
 
         // Set the returned meta data as attribute...
         setAttribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData),



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic