From 753fd319e22c6d900c7c77d025bfc33976534e7f Mon Sep 17 00:00:00 2001 From: Oliver Steffen Date: Tue, 22 Mar 2022 14:30:07 +0100 Subject: 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 Reviewed-by: Maciej Rabeda Reviewed-by: Gerd Hoffmann --- NetworkPkg/HttpDxe/HttpImpl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'NetworkPkg') diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index d8b014c..4ec2e8f 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -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. // -- cgit v1.1