Issue #6642 - move shutdown logic into HttpChannelOverHTTP and HttpConnection

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2021-08-27 11:53:54 +10:00
parent fa316fc20d
commit 949aa6c342
3 changed files with 5 additions and 11 deletions

View File

@ -103,7 +103,7 @@ public class HttpChannelOverHTTP extends HttpChannel
closeReason = "failure";
else if (receiver.isShutdown())
closeReason = "server close";
else if (sender.isShutdown())
else if (sender.isShutdown() && response.getStatus() != HttpStatus.SWITCHING_PROTOCOLS_101)
closeReason = "client close";
if (closeReason == null)

View File

@ -345,15 +345,6 @@ public class HttpGenerator
return Result.FLUSH;
}
_state = State.END;
// 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;
return Boolean.TRUE.equals(_persistent) ? Result.DONE : Result.SHUTDOWN_OUT;
}

View File

@ -28,6 +28,7 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.MetaData;
import org.eclipse.jetty.http.PreEncodedHttpField;
import org.eclipse.jetty.io.AbstractConnection;
@ -885,8 +886,10 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
@Override
protected void onCompleteSuccess()
{
boolean upgrading = _info.getStatus() == HttpStatus.SWITCHING_PROTOCOLS_101;
release().succeeded();
if (_shutdownOut)
// If successfully upgraded it is responsibility of the next protocol to close the connection.
if (_shutdownOut && !upgrading)
getEndPoint().shutdownOutput();
}