[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: http://svn.webkit.org/repository/webkit/trunk@170960 268f45cc-cd09-0410-ab3c-d52691b4dbfc