Added a QWebPage::open overload to allow specifying the http header and post data.
authorhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jun 2007 13:49:56 +0000 (13:49 +0000)
committerhausmann <hausmann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jun 2007 13:49:56 +0000 (13:49 +0000)
(it's an overload instead of a merged openUrl to avoid including qhttp.h in qwebpage.h,
which would imply that one has to have QT += network in the .pro file for using WebKitQt)

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@22096 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKitQt/Api/qwebpage.cpp
WebKitQt/Api/qwebpage.h
WebKitQt/ChangeLog

index 41832d6bb5c28a6c50a6c852ec62f8e43bdec3e1..0d5caabe4e4113132bd84c7434f592519945b71b 100644 (file)
@@ -50,6 +50,7 @@
 #include <QUndoStack>
 #include <QUrl>
 #include <QVBoxLayout>
+#include <QHttpRequestHeader>
 
 using namespace WebCore;
 
@@ -128,9 +129,28 @@ QWebFrame *QWebPage::createFrame(QWebFrame *parentFrame, QWebFrameData *frameDat
 }
 
 void QWebPage::open(const QUrl &url)
+{
+    open(url, QHttpRequestHeader(), QByteArray());
+}
+
+void QWebPage::open(const QUrl &url, const QHttpRequestHeader &httpHeader, const QByteArray &postData)
 {
     d->insideOpenCall = true;
-    mainFrame()->d->frame->loader()->load(KURL(url.toString()));
+    WebCore::ResourceRequest request(KURL(url.toString()));
+
+    if (httpHeader.isValid()) {
+        request.setHTTPMethod(httpHeader.method());
+        foreach (QString key, httpHeader.keys()) {
+            request.addHTTPHeaderField(key, httpHeader.value(key));
+        }
+
+        if (!postData.isEmpty()) {
+            WTF::RefPtr<WebCore::FormData> formData = new WebCore::FormData(postData.constData(), postData.size());
+            request.setHTTPBody(formData);
+        }
+    }
+
+    mainFrame()->d->frame->loader()->load(request);
     d->insideOpenCall = false;
 }
 
index 058ad3782c342eaa82b6f058a17a6dc1d604fabb..2bd6f33d0a4bee284ca3377b7ac5e6cde920a191 100644 (file)
 class QWebFrame;
 class QUndoStack;
 class QUrl;
+class QHttpRequestHeader;
 
 class QWebPagePrivate;
 class QWebFrameData;
 class QWebNetworkInterface;
 
-class QHttpRequestHeader;
-
 namespace WebCore {
     class ChromeClientQt;
     class FrameLoaderClientQt;
@@ -63,6 +62,7 @@ public:
 
 
     void open(const QUrl &url);
+    void open(const QUrl &url, const QHttpRequestHeader &httpHeader, const QByteArray &postData);
 
     QWebFrame *mainFrame() const;
 
index 6ac464b5f5232b3e75a7b5700919dc6a484cab2f..c4a51050c494435bf889bc1397f2ce937b44311d 100644 (file)
@@ -1,3 +1,14 @@
+2007-06-11  Simon Hausmann  <hausmann@kde.org>
+
+        Reviewed by Lars.
+
+        Added a QWebPage::open overload to allow specifying the http header and post data.
+        (it's an overload instead of a merged openUrl to avoid including qhttp.h in qwebpage.h,
+        which would imply that one has to have QT += network in the .pro file for using WebKitQt)
+
+        * Api/qwebpage.cpp:
+        * Api/qwebpage.h:
+
 2007-06-11  Simon Hausmann  <hausmann@kde.org>
 
         Reviewed by Lars.