diff options
author | Nick Stott <nick@nickstott.com> | 2019-10-28 12:41:36 -0400 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2019-10-28 12:41:36 -0400 |
commit | 65d9286203cf239f68c6015818e82e8521e600a1 (patch) | |
tree | 0af1a7be449036f2f4ae9d3ecf06b7d645c8bddc /cli/js/request.ts | |
parent | 967c236fa5fb1e87e1b5ee788fe77d3a07361da1 (diff) |
Re-enable basic stream support for fetch bodies (#3192)
* Add sd-streams from https://github.com/stardazed/sd-streams/blob/master/packages/streams/src/
* change the interfaces in dom_types to match what sd-streams expects
Diffstat (limited to 'cli/js/request.ts')
-rw-r--r-- | cli/js/request.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cli/js/request.ts b/cli/js/request.ts index 0c77b8854..345792c5c 100644 --- a/cli/js/request.ts +++ b/cli/js/request.ts @@ -2,8 +2,10 @@ import * as headers from "./headers.ts"; import * as body from "./body.ts"; import * as domTypes from "./dom_types.ts"; +import * as streams from "./streams/mod.ts"; const { Headers } = headers; +const { ReadableStream } = streams; function byteUpperCase(s: string): string { return String(s).replace(/[a-z]/g, function byteUpperCaseReplace(c): string { @@ -138,7 +140,13 @@ export class Request extends body.Body implements domTypes.Request { headersList.push(header); } - const body2 = this._bodySource; + let body2 = this._bodySource; + + if (this._bodySource instanceof ReadableStream) { + const tees = (this._bodySource as domTypes.ReadableStream).tee(); + this._stream = this._bodySource = tees[0]; + body2 = tees[1]; + } const cloned = new Request(this.url, { body: body2, |