X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=NetworkPkg%2FHttpDxe%2FHttpImpl.c;h=0fa437dc327d977767987926fc26519fdd6e7a72;hb=8fb0d2e3fd488a045899dc2b890fc57b8d793e0b;hp=c527da08723ece2c4878f64c357ef20e4462998d;hpb=b659408b933f40765960e877de3e1f8ceaab52cb;p=mirror_edk2.git diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c index c527da0872..0fa437dc32 100644 --- a/NetworkPkg/HttpDxe/HttpImpl.c +++ b/NetworkPkg/HttpDxe/HttpImpl.c @@ -40,6 +40,7 @@ EFI_HTTP_PROTOCOL mEfiHttpTemplate = { This is NULL. HttpConfigData is NULL. HttpConfigData->AccessPoint is NULL. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources. @retval EFI_NOT_STARTED The HTTP instance is not configured. **/ @@ -71,6 +72,9 @@ EfiHttpGetModeData ( if (HttpInstance->LocalAddressIsIPv6) { Http6AccessPoint = AllocateZeroPool (sizeof (EFI_HTTPv6_ACCESS_POINT)); + if (Http6AccessPoint == NULL) { + return EFI_OUT_OF_RESOURCES; + } CopyMem ( Http6AccessPoint, &HttpInstance->Ipv6Node, @@ -79,6 +83,9 @@ EfiHttpGetModeData ( HttpConfigData->AccessPoint.IPv6Node = Http6AccessPoint; } else { Http4AccessPoint = AllocateZeroPool (sizeof (EFI_HTTPv4_ACCESS_POINT)); + if (Http4AccessPoint == NULL) { + return EFI_OUT_OF_RESOURCES; + } CopyMem ( Http4AccessPoint, &HttpInstance->IPv4Node, @@ -317,7 +324,11 @@ EfiHttpRequest ( if (EFI_ERROR (Status)) { RemotePort = HTTP_DEFAULT_PORT; } - + // + // If Configure is TRUE, it indicates the first time to call Request(); + // If ReConfigure is TRUE, it indicates the request URL is not same + // with the previous call to Request(); + // Configure = TRUE; ReConfigure = TRUE; @@ -390,7 +401,7 @@ EfiHttpRequest ( if (!HttpInstance->LocalAddressIsIPv6) { Status = NetLibAsciiStrToIp4 (HostName, &HttpInstance->RemoteAddr); } else { - Status = NetLibAsciiStrToIp6 (HostName, &HttpInstance->RemoteIpv6Addr); + Status = HttpUrlGetIp6 (Url, UrlParser, &HttpInstance->RemoteIpv6Addr); } if (EFI_ERROR (Status)) { @@ -427,7 +438,11 @@ EfiHttpRequest ( // // The request URL is different from previous calls to Request(), close existing TCP instance. // - ASSERT (HttpInstance->Tcp4 != NULL &&HttpInstance->Tcp6 != NULL); + if (!HttpInstance->LocalAddressIsIPv6) { + ASSERT (HttpInstance->Tcp4 != NULL); + } else { + ASSERT (HttpInstance->Tcp6 != NULL); + } HttpCloseConnection (HttpInstance); EfiHttpCancel (This, NULL); } @@ -445,13 +460,12 @@ EfiHttpRequest ( Wrap->HttpInstance = HttpInstance; Wrap->TcpWrap.Method = Request->Method; - if (Configure) { - Status = HttpInitTcp (HttpInstance, Wrap); - if (EFI_ERROR (Status)) { - goto Error2; - } + Status = HttpInitTcp (HttpInstance, Wrap, Configure); + if (EFI_ERROR (Status)) { + goto Error2; + } - } else { + if (!Configure) { // // For the new HTTP token, create TX TCP token events. // @@ -460,7 +474,7 @@ EfiHttpRequest ( goto Error1; } } - + // // Create request message. // @@ -878,6 +892,8 @@ HttpResponseWorker ( goto Error; } + ASSERT (HttpHeaders != NULL); + // // Cache the part of body. // @@ -1280,14 +1296,19 @@ EfiHttpPoll ( HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This); ASSERT (HttpInstance != NULL); - if (HttpInstance->State != HTTP_STATE_TCP_CONNECTED || (HttpInstance->Tcp4 == NULL && - HttpInstance->Tcp6 == NULL)) { + if (HttpInstance->State != HTTP_STATE_TCP_CONNECTED) { return EFI_NOT_STARTED; } if (HttpInstance->LocalAddressIsIPv6) { + if (HttpInstance->Tcp6 == NULL) { + return EFI_NOT_STARTED; + } Status = HttpInstance->Tcp6->Poll (HttpInstance->Tcp6); } else { + if (HttpInstance->Tcp4 == NULL) { + return EFI_NOT_STARTED; + } Status = HttpInstance->Tcp4->Poll (HttpInstance->Tcp4); }