From fa316fc20d4ecfc8401e30095d6250251d00f02c Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Thu, 26 Aug 2021 13:09:36 +1000 Subject: [PATCH] Issue #6642 - never shutdown output after generating a request. Signed-off-by: Lachlan Roberts --- .../org/eclipse/jetty/http/HttpGenerator.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java index 8a35c6c6ed53..5cefc3002fe1 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java @@ -346,17 +346,14 @@ private Result completing(ByteBuffer chunk, ByteBuffer content) } _state = State.END; - // If this is an upgrade then we don't want to close the connection. + // If this is a request, don't close the connection until the server responds. + if (_info.isRequest()) + return Result.DONE; + + // If successfully upgraded it is responsibility of the next protocol to close the connection. if (_info.isResponse() && ((MetaData.Response)_info).getStatus() == HttpStatus.SWITCHING_PROTOCOLS_101) - { return Result.DONE; - } - else if (_info.isRequest()) - { - HttpField connectionHeader = _info.getFields().getField(HttpHeader.CONNECTION); - if (connectionHeader != null && connectionHeader.contains(HttpHeaderValue.UPGRADE.asString())) - return Result.DONE; - } + return Boolean.TRUE.equals(_persistent) ? Result.DONE : Result.SHUTDOWN_OUT; }