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

Streaming Response #143

Merged
merged 15 commits into from Apr 19, 2021
Merged

Streaming Response #143

merged 15 commits into from Apr 19, 2021

Conversation

amitksingh1490
Copy link
Collaborator

No description provided.

@Fristi
Copy link

Fristi commented Apr 15, 2021

At first seems to do the trick, but did you see https://github.com/http4s/http4s-netty ? It seems to use reactive-streams-netty which translates netty into reactive streams. Http4s uses fs2 and uses the interop module to turn a reactive-stream into a fs2 stream, you could do the same with the interop of ZIO.

@amitksingh1490
Copy link
Collaborator Author

At first seems to do the trick, but did you see https://github.com/http4s/http4s-netty ? It seems to use reactive-streams-netty which translates netty into reactive streams. Http4s uses fs2 and uses the interop module to turn a reactive-stream into a fs2 stream, you could do the same with the interop of ZIO.

Thanks @Fristi will look https://github.com/http4s/http4s-netty.

@amitksingh1490 amitksingh1490 marked this pull request as ready for review April 18, 2021 12:20
Comment on lines 87 to 95
private def writeAndFlush(
ctx: JChannelHandlerContext,
jReq: JFullHttpRequest,
res: Response.HttpResponse[R, Throwable],
) = {
ctx.writeAndFlush(encodeResponse(jReq.protocolVersion(), res), ctx.channel().voidPromise())
releaseOrIgnore(jReq)
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private def writeAndFlush(
ctx: JChannelHandlerContext,
jReq: JFullHttpRequest,
res: Response.HttpResponse[R, Throwable],
) = {
ctx.writeAndFlush(encodeResponse(jReq.protocolVersion(), res), ctx.channel().voidPromise())
releaseOrIgnore(jReq)
}

@tusharmath tusharmath changed the title feat(Http): Chunked response Streaming Response Apr 18, 2021
@tusharmath tusharmath added enhancement New feature or request automerge labels Apr 18, 2021
val app = Http.collect { case Method.GET -> Root / "chunked" =>
Response.http(
status = Status.OK,
content = HttpData.StreamData(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
content = HttpData.StreamData(
content = HttpData.stream(

@github-actions github-actions bot added the docs label Apr 19, 2021
@tusharmath tusharmath removed the docs label Apr 19, 2021
@github-actions github-actions bot added the docs label Apr 19, 2021
@amitksingh1490 amitksingh1490 merged commit ec9dc28 into main Apr 19, 2021
@amitksingh1490 amitksingh1490 deleted the feature/Http-chunked-response branch April 19, 2021 08:38
@tusharmath tusharmath added documentation Improvements or additions to documentation and removed docs labels Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants