mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Rather than creating a new NetworkAccessManager when the page is reset,
reuse the existing manager and just clear its headers and cookies. This avoids repeatedly setting up the SIGNAL/SLOT callback stuff which is leading to unclosed pipes on Ubuntu, eventually causing "too many open files" errors in large test suites.
This commit is contained in:
parent
c2a2bd0376
commit
f190f51652
3 changed files with 11 additions and 3 deletions
|
@ -23,3 +23,7 @@ void NetworkAccessManager::addHeader(QString key, QString value) {
|
|||
m_headers.insert(key, value);
|
||||
};
|
||||
|
||||
void NetworkAccessManager::resetHeaders() {
|
||||
m_headers.clear();
|
||||
};
|
||||
|
||||
|
|
|
@ -9,10 +9,11 @@ class NetworkAccessManager : public QNetworkAccessManager {
|
|||
public:
|
||||
NetworkAccessManager(QObject *parent = 0);
|
||||
void addHeader(QString key, QString value);
|
||||
void resetHeaders();
|
||||
|
||||
protected:
|
||||
QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice * outgoingData);
|
||||
|
||||
private:
|
||||
QHash<QString, QString> m_headers;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -8,8 +8,11 @@ Reset::Reset(WebPage *page, QStringList &arguments, QObject *parent) : Command(p
|
|||
|
||||
void Reset::start() {
|
||||
page()->triggerAction(QWebPage::Stop);
|
||||
page()->networkAccessManager()->setCookieJar(new NetworkCookieJar());
|
||||
page()->setCustomNetworkAccessManager();
|
||||
|
||||
NetworkAccessManager* networkAccessManager = qobject_cast<NetworkAccessManager*>(page()->networkAccessManager());
|
||||
networkAccessManager->setCookieJar(new NetworkCookieJar());
|
||||
networkAccessManager->resetHeaders();
|
||||
|
||||
page()->setUserAgent(NULL);
|
||||
page()->resetResponseHeaders();
|
||||
page()->resetConsoleMessages();
|
||||
|
|
Loading…
Reference in a new issue