[edk2-devel] [PATCH 4/4] NetworkPkg/HttpDxe: Detect non-HTTP/1.1 servers

Oliver Steffen posted 4 patches 3 years, 11 months ago
There is a newer version of this series
[edk2-devel] [PATCH 4/4] NetworkPkg/HttpDxe: Detect non-HTTP/1.1 servers
Posted by Oliver Steffen 3 years, 11 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2720

Force connecton close before the next request if
the server does not identify as version 1.1.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
---
 NetworkPkg/HttpDxe/HttpImpl.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index a1a3eea585..ea1ab60517 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -1105,6 +1105,14 @@ HttpResponseWorker (
       HttpInstance->CacheLen = BodyLen;

     }

 

+    //

+    // Check server's HTTP version.

+    //

+    if (AsciiStrnCmp (HttpHeaders, HTTP_VERSION, AsciiStrLen (HTTP_VERSION)) != 0) {

+      DEBUG ((DEBUG_WARN, "HTTP: Server version is not 1.1. Setting Connection close.\n"));

+      HttpInstance->ConnectionClose = TRUE;

+    }

+

     //

     // Search for Status Code.

     //

-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87287): https://edk2.groups.io/g/devel/message/87287
Mute This Topic: https://groups.io/mt/89555131/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH 4/4] NetworkPkg/HttpDxe: Detect non-HTTP/1.1 servers
Posted by Gerd Hoffmann 3 years, 11 months ago
On Fri, Mar 04, 2022 at 02:34:31PM +0100, Oliver Steffen wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2720
> 
> Force connecton close before the next request if
> the server does not identify as version 1.1.
> 
> Signed-off-by: Oliver Steffen <osteffen@redhat.com>
> ---
>  NetworkPkg/HttpDxe/HttpImpl.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
> index a1a3eea585..ea1ab60517 100644
> --- a/NetworkPkg/HttpDxe/HttpImpl.c
> +++ b/NetworkPkg/HttpDxe/HttpImpl.c
> @@ -1105,6 +1105,14 @@ HttpResponseWorker (
>        HttpInstance->CacheLen = BodyLen;
> 
>      }
> 
>  
> 
> +    //
> 
> +    // Check server's HTTP version.
> 
> +    //
> 
> +    if (AsciiStrnCmp (HttpHeaders, HTTP_VERSION, AsciiStrLen (HTTP_VERSION)) != 0) {

Better explicitly check for 1.0 here?  That is the special case we are
looking for here: http/1.0 has no pipelining, so we close the connection
in that case.

As long as edk2 has no support for http/2.0 it doesn't make a difference
in practice though.

> +      DEBUG ((DEBUG_WARN, "HTTP: Server version is not 1.1. Setting Connection close.\n"));

Same here, should better use DEBUG_VERBOSE.

take care,
  Gerd



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