[XHR] overrideMimeType() should be able to change encoding in HEADERS RECEIVED state
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jul 2014 10:09:41 +0000 (10:09 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Jul 2014 10:09:41 +0000 (10:09 +0000)
commite7292e240ecea4b1fee20809b2773410f4d59589
treebda6d6dc9e643a106dfddf289fe041ccca928312
parentb81c8f9b405b2920a395b453dca112cbe6931a0c
[XHR] overrideMimeType() should be able to change encoding in HEADERS RECEIVED state
https://bugs.webkit.org/show_bug.cgi?id=128968

Patch by Youenn Fablet <youenn.fablet@crf.canon.fr> on 2014-07-10
Reviewed by Alexey Proskuryakov.

Source/WebCore:
Moved response encoding computation from didReceiveResponse to didReceiveData, just before the decoder is instantiated.
This allows overrideMimeType to be changed within readystatechange event callback and have an impact on selected encoding.

Test: http/tests/xmlhttprequest/overridemimetype-headers-received-state-force-shiftjis.html

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::didReceiveResponse): Removed m_responseEncoding computation from response and mimeTypeOverride.
(WebCore::XMLHttpRequest::didReceiveData): Added m_responseEncoding computation from response and mimeTypeOverride.

LayoutTests:
Added test equivalent to http://w3c-test.org/web-platform-tests/master/XMLHttpRequest/overridemimetype-headers-received-state-force-shiftjis.htm
The test sets overrideMimeType when xhr state is changed to HEADERS RECEIVED.

* http/tests/xmlhttprequest/overridemimetype-headers-received-state-force-shiftjis-expected.txt: Added.
* http/tests/xmlhttprequest/overridemimetype-headers-received-state-force-shiftjis.html: Added.
* http/tests/xmlhttprequest/resources/get-content.php: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170960 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/http/tests/xmlhttprequest/overridemimetype-headers-received-state-force-shiftjis-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/overridemimetype-headers-received-state-force-shiftjis.html [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/resources/get-content.php [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/xml/XMLHttpRequest.cpp