Skip to content

Commit

Permalink
Redirects should not send content type. Fixes thoughtbot#162
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Mongeau and Joe Ferris authored and halogenandtoast committed Sep 15, 2011
1 parent c5e6396 commit 25fe9be
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
30 changes: 30 additions & 0 deletions spec/driver_spec.rb
Expand Up @@ -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|
Expand Down
7 changes: 5 additions & 2 deletions src/NetworkAccessManager.cpp
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/WebPage.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 25fe9be

Please sign in to comment.