From 65d9286203cf239f68c6015818e82e8521e600a1 Mon Sep 17 00:00:00 2001 From: Nick Stott Date: Mon, 28 Oct 2019 12:41:36 -0400 Subject: 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 --- cli/js/request.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'cli/js/request.ts') 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, -- cgit v1.2.3