It looks like channelRead
can be called multiple times per HTTP request, and may contain several reqPart
which are of type body
. In the switch statement the .body
case assigns the latest bodyBytes
to the body
variable, losing previous parts.
I'm not familiar with NIO and ByteBuffers so I don't know if this is safe, but a naive fix may be to allocate body in the initialiser and then in channelRead(context:data:)
:
var body = ByteBuffer()
...
case .body(var bodyBytes):
body.writeBuffer(&bodyBytes)
This seems to fix the issue for requests with larger payloads which may be broken up into several .body
calls. However I'm not sure if we are responsible for any cleanup of the buffer etc. If that solution looks good to you I can create a PR.