Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Revert "Represent non-stringified JSON request body as an [object Obj…
…ect] string"
This reverts commit 5c6b055.
- Loading branch information
Showing
with
1 addition
and
7 deletions.
-
+1
−7
fetch.js
|
|
@@ -246,20 +246,14 @@ function Body() { |
|
|
this._bodyText = body = Object.prototype.toString.call(body) |
|
|
} |
|
|
|
|
|
var contentType = this.headers.get('content-type') |
|
|
|
|
|
if (!contentType) { |
|
|
if (!this.headers.get('content-type')) { |
|
|
if (typeof body === 'string') { |
|
|
this.headers.set('content-type', 'text/plain;charset=UTF-8') |
|
|
} else if (this._bodyBlob && this._bodyBlob.type) { |
|
|
this.headers.set('content-type', this._bodyBlob.type) |
|
|
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { |
|
|
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8') |
|
|
} |
|
|
} else if (contentType.indexOf('json') >= 0 && typeof this._bodyInit !== 'string') { |
|
|
// Always pass a text representation of a non-stringified JSON body |
|
|
// to `XMLHttpRequest.send` to retain a compatible behavior with the browser. |
|
|
this._bodyInit = this._bodyText |
|
|
} |
|
|
} |
|
|
|
|
|
|