Hi, Gray

The URI in the request line could be either an absolute URI or an abs path, 
both are allowed according to RFC2616 section 5.1.2, so we let the caller of 
EFI_HTTP_PROTOCOL to decide what kind of the URI they want to use, and not 
modify it. In your patch you assume the input RequestData->Url is always an abs 
path so I think it's not a correct fix.

Quote from RFC2616:

        Request-URI    = "*" | absoluteURI | abs_path | authority

example would be
        OPTIONS * HTTP/1.1
Or
        GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1
Or
        GET /pub/WWW/TheProject.html HTTP/1.1

Siyuan

-----Original Message-----
From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Gary 
Ching-Pang Lin
Sent: Monday, August 17, 2015 4:21 PM
To: edk2-devel@lists.01.org
Cc: Justen, Jordan L; Fu, Siyuan; Laszlo Ersek
Subject: [edk2] [PATCH v2 1/2] NetworkPkg: Remove the hostname from the http 
request url

The hostname is already set in the header of the http request.
The url shouldn't contain the hostname since the hostname will be prepended to 
the url when the server interprets the request.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Gary Ching-Pang Lin <g...@suse.com>
Reviewed-by: Ye Ting <ting...@intel.com>
---
 NetworkPkg/HttpDxe/HttpImpl.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c 
index 545fe42..030dcfe 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -227,6 +227,7 @@ EfiHttpRequest (
   CHAR16                        *HostNameStr;
   HTTP_TOKEN_WRAP               *Wrap;
   HTTP_TCP_TOKEN_WRAP           *TcpWrap;
+  CHAR8                         *FileUrl;
 
   if ((This == NULL) || (Token == NULL)) {
     return EFI_INVALID_PARAMETER;
@@ -450,7 +451,18 @@ EfiHttpRequest (
   //
   // Create request message.
   //
-  RequestStr = HttpGenRequestString (HttpInstance, HttpMsg, Url);
+  FileUrl = Url;
+  while (*FileUrl != ':')
+    FileUrl++;
+  if ((*(FileUrl+1) == '/') && (*(FileUrl+2) == '/')) {
+    FileUrl += 3;
+    while (*FileUrl != '/')
+      FileUrl++;
+  } else {
+    Status = EFI_INVALID_PARAMETER;
+    goto Error3;
+  }
+  RequestStr = HttpGenRequestString (HttpInstance, HttpMsg, FileUrl);
   if (RequestStr == NULL) {
     Status = EFI_OUT_OF_RESOURCES;
     goto Error3;
--
2.1.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to