Added the missing parameters to make it possible to do POST operations from the publi...
authorhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jan 2008 11:38:00 +0000 (11:38 +0000)
committerhausmann@webkit.org <hausmann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jan 2008 11:38:00 +0000 (11:38 +0000)
This is ugly though as it also requires including qnetworkaccessmanager.h. It would be nicer if the
two extra arguments were in QNetworkRequest :-/

Signed-off-by: Lars
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29225 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/Api/qwebframe.cpp
WebKit/qt/Api/qwebframe.h
WebKit/qt/Api/qwebview.cpp
WebKit/qt/Api/qwebview.h
WebKit/qt/ChangeLog

index 68d06dbe6826426cc3d5704f47f66a7f883d1cc9..afb3112883586aac3a9a81eef55a0af6757a2e62 100644 (file)
@@ -270,17 +270,34 @@ void QWebFrame::load(const QWebNetworkRequest &req)
 
 #else
 
 
 #else
 
-void QWebFrame::load(const QNetworkRequest &req)
+void QWebFrame::load(const QNetworkRequest &req,
+                     QNetworkAccessManager::Operation operation,
+                     const QByteArray &body)
 {
     if (d->parentFrame())
         d->page->d->insideOpenCall = true;
 
     QUrl url = req.url();
 {
     if (d->parentFrame())
         d->page->d->insideOpenCall = true;
 
     QUrl url = req.url();
-    QByteArray postData; // ### FIXME = req.postData();
 
     WebCore::ResourceRequest request(KURL(url.toString()));
 
 
     WebCore::ResourceRequest request(KURL(url.toString()));
 
-    // ### FIXME httpHeader.method();
+    switch (operation) {
+        case QNetworkAccessManager::HeadOperation:
+            request.setHTTPMethod("HEAD");
+            break;
+        case QNetworkAccessManager::GetOperation:
+            request.setHTTPMethod("GET");
+            break;
+        case QNetworkAccessManager::PutOperation:
+            request.setHTTPMethod("PUT");
+            break;
+        case QNetworkAccessManager::PostOperation:
+            request.setHTTPMethod("POST");
+            break;
+        case QNetworkAccessManager::UnknownOperation:
+            // eh?
+            break;
+    }
 
     QList<QByteArray> httpHeaders = req.rawHeaderList();
     for (int i = 0; i < httpHeaders.size(); ++i) {
 
     QList<QByteArray> httpHeaders = req.rawHeaderList();
     for (int i = 0; i < httpHeaders.size(); ++i) {
@@ -288,8 +305,8 @@ void QWebFrame::load(const QNetworkRequest &req)
         request.addHTTPHeaderField(QString::fromLatin1(headerName), QString::fromLatin1(req.rawHeader(headerName)));
     }
 
         request.addHTTPHeaderField(QString::fromLatin1(headerName), QString::fromLatin1(req.rawHeader(headerName)));
     }
 
-    if (!postData.isEmpty()) {
-        WTF::RefPtr<WebCore::FormData> formData = new WebCore::FormData(postData.constData(), postData.size());
+    if (!body.isEmpty()) {
+        WTF::RefPtr<WebCore::FormData> formData = new WebCore::FormData(body.constData(), body.size());
         request.setHTTPBody(formData);
     }
 
         request.setHTTPBody(formData);
     }
 
index 48205334fb2d7cfafee9266377661d520b55bd8f..ccf757c688f45664b840441b593b0d56aeccb551 100644 (file)
@@ -26,6 +26,9 @@
 
 #include <QtCore/qobject.h>
 #include <QtCore/qurl.h>
 
 #include <QtCore/qobject.h>
 #include <QtCore/qurl.h>
+#if QT_VERSION >= 0x040400
+#include <QtNetwork/qnetworkaccessmanager.h>
+#endif
 #include "qwebkitglobal.h"
 
 class QRect;
 #include "qwebkitglobal.h"
 
 class QRect;
@@ -62,7 +65,9 @@ public:
 #if QT_VERSION < 0x040400
     void load(const QWebNetworkRequest &request);
 #else
 #if QT_VERSION < 0x040400
     void load(const QWebNetworkRequest &request);
 #else
-    void load(const QNetworkRequest &request);
+    void load(const QNetworkRequest &request,
+              QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
+              const QByteArray &body = QByteArray());
 #endif
     void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
     void setHtml(const QByteArray &html, const QUrl &baseUrl = QUrl());
 #endif
     void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
     void setHtml(const QByteArray &html, const QUrl &baseUrl = QUrl());
index 4896900a3a61cad1bc09ee657f3ac09c40f4462c..945841cea3062d2d942b7d929061acd8ed46f974 100644 (file)
@@ -135,10 +135,16 @@ void QWebView::load(const QUrl &url)
 #if QT_VERSION < 0x040400
 void QWebView::load(const QWebNetworkRequest &request)
 #else
 #if QT_VERSION < 0x040400
 void QWebView::load(const QWebNetworkRequest &request)
 #else
-void QWebView::load(const QNetworkRequest &request)
+void QWebView::load(const QNetworkRequest &request,
+                    QNetworkAccessManager::Operation operation,
+                    const QByteArray &body)
 #endif
 {
 #endif
 {
-    page()->mainFrame()->load(request);
+    page()->mainFrame()->load(request
+#if QT_VERSION >= 0x040400
+                              , operation, body
+#endif
+                             );
 }
 
 /*!
 }
 
 /*!
index 2bb04db0109614be9b9289e70bc32265e858392c..d0cf35e314ed5fdb3f27a55152e1a9d692f6120f 100644 (file)
@@ -23,6 +23,9 @@
 #include "qwebkitglobal.h"
 #include "qwebpage.h"
 #include <QtGui/qwidget.h>
 #include "qwebkitglobal.h"
 #include "qwebpage.h"
 #include <QtGui/qwidget.h>
+#if QT_VERSION >= 0x040400
+#include <QtNetwork/qnetworkaccessmanager.h>
+#endif
 
 class QWebPage;
 class QWebViewPrivate;
 
 class QWebPage;
 class QWebViewPrivate;
@@ -49,7 +52,9 @@ public:
 #if QT_VERSION < 0x040400
     void load(const QWebNetworkRequest &request);
 #else
 #if QT_VERSION < 0x040400
     void load(const QWebNetworkRequest &request);
 #else
-    void load(const QNetworkRequest &request);
+    void load(const QNetworkRequest &request,
+              QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
+              const QByteArray &body = QByteArray());
 #endif
     void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
     void setHtml(const QByteArray &html, const QUrl &baseUrl = QUrl());
 #endif
     void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
     void setHtml(const QByteArray &html, const QUrl &baseUrl = QUrl());
index 88cb4c5ad03d2e420c3ae95e03d8e50f0ffbe8ec..e6061f015c7ccd5a814baf5e796f8df7f5774df9 100644 (file)
@@ -1,3 +1,20 @@
+2008-01-07  Simon Hausmann  <hausmann@webkit.org>
+
+        Reviewed by Lars.
+
+        Added the missing parameters to make it possible to do POST operations from the public API.
+        
+        This is ugly though as it also requires including qnetworkaccessmanager.h. It would be nicer if the
+        two extra arguments were in QNetworkRequest :-/
+        
+
+        * Api/qwebframe.cpp:
+        (QWebFrame::load):
+        * Api/qwebframe.h:
+        * Api/qwebview.cpp:
+        (QWebView::load):
+        * Api/qwebview.h:
+
 2008-01-07  Simon Hausmann  <hausmann@webkit.org>
 
         Reviewed by Lars.
 2008-01-07  Simon Hausmann  <hausmann@webkit.org>
 
         Reviewed by Lars.