Browse Source

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>
Oliver Steffen 2 years ago
parent
commit
753fd319e2
1 changed files with 11 additions and 0 deletions
  1. 11 0
      NetworkPkg/HttpDxe/HttpImpl.c

+ 11 - 0
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.
       //