angular-docs-cn/packages/common/http/test
Alex Rickabaugh 452a7ae88b fix(common): fix XSSI prefix stripping by using JSON.parse always (#18466)
Currently HttpClient sends requests for JSON data with the
XMLHttpRequest.responseType set to 'json'. With this flag, the browser
will attempt to parse the response as JSON, but will return 'null' on
any errors. If the JSON response contains an XSSI-prevention prefix,
this will cause the browser's parsing to fail, which is unrecoverable.

The only compelling reason to use the responseType 'json' is for
performance (especially if the browser offloads JSON parsing to a
separate thread). I'm not aware of any browser which does this currently,
nor of any plans to do so. JSON.parse and responseType 'json' both
end up using the same V8 code path in Chrome to implement the parse.

Thus, this change switches all JSON parsing in HttpClient to use
JSON.parse directly.

Fixes #18396, #18453.

PR Close #18466
2017-08-29 17:18:54 -07:00
..
client_spec.ts feat(common): accept object map for HttpClient headers & params (#18490) 2017-08-29 17:18:02 -07:00
headers_spec.ts feat(common): new HttpClient API 2017-07-07 12:09:32 -07:00
jsonp_mock.ts feat(common): new HttpClient API 2017-07-07 12:09:32 -07:00
jsonp_spec.ts build: enable TSLint on the packages folder 2017-07-31 15:47:57 -07:00
module_spec.ts feat(common): new HttpClient API 2017-07-07 12:09:32 -07:00
params_spec.ts build: enable TSLint on the packages folder 2017-07-31 15:47:57 -07:00
request_spec.ts feat(common): two missing features in HttpClient (#17996) 2017-07-07 14:56:36 -07:00
response_spec.ts feat(common): new HttpClient API 2017-07-07 12:09:32 -07:00
xhr_mock.ts fix(common): fix XSSI prefix stripping by using JSON.parse always (#18466) 2017-08-29 17:18:54 -07:00
xhr_spec.ts fix(common): fix XSSI prefix stripping by using JSON.parse always (#18466) 2017-08-29 17:18:54 -07:00
xsrf_spec.ts build: enable TSLint on the packages folder 2017-07-31 15:47:57 -07:00