Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxyRequest should be able to proxy streams #373

Closed
1 task done
iainsproat opened this issue Apr 11, 2023 · 1 comment
Closed
1 task done

proxyRequest should be able to proxy streams #373

iainsproat opened this issue Apr 11, 2023 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers proxy

Comments

@iainsproat
Copy link
Contributor

iainsproat commented Apr 11, 2023

Describe the feature

Attempting to proxy a request with a stream using proxyRequest currently fails as the body is incorrectly read.

For example, the following will not result in the expected body value of This is a streamed request reaching the /debug path:

app.use(
        "/",
        eventHandler((event) => {
          return proxyRequest(event, url + "/debug", { fetch });
        })
);
      
const stream = new ReadableStream({
        start(controller) {
          controller.enqueue("This ");
          controller.enqueue("is ");
          controller.enqueue("a ");
          controller.enqueue("streamed ");
          controller.enqueue("request.");
          controller.close();
        },
      }).pipeThrough(new TextEncoderStream());

      const result = await fetch(url + "/", {
        method: "POST",
        body: stream,
        headers: {
          "content-type": "application/octet-stream",
          "x-custom": "hello",
        },
        duplex: "half",
      }).then((r) => r.json());

Additional information

  • Would you be willing to help implement this feature?

I have provided a rough outline of the problem and potential solution in #374

@pi0
Copy link
Member

pi0 commented Jul 27, 2023

This is opt-in supported via #413 please check nightly channel in readme if you like to early test.

@pi0 pi0 closed this as completed Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers proxy
Projects
None yet
Development

No branches or pull requests

3 participants