mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
Redirects should not send content type. Fixes #162
This commit is contained in:
parent
c5e6396b6b
commit
25fe9befac
3 changed files with 36 additions and 2 deletions
|
@ -104,6 +104,36 @@ describe Capybara::Driver::Webkit do
|
|||
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|
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue