Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Response headers supported.

  • Loading branch information...
commit 7b3d142729d4b0dd412944f40885cb7cce2715c3 1 parent 62b0d85
@halogenandtoast halogenandtoast authored
View
2  lib/capybara/driver/webkit.rb
@@ -54,7 +54,7 @@ def evaluate_script(script)
end
def response_headers
- raise Capybara::NotSupportedByDriverError
+ browser.response_headers
end
def status_code
View
4 lib/capybara/driver/webkit/browser.rb
@@ -44,6 +44,10 @@ def status_code
command("Status").to_i
end
+ def response_headers
+ Hash[command("Headers").split("\n").map { |header| header.split(": ") }]
+ end
+
def url
command("Url")
end
View
2  spec/integration/driver_spec.rb
@@ -14,7 +14,7 @@
@driver.server_port.should eq(@driver.instance_variable_get(:@rack_server).port)
end
- # it_should_behave_like "driver with header support"
+ it_should_behave_like "driver with header support"
it_should_behave_like "driver with status code support"
# it_should_behave_like "driver with frame support"
end
View
1  src/Connection.cpp
@@ -14,6 +14,7 @@
#include "Render.h"
#include "Body.h"
#include "Status.h"
+#include "Headers.h"
#include <QTcpSocket>
#include <iostream>
View
11 src/Headers.cpp
@@ -0,0 +1,11 @@
+#include "Headers.h"
+#include "WebPage.h"
+
+Headers::Headers(WebPage *page, QObject *parent) : Command(page, parent) {
+}
+
+void Headers::start(QStringList &arguments) {
+ Q_UNUSED(arguments);
+ emit finished(new Response(true, page()->pageHeaders()));
+}
+
View
12 src/Headers.h
@@ -0,0 +1,12 @@
+#include "Command.h"
+
+class WebPage;
+
+class Headers : public Command {
+ Q_OBJECT
+
+ public:
+ Headers(WebPage *page, QObject *parent = 0);
+ virtual void start(QStringList &arguments);
+};
+
View
13 src/WebPage.cpp
@@ -168,9 +168,22 @@ QString WebPage::getLastAttachedFileName() {
}
void WebPage::replyFinished(QNetworkReply *reply) {
+ QStringList headers;
lastStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ QList<QByteArray> list = reply->rawHeaderList();
+
+ int length = list.size();
+ for(int i = 0; i < length; i++) {
+ headers << list.at(i)+": "+reply->rawHeader(list.at(i));
+ }
+
+ m_pageHeaders = headers.join("\n");
}
int WebPage::getLastStatus() {
return lastStatus;
}
+
+QString WebPage::pageHeaders() {
+ return m_pageHeaders;
+}
View
2  src/WebPage.h
@@ -20,6 +20,7 @@ class WebPage : public QWebPage {
void loadStarted();
void loadFinished(bool);
bool isLoading() const;
+ QString pageHeaders();
void frameCreated(QWebFrame *);
void replyFinished(QNetworkReply *reply);
@@ -38,5 +39,6 @@ class WebPage : public QWebPage {
void loadJavascript();
void setUserStylesheet();
int lastStatus;
+ QString m_pageHeaders;
};
View
1  src/find_command.h
@@ -16,3 +16,4 @@ CHECK_COMMAND(Header)
CHECK_COMMAND(Render)
CHECK_COMMAND(Body)
CHECK_COMMAND(Status)
+CHECK_COMMAND(Headers)
View
4 src/webkit_server.pro
@@ -1,8 +1,8 @@
TEMPLATE = app
TARGET = webkit_server
DESTDIR = .
-HEADERS = WebPage.h Server.h Connection.h Command.h Visit.h Find.h Reset.h Node.h JavascriptInvocation.h Url.h Source.h Evaluate.h Execute.h FrameFocus.h Response.h NetworkAccessManager.h Header.h Render.h body.h Status.h
-SOURCES = main.cpp WebPage.cpp Server.cpp Connection.cpp Command.cpp Visit.cpp Find.cpp Reset.cpp Node.cpp JavascriptInvocation.cpp Url.cpp Source.cpp Evaluate.cpp Execute.cpp FrameFocus.cpp Response.cpp NetworkAccessManager.cpp Header.cpp Render.cpp body.cpp Status.cpp
+HEADERS = WebPage.h Server.h Connection.h Command.h Visit.h Find.h Reset.h Node.h JavascriptInvocation.h Url.h Source.h Evaluate.h Execute.h FrameFocus.h Response.h NetworkAccessManager.h Header.h Render.h body.h Status.h Headers.h
+SOURCES = main.cpp WebPage.cpp Server.cpp Connection.cpp Command.cpp Visit.cpp Find.cpp Reset.cpp Node.cpp JavascriptInvocation.cpp Url.cpp Source.cpp Evaluate.cpp Execute.cpp FrameFocus.cpp Response.cpp NetworkAccessManager.cpp Header.cpp Render.cpp body.cpp Status.cpp Headers.cpp
RESOURCES = webkit_server.qrc
QT += network webkit
CONFIG += console
Please sign in to comment.
Something went wrong with that request. Please try again.