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

Iis it possible to proxy streaming responses? #6

Closed
yeus opened this issue Jan 21, 2024 · 3 comments · Fixed by #7
Closed

Iis it possible to proxy streaming responses? #6

yeus opened this issue Jan 21, 2024 · 3 comments · Fixed by #7

Comments

@yeus
Copy link

yeus commented Jan 21, 2024

Issue

I have tried to find anything in documentation about this and it didn't work "out-of-the-box" for me. But I would like to proxy a streamed response.

Did I miss anything? Or is this not/already implemented?

@cmorten
Copy link
Owner

cmorten commented Jan 28, 2024

Hi @yeus 👋

You weren't missing anything, streaming wasn't supported.

In #7 I've hopefully now added support so responses are streamed from the proxied source provided you aren't making use of any functionality that decorates/filters based on the response in any way (in which case the response is buffered into memory as was done previously).

See ./test/streaming.test.ts for an example.

If encounter any problems let me know and can re-open the issue if needed.

@yeus
Copy link
Author

yeus commented Jan 29, 2024

Hi @yeus 👋

You weren't missing anything, streaming wasn't supported.

In #7 I've hopefully now added support so responses are streamed from the proxied source provided you aren't making use of any functionality that decorates/filters based on the response in any way (in which case the response is buffered into memory as was done previously).

See ./test/streaming.test.ts for an example.

If encounter any problems let me know and can re-open the issue if needed.

Thank you, that sounds awesome! I will try it out.

Is there a way to look at the response after it has been sent though?

@cmorten
Copy link
Owner

cmorten commented Feb 7, 2024

Sorry for the slow reply.

Being honest not sure atm, not quite familiar enough with Oak to say for sure. This library doesn’t offer any way to tap or fork the response, but there may be a way to add a middleware in Oak to read off the context object what was sent.

Just to FYI it seems after this lib launched Oak has since introduced its own proxy middleware - being a first class middleware maintained by the Oak project itself, it might be worth considering as suspect will support things better 😊

See:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants