Browse files

Redirects should not send content type. Fixes #162

  • Loading branch information...
1 parent c5e6396 commit 25fe9befaced15ac80bcdc7d18f27ad39cdeff5b Matthew Mongeau and Joe Ferris committed with halogenandtoast Sep 9, 2011
Showing with 36 additions and 2 deletions.
  1. +30 −0 spec/driver_spec.rb
  2. +5 −2 src/NetworkAccessManager.cpp
  3. +1 −0 src/WebPage.cpp
View
30 spec/driver_spec.rb
@@ -104,6 +104,36 @@
end
end
+ context "redirect app" do
+ before(:all) do
+ @app = lambda do |env|
+ if env['PATH_INFO'] == '/target'
+ content_type = "<p>#{env['CONTENT_TYPE']}</p>"
+ [200, {"Content-Type" => "text/html", "Content-Length" => content_type.length.to_s}, [content_type]]
+ elsif env['PATH_INFO'] == '/form'
+ body = <<-HTML
+ <html>
+ <body>
+ <form action="/redirect" method="POST" enctype="multipart/form-data">
+ <input name="submit" type="submit" />
+ </form>
+ </body>
+ </html>
+ HTML
+ [200, {"Content-Type" => "text/html", "Content-Length" => body.length.to_s}, [body]]
+ else
+ [301, {"Location" => "/target"}, [""]]
+ end
+ end
+ end
+
+ it "should redirect without content type" do
+ subject.visit("/form")
+ subject.find("//input").first.click
+ subject.find("//p").first.text.should == ""
+ end
+ end
+
context "hello app" do
before(:all) do
@app = lambda do |env|
View
7 src/NetworkAccessManager.cpp
@@ -6,14 +6,17 @@
NetworkAccessManager::NetworkAccessManager(QObject *parent):QNetworkAccessManager(parent) {
}
-QNetworkReply* NetworkAccessManager::createRequest(QNetworkAccessManager::Operation oparation, const QNetworkRequest &request, QIODevice * outgoingData = 0) {
+QNetworkReply* NetworkAccessManager::createRequest(QNetworkAccessManager::Operation operation, const QNetworkRequest &request, QIODevice * outgoingData = 0) {
QNetworkRequest new_request(request);
+ if (operation != QNetworkAccessManager::PostOperation && operation != QNetworkAccessManager::PutOperation) {
+ new_request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant());
+ }
QHashIterator<QString, QString> item(m_headers);
while (item.hasNext()) {
item.next();
new_request.setRawHeader(item.key().toAscii(), item.value().toAscii());
}
- return QNetworkAccessManager::createRequest(oparation, new_request, outgoingData);
+ return QNetworkAccessManager::createRequest(operation, new_request, outgoingData);
};
void NetworkAccessManager::addHeader(QString key, QString value) {
View
1 src/WebPage.cpp
@@ -158,6 +158,7 @@ QString WebPage::chooseFile(QWebFrame *parentFrame, const QString &suggestedFile
}
bool WebPage::extension(Extension extension, const ExtensionOption *option, ExtensionReturn *output) {
+ Q_UNUSED(option);
if (extension == ChooseMultipleFilesExtension) {
QStringList names = QStringList() << getLastAttachedFileName();
static_cast<ChooseMultipleFilesExtensionReturn*>(output)->fileNames = names;

0 comments on commit 25fe9be

Please sign in to comment.