]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Remove the hostname from the http request URL.
authorGary Ching-Pang Lin <glin@suse.com>
Sat, 22 Aug 2015 12:35:19 +0000 (12:35 +0000)
committersfu5 <sfu5@Edk2>
Sat, 22 Aug 2015 12:35:19 +0000 (12:35 +0000)
Per RFC7230, the URL must be a absolute-path when making a request directly to
the server. Since proxy is not supported now, all requests to the HTTP driver
are actually direct requests. This commit removes the scheme and the hostname
from the URL in the http request if the URL is an absolute-URI so that the HTTP
server can interpret the request properly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Gary Ching-Pang Lin <glin@suse.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18257 6f19259b-4bc3-4df7-8a09-765794883524

NetworkPkg/HttpDxe/HttpImpl.c

index 545fe42332da3ff7cec00b0a57d49221d9683c4f..80e819201ec1b667dbf78d325b380b56df2763b1 100644 (file)
@@ -227,7 +227,8 @@ EfiHttpRequest (
   CHAR16                        *HostNameStr;\r
   HTTP_TOKEN_WRAP               *Wrap;\r
   HTTP_TCP_TOKEN_WRAP           *TcpWrap;\r
-\r
+  CHAR8                         *FileUrl;\r
+  \r
   if ((This == NULL) || (Token == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
@@ -450,7 +451,25 @@ EfiHttpRequest (
   //\r
   // Create request message.\r
   //\r
-  RequestStr = HttpGenRequestString (HttpInstance, HttpMsg, Url);\r
+  FileUrl = Url;\r
+  if (*FileUrl != '/') {\r
+    //\r
+    // Convert the absolute-URI to the absolute-path\r
+    //\r
+    while (*FileUrl != ':') {\r
+      FileUrl++;\r
+    }\r
+    if ((*(FileUrl+1) == '/') && (*(FileUrl+2) == '/')) {\r
+      FileUrl += 3;\r
+      while (*FileUrl != '/') {\r
+        FileUrl++;\r
+      }\r
+    } else {\r
+      Status = EFI_INVALID_PARAMETER;\r
+      goto Error3;\r
+    }\r
+  }\r
+  RequestStr = HttpGenRequestString (HttpInstance, HttpMsg, FileUrl);\r
   if (RequestStr == NULL) {\r
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Error3;\r