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

List:       kde-commits
Subject:    KDE/kdelibs
From:       Maks Orlovich <maksim () kde ! org>
Date:       2010-11-12 3:19:24
Message-ID: 20101112031924.43DC6AC89E () svn ! kde ! org
[Download RAW message or body]

SVN commit 1195834 by orlovich:

Add ability to use custom method names in kio_http (+ add a missing case in davCustom \
method handling). Needef or XMLHttpRequest.

@adawit: I think this may be of use to you as well?

CCMAIL: adawit@kde.org


 M  +3 -0      kio/DESIGN.metadata  
 M  +13 -6     kioslave/http/http.cpp  
 M  +3 -0      kioslave/http/http.h  


--- trunk/KDE/kdelibs/kio/DESIGN.metadata #1195833:1195834
@@ -138,6 +138,9 @@
 
 CustomHTTPHeader	string	Custom HTTP headers to add to the request (read by http)
 
+CustomHTTPMethod        string  Overrides the method string sent by kio_http 
+                                without changing the behavior (read by http)
+
 UseProxy		string	URL representing the proxy settings (read by http)
 
 PrivacyPolicy		stringlist  \n delimited URIs referring to P3P privacy
--- trunk/KDE/kdelibs/kioslave/http/http.cpp #1195833:1195834
@@ -242,9 +242,12 @@
     return isValidProxy(u) && u.protocol() == QLatin1String("http");
 }
 
-static QByteArray methodString(HTTP_METHOD m)
+QByteArray HTTPProtocol::HTTPRequest::methodString() const
 {
-    switch(m) {
+    if (!methodStringOverride.isEmpty())
+	return (methodStringOverride + QLatin1Char(' ')).toLatin1();
+
+    switch(method) {
     case HTTP_GET:
         return "GET ";
     case HTTP_PUT:
@@ -279,6 +282,8 @@
         return "UNSUBSCRIBE ";
     case DAV_POLL:
         return "POLL ";
+    case DAV_NOTIFY:
+        return "NOTIFY ";
     case DAV_REPORT:
         return "REPORT ";
     default:
@@ -441,6 +446,8 @@
   m_maxCacheAge = config()->readEntry("MaxCacheAge", DEFAULT_MAX_CACHE_AGE);
   m_request.windowId = config()->readEntry("window-id");
 
+  m_request.methodStringOverride = metaData(QLatin1String("CustomHTTPMethod"));
+
   kDebug(7113) << "Window Id =" << m_request.windowId;
   kDebug(7113) << "ssl_was_in_use =" << metaData(QLatin1String("ssl_was_in_use"));
 
@@ -2219,7 +2226,7 @@
   bool hasDavData = false;
 
   {
-    header = QString::fromLatin1(methodString(m_request.method));
+    header = QString::fromLatin1(m_request.methodString());
     QString davHeader;
 
     // Fill in some values depending on the HTTP method to guide further processing
@@ -3273,7 +3280,7 @@
                     kDebug(7113) << "Trying authentication scheme:" << \
(*auth)->scheme();  
                     // remove trailing space from the method string, or digest auth \
                will fail
-                    (*auth)->setChallenge(bestOffer, authinfo.url, \
methodString(m_request.method)); +                    \
(*auth)->setChallenge(bestOffer, authinfo.url, m_request.methodString());  
                     QString username;
                     QString password;
@@ -4928,7 +4935,7 @@
                 m_wwwAuth = KAbstractHttpAuthentication::newAuth(cachedChallenge, \
config());  if (m_wwwAuth) {
                     kDebug(7113) << "Creating WWW authentcation object from cached \
                info";
-                    m_wwwAuth->setChallenge(cachedChallenge, m_request.url, \
methodString(m_request.method)); +                    \
                m_wwwAuth->setChallenge(cachedChallenge, m_request.url, \
                m_request.methodString());
                     m_wwwAuth->generateResponse(authinfo.username, \
authinfo.password);  }
             }
@@ -4951,7 +4958,7 @@
                 m_proxyAuth = KAbstractHttpAuthentication::newAuth(cachedChallenge, \
config());  if (m_proxyAuth) {
                     kDebug(7113) << "Creating Proxy authentcation object from cached \
                info";
-                    m_proxyAuth->setChallenge(cachedChallenge, m_request.proxyUrl, \
methodString(m_request.method)); +                    \
m_proxyAuth->setChallenge(cachedChallenge, m_request.proxyUrl, \
                m_request.methodString());
                     m_proxyAuth->generateResponse(authinfo.username, \
authinfo.password);  }
             }
--- trunk/KDE/kdelibs/kioslave/http/http.h #1195833:1195834
@@ -137,6 +137,8 @@
       useCookieJar = false;
     }
 
+    QByteArray methodString() const;
+
     KUrl url;
     QString encoded_hostname; //### can be calculated on-the-fly
     // Persistent connections
@@ -144,6 +146,7 @@
     int keepAliveTimeout;   // Timeout in seconds.
 
     KIO::HTTP_METHOD method;
+    QString methodStringOverride;     // Overrides method if non-empty.
     KIO::filesize_t offset;
     KIO::filesize_t endoffset;
     QString windowId;                 // Window Id this request is related to.


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

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