I use tapir + akka http for the service. One of the endpoints downloads files.
val load
: Endpoint[Source[ByteString, Any], Any, Any, AkkaStreams] =
endpoint
.post
.in("load")
.in(streamBody(AkkaStreams)(
Schema(Schema.schemaForByteArray.schemaType),
CodecFormat.OctetStream()
))
.out(???)
Gettin warn
Sending an 2xx 'early' response before end of request was received
How do I handle this using tapir?
This is this issue with akka-http: https://github.com/akka/akka-http/issues/2455
Do you use
Sourceof chunks in your code? Akka-http consumes messages, whenLastChunkis consumed, it sends response, not even consumingMessageEndwhich comes afterLastChunk.MessageEndis not consumed,messageEndPendingis set totruehence the warning about early response.I worked around it by filtering the
LastChunkand concatenating it to the end of the stream - afterMessageEndand thus forcing akka-http to consumeMessageEnd.