Skip to content

Commit

Permalink
Fix #12356 Do not send keep-alive when not persistent
Browse files Browse the repository at this point in the history
refactor to make less fragile
  • Loading branch information
gregw committed Oct 14, 2024
1 parent 0aedc8c commit 6e52cfa
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -788,16 +788,24 @@ else if (response != null)
if (contentLength >= 0 && (contentLength > 0 || assumedContent || contentLengthField))
putContentLength(header, contentLength);

if (http11 && !connectionClose)
if (http11)
{
if (connection == null)
connection = CONNECTION_CLOSE;
else
connection = connection.withValue(HttpHeaderValue.CLOSE.asString());
if (!connectionClose)
{
if (connection == null)
connection = CONNECTION_CLOSE;
else
connection = connection.withValue(HttpHeaderValue.CLOSE.asString());
connectionClose = true;
}
}
else if (http10 && connectionKeepAlive)
else if (http10)
{
connection = connection.withoutValue(HttpHeaderValue.KEEP_ALIVE.asString());
if (connectionKeepAlive)
{
connection = connection.withoutValue(HttpHeaderValue.KEEP_ALIVE.asString());
connectionKeepAlive = false;
}
}
}
// Else we must be a request
Expand Down

0 comments on commit 6e52cfa

Please sign in to comment.