summaryrefslogtreecommitdiff
path: root/NetworkPkg
diff options
context:
space:
mode:
authorGary Ching-Pang Lin <glin@suse.com>2015-08-22 12:35:19 +0000
committersfu5 <sfu5@Edk2>2015-08-22 12:35:19 +0000
commitb199d9418820b873d0e05190fe5dc947a6f72b14 (patch)
treef06ca7438141d84e4a4b9ca71a07b44e83fc0383 /NetworkPkg
parent072418e553507a7e80e1b94acc3ebcd7b96a9446 (diff)
downloadedk2-platforms-b199d9418820b873d0e05190fe5dc947a6f72b14.tar.xz
NetworkPkg: Remove the hostname from the http request URL.
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
Diffstat (limited to 'NetworkPkg')
-rw-r--r--NetworkPkg/HttpDxe/HttpImpl.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 545fe42332..80e819201e 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -227,7 +227,8 @@ 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,25 @@ EfiHttpRequest (
//
// Create request message.
//
- RequestStr = HttpGenRequestString (HttpInstance, HttpMsg, Url);
+ FileUrl = Url;
+ if (*FileUrl != '/') {
+ //
+ // Convert the absolute-URI to the absolute-path
+ //
+ 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;