fix(http): set the default Accept header (#12989)

Fixes #6354
This commit is contained in:
Dzmitry Shylovich
2016-12-07 03:20:43 +03:00
committed by Alex Rickabaugh
parent 25c2141991
commit 986abbe0b2
2 changed files with 25 additions and 2 deletions

View File

@ -109,9 +109,13 @@ export class XHRConnection implements Connection {
this.setDetectedContentType(req, _xhr);
if (req.headers != null) {
req.headers.forEach((values, name) => _xhr.setRequestHeader(name, values.join(',')));
if (req.headers == null) {
req.headers = new Headers();
}
if (!req.headers.has('Accept')) {
req.headers.append('Accept', 'application/json, text/plain, */*');
}
req.headers.forEach((values, name) => _xhr.setRequestHeader(name, values.join(',')));
// Select the correct buffer type to store the response
if (req.responseType != null && _xhr.responseType != null) {