-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test: add failing test for echoing raw data * fix: fix unsafe cast issue * test: simplify test case
- Loading branch information
1 parent
79674a9
commit f5f2883
Showing
5 changed files
with
31 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 2 additions & 6 deletions
8
zio-http/src/main/scala/zhttp/service/RequestBodyHandler.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,18 @@ | ||
package zhttp.service | ||
import io.netty.channel.{ChannelHandlerContext, SimpleChannelInboundHandler} | ||
import io.netty.handler.codec.http.{HttpContent, LastHttpContent} | ||
import zhttp.http.HttpData.{UnsafeChannel, UnsafeContent} | ||
|
||
final class RequestBodyHandler(val callback: UnsafeChannel => UnsafeContent => Unit) | ||
final class RequestBodyHandler(val callback: HttpContent => Unit) | ||
extends SimpleChannelInboundHandler[HttpContent](false) { self => | ||
|
||
private var onMessage: UnsafeContent => Unit = _ | ||
|
||
override def channelRead0(ctx: ChannelHandlerContext, msg: HttpContent): Unit = { | ||
self.onMessage(new UnsafeContent(msg)) | ||
self.callback(msg) | ||
if (msg.isInstanceOf[LastHttpContent]) { | ||
ctx.channel().pipeline().remove(self): Unit | ||
} | ||
} | ||
|
||
override def handlerAdded(ctx: ChannelHandlerContext): Unit = { | ||
self.onMessage = callback(new UnsafeChannel(ctx)) | ||
ctx.read(): Unit | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters