[edk2-devel] [PATCH v2 3/4] NetworkPkg/HttpDxe: Detect 'Connection: close' header

Oliver Steffen posted 4 patches 3 years, 11 months ago
There is a newer version of this series
[edk2-devel] [PATCH v2 3/4] NetworkPkg/HttpDxe: Detect 'Connection: close' header
Posted by Oliver Steffen 3 years, 11 months ago
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>
---
 NetworkPkg/HttpDxe/HttpImpl.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index d8b014c94f3a..d40d55ac92ad 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.
       //
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87353): https://edk2.groups.io/g/devel/message/87353
Mute This Topic: https://groups.io/mt/89636385/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2 3/4] NetworkPkg/HttpDxe: Detect 'Connection: close' header
Posted by Gerd Hoffmann 3 years, 11 months ago
On Tue, Mar 08, 2022 at 02:21:03PM +0100, Oliver Steffen wrote:
> 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: Gerd Hoffmann <kraxel@redhat.com>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87384): https://edk2.groups.io/g/devel/message/87384
Mute This Topic: https://groups.io/mt/89636385/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-