[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-11-30 19:36:22
Message-ID: 20101130193622.07D4DAC8A3 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1202412 by adawit:

- Make sure all literal string is enclosed with QLatin1String.
- Set the attribute HttpReasonPhraseAttribute.


 M  +24 -10    accessmanagerreply_p.cpp  


--- trunk/KDE/kdelibs/kio/kio/accessmanagerreply_p.cpp #1202411:1202412
@@ -30,7 +30,10 @@
 
 #include <QtNetwork/QSslConfiguration>
 
+#define QL1S(x)  QLatin1String(x)
+#define QL1C(x)  QLatin1Char(x)
 
+
 namespace KDEPrivate {
 
 AccessManagerReply::AccessManagerReply(const QNetworkAccessManager::Operation &op,
@@ -105,7 +108,7 @@
 {
     if (!m_metaDataRead) {
         // Set the HTTP status code...
-        const QString responseCode = job->queryMetaData("responsecode");
+        const QString responseCode = job->queryMetaData(QL1S("responsecode"));
         if (!responseCode.isEmpty())
             setAttribute(QNetworkRequest::HttpStatusCodeAttribute, responseCode.toInt());
 
@@ -117,29 +120,40 @@
             setSslConfiguration(sslConfig);
 
         // Set the raw header information...
-        const QString headers = job->queryMetaData("HTTP-Headers");
+        const QString headers = job->queryMetaData(QL1S("HTTP-Headers"));
         if (!headers.isEmpty()) {
-            const QStringList httpHeaders (headers.split(QLatin1Char('\n')));
+            const QStringList httpHeaders (headers.split(QL1C('\n')));
             Q_FOREACH(const QString& httpHeader, httpHeaders) {
-                int index = httpHeader.indexOf(QLatin1Char(':'));
-                if (index == -1)
-                   continue; // Ignore the HTTP status line...
+                int index = httpHeader.indexOf(QL1C(':'));
+                 // Ignore the HTTP status line...
+                if (index == -1 && httpHeader.startsWith(QL1S("HTTP/"), Qt::CaseInsensitive)) {
+                    index = httpHeader.indexOf(responseCode);
+                    if (index > -1) {
+                        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;
+                        }
+                    }
+                    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("set-cookie", Qt::CaseInsensitive))
+                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("content-type", Qt::CaseInsensitive)) {
+                if (headerName.startsWith(QL1S("content-type"), Qt::CaseInsensitive)) {
                     const QString mimeType = header(QNetworkRequest::ContentTypeHeader).toString();
                     if (!headerValue.contains(mimeType, Qt::CaseInsensitive)) {
-                        index = headerValue.indexOf(QLatin1Char(';'));
+                        index = headerValue.indexOf(QL1C(';'));
                         if (index == -1)
                             headerValue = mimeType;
                         else
                             headerValue.replace(0, index, mimeType);
-                        kDebug(7044) << "Changed mime-type from" << mimeType << "to" << headerValue;
+                        //kDebug(7044) << "Changed mime-type from" << mimeType << "to" << headerValue;
                     }
                 }
                 // kDebug(7044) << "Adding header:" << headerName << ":" << headerValue;
[prev in list] [next in list] [prev in thread] [next in thread] 

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