Set the URL of NoOpReply to the request URL
Prevents insertion of an empty URL into m_responses when the requested URL is blacklisted.
This commit is contained in:
parent
5127c01366
commit
b829103bbd
|
@ -1935,6 +1935,13 @@ describe Capybara::Webkit::Driver do
|
|||
driver.find("//p").first.text.should == "Inner"
|
||||
end
|
||||
end
|
||||
|
||||
it "returns a status code for blocked urls" do
|
||||
driver.visit("/")
|
||||
driver.within_frame('frame1') do
|
||||
driver.status_code.should == 200
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "timeout for long requests" do
|
||||
|
|
|
@ -13,7 +13,7 @@ QNetworkReply* NetworkAccessManager::createRequest(QNetworkAccessManager::Operat
|
|||
QNetworkRequest new_request(request);
|
||||
QByteArray url = new_request.url().toEncoded();
|
||||
if (this->isBlacklisted(new_request.url())) {
|
||||
return this->noOpRequest();
|
||||
return new NoOpReply(new_request, this);
|
||||
} else {
|
||||
if (operation != QNetworkAccessManager::PostOperation && operation != QNetworkAccessManager::PutOperation) {
|
||||
new_request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant());
|
||||
|
@ -99,7 +99,3 @@ bool NetworkAccessManager::isBlacklisted(QUrl url) {
|
|||
return false;
|
||||
};
|
||||
|
||||
QNetworkReply* NetworkAccessManager::noOpRequest() {
|
||||
return new NoOpReply();
|
||||
};
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ class NetworkAccessManager : public QNetworkAccessManager {
|
|||
QHash<QString, QString> m_headers;
|
||||
QHash<QUrl, NetworkResponse> m_responses;
|
||||
bool isBlacklisted(QUrl url);
|
||||
QNetworkReply* noOpRequest();
|
||||
QHash<QUrl, QUrl> m_redirectMappings;
|
||||
|
||||
private slots:
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#include <QTimer>
|
||||
#include "NoOpReply.h"
|
||||
|
||||
NoOpReply::NoOpReply(QObject *parent) : QNetworkReply(parent) {
|
||||
NoOpReply::NoOpReply(QNetworkRequest &request, QObject *parent) : QNetworkReply(parent) {
|
||||
open(ReadOnly | Unbuffered);
|
||||
setAttribute(QNetworkRequest::HttpStatusCodeAttribute, 200);
|
||||
setHeader(QNetworkRequest::ContentLengthHeader, QVariant(0));
|
||||
setHeader(QNetworkRequest::ContentTypeHeader, QVariant(QString("text/plain")));
|
||||
setUrl(request.url());
|
||||
|
||||
QTimer::singleShot( 0, this, SIGNAL(readyRead()) );
|
||||
QTimer::singleShot( 0, this, SIGNAL(finished()) );
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
|
||||
class NoOpReply : public QNetworkReply {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NoOpReply( QObject *parent=0 );
|
||||
NoOpReply(QNetworkRequest &request, QObject *parent = 0);
|
||||
|
||||
void abort();
|
||||
qint64 bytesAvailable() const;
|
||||
|
|
Loading…
Reference in New Issue