XMLHttpRequest.getAllResponseHeaders should use CRLF
Summary: XMLHttpRequest.prototype.getAllResponseHeaders was previously joining the headers with `\n`. The spec at: https://xhr.spec.whatwg.org/#the-getallresponseheaders()-method step 3.2, requires the headers to be joined using `\r\n`. Closes https://github.com/facebook/react-native/pull/10034 Differential Revision: D3917020 fbshipit-source-id: f4e920f6bebacc3aa5c52c84348157d2b530480f
This commit is contained in:
parent
1142d9d059
commit
24c72f513e
|
@ -340,7 +340,7 @@ class XMLHttpRequest extends EventTarget(...XHR_EVENTS) {
|
|||
var headers = this.responseHeaders || {};
|
||||
return Object.keys(headers).map((headerName) => {
|
||||
return headerName + ': ' + headers[headerName];
|
||||
}).join('\n');
|
||||
}).join('\r\n');
|
||||
}
|
||||
|
||||
getResponseHeader(header: string): ?string {
|
||||
|
|
|
@ -194,4 +194,17 @@ describe('XMLHttpRequest', function() {
|
|||
expect(handleProgress.mock.calls[0][0].total).toBe(100);
|
||||
});
|
||||
|
||||
it('should combine response headers with CRLF', function() {
|
||||
xhr.open('GET', 'blabla');
|
||||
xhr.send();
|
||||
xhr.__didReceiveResponse(1, 200, {
|
||||
'Content-Type': 'text/plain; charset=utf-8',
|
||||
'Content-Length': '32',
|
||||
});
|
||||
|
||||
expect(xhr.getAllResponseHeaders()).toBe(
|
||||
'Content-Type: text/plain; charset=utf-8\r\n' +
|
||||
'Content-Length: 32');
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue