Commit e83e2e1e authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

[XMLHttpRequest] overrideMimeType(mime) does not update the response's "Content-Type" header

https://bugs.webkit.org/show_bug.cgi?id=98137

Patch by Christophe Dumez <christophe.dumez@intel.com> on 2012-10-02
Reviewed by Kentaro Hara.

Source/WebCore:

According to the XMLHttpRequest specification, overrideMimeType(mime) sets the
"Content-Type" header for the response to mime. However, with the current
implementation, calling overrideMimeType(mime) does not affect the value
returned by client.getResponseHeader("Content-Type"). This patch makes sure
the response's "Content-Type" header is properly updated with the override
MIME type.

Test: http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header.html

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::didReceiveResponse):

LayoutTests:

Add layout test to check that calling overrideMimeType(mime) properly
sets the response's "Content-Type" header to mime.

* http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header-expected.txt: Added.
* http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130158 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4d0e6021
2012-10-02 Christophe Dumez <christophe.dumez@intel.com>
[XMLHttpRequest] overrideMimeType(mime) does not update the response's "Content-Type" header
https://bugs.webkit.org/show_bug.cgi?id=98137
Reviewed by Kentaro Hara.
Add layout test to check that calling overrideMimeType(mime) properly
sets the response's "Content-Type" header to mime.
* http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header-expected.txt: Added.
* http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header.html: Added.
2012-10-02 Andrey Kosyakov <caseq@chromium.org>
 
Unreviewed gardening.
This tests that XMLHttpRequest overrideMimeType() properly updates the Content-Type header for the response.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS xhr.getResponseHeader("Content-Type") is "text/xml;charset=GBK"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="/js-test-resources/js-test-pre.js"></script>
</head>
<body>
<script>
description('This tests that XMLHttpRequest overrideMimeType() properly updates the Content-Type header for the response.');
window.jsTestIsAsync = true;
var xhr = new XMLHttpRequest();
var url = 'resources/reply.xml';
xhr.onreadystatechange = function () {
if (xhr.readyState == xhr.LOADING) {
shouldBe('xhr.getResponseHeader("Content-Type")', '"text/xml;charset=GBK"');
finishJSTest();
}
}
xhr.onerror = function() {
testFailed('The XHR request to an existing resource failed: "' + url + '"');
finishJSTest();
};
xhr.open('GET', url);
xhr.overrideMimeType('text/xml;charset=GBK');
xhr.send();
</script>
<script src="/js-test-resources/js-test-post.js"></script>
</body>
</html>
2012-10-02 Christophe Dumez <christophe.dumez@intel.com>
[XMLHttpRequest] overrideMimeType(mime) does not update the response's "Content-Type" header
https://bugs.webkit.org/show_bug.cgi?id=98137
Reviewed by Kentaro Hara.
According to the XMLHttpRequest specification, overrideMimeType(mime) sets the
"Content-Type" header for the response to mime. However, with the current
implementation, calling overrideMimeType(mime) does not affect the value
returned by client.getResponseHeader("Content-Type"). This patch makes sure
the response's "Content-Type" header is properly updated with the override
MIME type.
Test: http/tests/xmlhttprequest/xmlhttprequest-overridemimetype-content-type-header.html
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::didReceiveResponse):
2012-10-02 Vsevolod Vlasov <vsevik@chromium.org>
 
Web Inspector: Move UISourceCode creation out from ResourceScriptMapping.
......@@ -1116,7 +1116,11 @@ void XMLHttpRequest::didReceiveResponse(unsigned long identifier, const Resource
InspectorInstrumentation::didReceiveXHRResponse(scriptExecutionContext(), identifier);
m_response = response;
m_responseEncoding = extractCharsetFromMediaType(m_mimeTypeOverride);
if (!m_mimeTypeOverride.isEmpty()) {
m_response.setHTTPHeaderField("Content-Type", m_mimeTypeOverride);
m_responseEncoding = extractCharsetFromMediaType(m_mimeTypeOverride);
}
if (m_responseEncoding.isEmpty())
m_responseEncoding = response.textEncodingName();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment