Skip to content

Commit

Permalink
refactor(Http): update example and ServerRequestHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
d11-amitsingh committed Apr 18, 2021
1 parent 040ec94 commit 789314e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
5 changes: 4 additions & 1 deletion example/src/main/scala/WebSocketAdvanced.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ object WebSocketAdvanced extends App {
Response.http(
status = Status.OK,
content = HttpContent.Chunked(
ZStream.repeat(Chunk("Hello world !")).schedule(Schedule.spaced(1 microsecond)).take(2000000),
ZStream
.repeat(Chunk.fromArray("Hello world !".getBytes(HTTP_CHARSET)))
.schedule(Schedule.spaced(1 microsecond))
.take(2000000),
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,7 @@ final case class ServerRequestHandler[R](
releaseOrIgnore(jReq)
executeAsync2(
ctx, {
data
.map(t =>
t.map(x => {
Unpooled.copiedBuffer(x, HTTP_CHARSET)
}).map(x => {
ctx.writeAndFlush(x)
()
}),
)
.runDrain
data.map(t => ctx.writeAndFlush(Unpooled.copiedBuffer(t.toArray))).runDrain
} *> ChannelFuture.unit(ctx.writeAndFlush(LastHttpContent.EMPTY_LAST_CONTENT)),
)

Expand Down

0 comments on commit 789314e

Please sign in to comment.