mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
82d0d6fcc9
NetworkAccessManager was getting pretty complex, and adding something that modifies or intercepts requests is becoming a common change. This change introduces a chain of handlers which can modify a request or return a response of their own. To start with, this extracts the concerns of fixing missing content types, setting custom headers, and intercepting blacklisted requests.
18 lines
484 B
C++
18 lines
484 B
C++
#include "Header.h"
|
|
#include "WebPage.h"
|
|
#include "WebPageManager.h"
|
|
#include "NetworkAccessManager.h"
|
|
|
|
Header::Header(WebPageManager *manager, QStringList &arguments, QObject *parent) : SocketCommand(manager, arguments, parent) {
|
|
}
|
|
|
|
void Header::start() {
|
|
QString key = arguments()[0];
|
|
QString value = arguments()[1];
|
|
if (key.toLower().replace("-", "_") == "user_agent") {
|
|
page()->setUserAgent(value);
|
|
} else {
|
|
manager()->addHeader(key, value);
|
|
}
|
|
finish(true);
|
|
}
|