diff --git a/cloudflare/fetch/bind.go b/cloudflare/fetch/bind.go index 72e69dd..286c8b6 100644 --- a/cloudflare/fetch/bind.go +++ b/cloudflare/fetch/bind.go @@ -30,5 +30,5 @@ func fetch(namespace js.Value, req *http.Request, init *RequestInit) (*http.Resp return nil, err } - return jshttp.ToStreamResponse(jsRes) + return jshttp.ToResponse(jsRes) } diff --git a/internal/jshttp/response.go b/internal/jshttp/response.go index c688333..8a27bb0 100644 --- a/internal/jshttp/response.go +++ b/internal/jshttp/response.go @@ -30,17 +30,6 @@ func ToResponse(res js.Value) (*http.Response, error) { return toResponse(res, body) } -// ToStreamResponse pipes JavaScript sides Response to TransformStream and converts to *http.Response. -// - see: https://developers.cloudflare.com/workers/runtime-apis/streams/ -func ToStreamResponse(res js.Value) (*http.Response, error) { - ts := js.Global().Get("IdentityTransformStream").New() - readable := ts.Get("readable") - writable := ts.Get("writable") - res.Get("body").Call("pipeTo", writable) - body := jsutil.ConvertReadableStreamToReadCloser(readable) - return toResponse(res, body) -} - // ToJSResponse converts *http.Response to JavaScript sides Response class object. func ToJSResponse(res *http.Response) js.Value { return newJSResponse(res.StatusCode, res.Header, res.Body, nil)