Skip to content

Commit

Permalink
[serving][rolling-batch] avoid transfer chunked encoding with non-str… (
Browse files Browse the repository at this point in the history
  • Loading branch information
siddvenk authored Nov 14, 2024
1 parent 567ae86 commit e19237a
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,20 @@ void sendOutput(Output output, ChannelHandlerContext ctx) {
byte[] buf = supplier.nextChunk(chunkReadTime, TimeUnit.SECONDS);
// Defer sending HTTP header until first chunk received.
// This allows inference update HTTP code.
// If this is the first and last chunk, we're in a non-streaming case and can
// use default response without chunked transfer encoding
if (first && !supplier.hasNext()) {
FullHttpResponse resp =
new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status);
for (Map.Entry<String, String> entry : output.getProperties().entrySet()) {
resp.headers().set(entry.getKey(), entry.getValue());
}
if (buf != null) {
resp.content().writeBytes(buf);
}
NettyUtils.sendHttpResponse(ctx, resp, true);
return;
}
if (first) {
code = output.getCode();
status = new HttpResponseStatus(code, output.getMessage());
Expand Down

0 comments on commit e19237a

Please sign in to comment.