Response headers supported.
This commit is contained in:
parent
62b0d854df
commit
7b3d142729
|
@ -54,7 +54,7 @@ class Capybara::Driver::Webkit
|
|||
end
|
||||
|
||||
def response_headers
|
||||
raise Capybara::NotSupportedByDriverError
|
||||
browser.response_headers
|
||||
end
|
||||
|
||||
def status_code
|
||||
|
|
|
@ -44,6 +44,10 @@ class Capybara::Driver::Webkit
|
|||
command("Status").to_i
|
||||
end
|
||||
|
||||
def response_headers
|
||||
Hash[command("Headers").split("\n").map { |header| header.split(": ") }]
|
||||
end
|
||||
|
||||
def url
|
||||
command("Url")
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ describe Capybara::Driver::Webkit do
|
|||
@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
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "Render.h"
|
||||
#include "Body.h"
|
||||
#include "Status.h"
|
||||
#include "Headers.h"
|
||||
|
||||
#include <QTcpSocket>
|
||||
#include <iostream>
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,3 +16,4 @@ CHECK_COMMAND(Header)
|
|||
CHECK_COMMAND(Render)
|
||||
CHECK_COMMAND(Body)
|
||||
CHECK_COMMAND(Status)
|
||||
CHECK_COMMAND(Headers)
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue