diff options
| author | Divy Srivastava <dj.srivastava23@gmail.com> | 2022-08-18 17:35:02 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-18 17:35:02 +0530 |
| commit | cd21cff29942f24ba7d38287186cce64d0e84e56 (patch) | |
| tree | e663eff884526ee762ae9141a3cf5a0f6967a84e /ext/fetch/22_body.js | |
| parent | 0b0843e4a54d7c1ddf293ac1ccee2479b69a5ba9 (diff) | |
feat(ext/flash): An optimized http/1.1 server (#15405)
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
Co-authored-by: crowlkats <crowlkats@toaxl.com>
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'ext/fetch/22_body.js')
| -rw-r--r-- | ext/fetch/22_body.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ext/fetch/22_body.js b/ext/fetch/22_body.js index 10ddb7603..a51cdc184 100644 --- a/ext/fetch/22_body.js +++ b/ext/fetch/22_body.js @@ -388,7 +388,10 @@ let source = null; let length = null; let contentType = null; - if (ObjectPrototypeIsPrototypeOf(BlobPrototype, object)) { + if (typeof object === "string") { + source = object; + contentType = "text/plain;charset=UTF-8"; + } else if (ObjectPrototypeIsPrototypeOf(BlobPrototype, object)) { stream = object.stream(); source = object; length = object.size; @@ -424,24 +427,21 @@ // TODO(@satyarohith): not sure what primordial here. source = object.toString(); contentType = "application/x-www-form-urlencoded;charset=UTF-8"; - } else if (typeof object === "string") { - source = object; - contentType = "text/plain;charset=UTF-8"; } else if (ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, object)) { stream = object; if (object.locked || isReadableStreamDisturbed(object)) { throw new TypeError("ReadableStream is locked or disturbed"); } } - if (ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, source)) { - stream = { body: source, consumed: false }; - length = source.byteLength; - } else if (typeof source === "string") { + if (typeof source === "string") { // WARNING: this deviates from spec (expects length to be set) // https://fetch.spec.whatwg.org/#bodyinit > 7. // no observable side-effect for users so far, but could change stream = { body: source, consumed: false }; length = null; // NOTE: string length != byte length + } else if (ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, source)) { + stream = { body: source, consumed: false }; + length = source.byteLength; } const body = new InnerBody(stream); body.source = source; |
