NetworkPkg/HttpDxe: Detect 'Connection: close' header

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2720

Force connection close before the next request if
the server sends the 'Connection: close' header.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Oliver Steffen 2022-03-22 14:30:07 +01:00 committed by mergify[bot]
parent c43ff5188d
commit 753fd319e2
1 changed files with 11 additions and 0 deletions

View File

@ -994,6 +994,7 @@ HttpResponseWorker (
UINTN HdrLen;
NET_FRAGMENT Fragment;
UINT32 TimeoutValue;
UINTN Index;
if ((Wrap == NULL) || (Wrap->HttpInstance == NULL)) {
return EFI_INVALID_PARAMETER;
@ -1200,6 +1201,16 @@ HttpResponseWorker (
FreePool (HttpHeaders);
HttpHeaders = NULL;
for (Index = 0; Index < HttpMsg->HeaderCount; ++Index) {
if ((AsciiStriCmp ("Connection", HttpMsg->Headers[Index].FieldName) == 0) &&
(AsciiStriCmp ("close", HttpMsg->Headers[Index].FieldValue) == 0))
{
DEBUG ((DEBUG_VERBOSE, "Http: 'Connection: close' header received.\n"));
HttpInstance->ConnectionClose = TRUE;
break;
}
}
//
// Init message-body parser by header information.
//