Skip to content

Commit

Permalink
Updated HttpGenerator to handle Upgrade responses.
Browse files Browse the repository at this point in the history
Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Oct 14, 2024
1 parent c9e8d10 commit 4192d73
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ private void generateHeaders(ByteBuffer header, ByteBuffer content, boolean last
boolean http11 = _info.getHttpVersion() == HttpVersion.HTTP_1_1;
boolean connectionClose = false;
boolean connectionKeepAlive = false;
boolean connectionUpgrade = false;
boolean chunkedHint = _info.getTrailersSupplier() != null;
boolean contentType = false;
long contentLength = _info.getContentLength();
Expand Down Expand Up @@ -639,6 +640,7 @@ else if (contentLength != field.getLongValue())

connectionClose |= field.contains(HttpHeaderValue.CLOSE.asString());
connectionKeepAlive |= field.contains(HttpHeaderValue.KEEP_ALIVE.asString());
connectionUpgrade |= field.contains(HttpHeaderValue.UPGRADE.asString());
break;
}

Expand All @@ -660,7 +662,7 @@ else if (contentLength != field.getLongValue())
boolean assumedContent = assumedContentRequest || contentType || chunkedHint;
boolean noContentRequest = request != null && contentLength <= 0 && !assumedContent;

// Handle connect requests
// Handle CONNECT requests.
if (request != null && HttpMethod.CONNECT.is(request.getMethod()))
{
_persistent = true;
Expand All @@ -669,6 +671,16 @@ else if (contentLength != field.getLongValue())
if (connectionClose)
connectionClose = false;
}
// Handle Upgrade responses.
if (request != null && connectionUpgrade)
{
_persistent = true;
if (connectionClose)
{
connection = connection.withoutValue(HttpHeaderValue.CLOSE.asString());
connectionClose = false;
}
}

// Handle persistence and adjust connection header if necessary.
if (http11)
Expand Down

0 comments on commit 4192d73

Please sign in to comment.