Skip to content

Can't pipe a stream to ctx.res from http.get #1750

Answered by simongcc
simongcc asked this question in Q&A
Discussion options

You must be logged in to vote

A quick update to the question.
I found the follow works without piping it.
Because in the source code of koa application.js
it is

if (body instanceof Stream) return body.pipe(res);

So it is not necessary to pipe for Koa, Koa will handle it.
And thus

 await imageStream.pipe(ctx.res); => //  await imageStream.pipe(ctx.res); Not necessary

But then I found another problem.
If the stream originally controlled by authenticated source. This is not working.
I will continue to study. If any one knows could share their insight. Much thanks.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by simongcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant