2 Implementation of EFI_HTTP_PROTOCOL protocol interfaces.
4 Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>
5 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include "HttpDriver.h"
19 EFI_HTTP_PROTOCOL mEfiHttpTemplate
= {
29 Returns the operational parameters for the current HTTP child instance.
31 The GetModeData() function is used to read the current mode data (operational
32 parameters) for this HTTP protocol instance.
34 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
35 @param[out] HttpConfigData Point to buffer for operational parameters of this
38 @retval EFI_SUCCESS Operation succeeded.
39 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
41 HttpConfigData is NULL.
42 HttpInstance->LocalAddressIsIPv6 is FALSE and
43 HttpConfigData->IPv4Node is NULL.
44 HttpInstance->LocalAddressIsIPv6 is TRUE and
45 HttpConfigData->IPv6Node is NULL.
46 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
52 IN EFI_HTTP_PROTOCOL
*This
,
53 OUT EFI_HTTP_CONFIG_DATA
*HttpConfigData
56 HTTP_PROTOCOL
*HttpInstance
;
59 // Check input parameters.
61 if ((This
== NULL
) || (HttpConfigData
== NULL
)) {
62 return EFI_INVALID_PARAMETER
;
65 HttpInstance
= HTTP_INSTANCE_FROM_PROTOCOL (This
);
66 ASSERT (HttpInstance
!= NULL
);
68 if ((HttpInstance
->LocalAddressIsIPv6
&& HttpConfigData
->AccessPoint
.IPv6Node
== NULL
) ||
69 (!HttpInstance
->LocalAddressIsIPv6
&& HttpConfigData
->AccessPoint
.IPv4Node
== NULL
)) {
70 return EFI_INVALID_PARAMETER
;
73 if (HttpInstance
->State
< HTTP_STATE_HTTP_CONFIGED
) {
74 return EFI_NOT_STARTED
;
77 HttpConfigData
->HttpVersion
= HttpInstance
->HttpVersion
;
78 HttpConfigData
->TimeOutMillisec
= HttpInstance
->TimeOutMillisec
;
79 HttpConfigData
->LocalAddressIsIPv6
= HttpInstance
->LocalAddressIsIPv6
;
81 if (HttpInstance
->LocalAddressIsIPv6
) {
83 HttpConfigData
->AccessPoint
.IPv6Node
,
84 &HttpInstance
->Ipv6Node
,
85 sizeof (HttpInstance
->Ipv6Node
)
89 HttpConfigData
->AccessPoint
.IPv4Node
,
90 &HttpInstance
->IPv4Node
,
91 sizeof (HttpInstance
->IPv4Node
)
99 Initialize or brutally reset the operational parameters for this EFI HTTP instance.
101 The Configure() function does the following:
102 When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring
103 timeout, local address, port, etc.
104 When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active
105 connections with remote hosts, canceling all asynchronous tokens, and flush request
106 and response buffers without informing the appropriate hosts.
108 No other EFI HTTP function can be executed by this instance until the Configure()
109 function is executed and returns successfully.
111 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
112 @param[in] HttpConfigData Pointer to the configure data to configure the instance.
114 @retval EFI_SUCCESS Operation succeeded.
115 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
117 HttpConfigData->LocalAddressIsIPv6 is FALSE and
118 HttpConfigData->IPv4Node is NULL.
119 HttpConfigData->LocalAddressIsIPv6 is TRUE and
120 HttpConfigData->IPv6Node is NULL.
121 @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling
122 Configure() with NULL to reset it.
123 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
124 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
125 executing Configure().
126 @retval EFI_UNSUPPORTED One or more options in HttpConfigData are not supported
127 in the implementation.
132 IN EFI_HTTP_PROTOCOL
*This
,
133 IN EFI_HTTP_CONFIG_DATA
*HttpConfigData
136 HTTP_PROTOCOL
*HttpInstance
;
140 // Check input parameters.
143 (HttpConfigData
!= NULL
&&
144 ((HttpConfigData
->LocalAddressIsIPv6
&& HttpConfigData
->AccessPoint
.IPv6Node
== NULL
) ||
145 (!HttpConfigData
->LocalAddressIsIPv6
&& HttpConfigData
->AccessPoint
.IPv4Node
== NULL
)))) {
146 return EFI_INVALID_PARAMETER
;
149 HttpInstance
= HTTP_INSTANCE_FROM_PROTOCOL (This
);
150 ASSERT (HttpInstance
!= NULL
&& HttpInstance
->Service
!= NULL
);
152 if (HttpConfigData
!= NULL
) {
155 // Now configure this HTTP instance.
157 if (HttpInstance
->State
!= HTTP_STATE_UNCONFIGED
) {
158 return EFI_ALREADY_STARTED
;
161 HttpInstance
->HttpVersion
= HttpConfigData
->HttpVersion
;
162 HttpInstance
->TimeOutMillisec
= HttpConfigData
->TimeOutMillisec
;
163 HttpInstance
->LocalAddressIsIPv6
= HttpConfigData
->LocalAddressIsIPv6
;
165 if (HttpConfigData
->LocalAddressIsIPv6
) {
167 &HttpInstance
->Ipv6Node
,
168 HttpConfigData
->AccessPoint
.IPv6Node
,
169 sizeof (HttpInstance
->Ipv6Node
)
173 &HttpInstance
->IPv4Node
,
174 HttpConfigData
->AccessPoint
.IPv4Node
,
175 sizeof (HttpInstance
->IPv4Node
)
182 Status
= HttpInitProtocol (HttpInstance
, HttpInstance
->LocalAddressIsIPv6
);
183 if (EFI_ERROR (Status
)) {
187 HttpInstance
->State
= HTTP_STATE_HTTP_CONFIGED
;
192 // Reset all the resources related to HttpInsance.
194 HttpCleanProtocol (HttpInstance
);
195 HttpInstance
->State
= HTTP_STATE_UNCONFIGED
;
202 The Request() function queues an HTTP request to this HTTP instance.
204 Similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent
205 successfully, or if there is an error, Status in token will be updated and Event will
208 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
209 @param[in] Token Pointer to storage containing HTTP request token.
211 @retval EFI_SUCCESS Outgoing data was processed.
212 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
213 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
214 @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.
215 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
216 @retval EFI_UNSUPPORTED The HTTP method is not supported in current
218 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
221 Token->Message is NULL.
222 Token->Message->Body is not NULL,
223 Token->Message->BodyLength is non-zero, and
224 Token->Message->Data is NULL, but a previous call to
225 Request()has not been completed successfully.
230 IN EFI_HTTP_PROTOCOL
*This
,
231 IN EFI_HTTP_TOKEN
*Token
234 EFI_HTTP_MESSAGE
*HttpMsg
;
235 EFI_HTTP_REQUEST_DATA
*Request
;
241 HTTP_PROTOCOL
*HttpInstance
;
244 BOOLEAN TlsConfigure
;
249 HTTP_TOKEN_WRAP
*Wrap
;
251 UINTN RequestMsgSize
;
264 TlsConfigure
= FALSE
;
266 if ((This
== NULL
) || (Token
== NULL
)) {
267 return EFI_INVALID_PARAMETER
;
270 HttpMsg
= Token
->Message
;
271 if (HttpMsg
== NULL
) {
272 return EFI_INVALID_PARAMETER
;
275 Request
= HttpMsg
->Data
.Request
;
278 // Only support GET, HEAD, PUT and POST method in current implementation.
280 if ((Request
!= NULL
) && (Request
->Method
!= HttpMethodGet
) &&
281 (Request
->Method
!= HttpMethodHead
) && (Request
->Method
!= HttpMethodPut
) && (Request
->Method
!= HttpMethodPost
)) {
282 return EFI_UNSUPPORTED
;
285 HttpInstance
= HTTP_INSTANCE_FROM_PROTOCOL (This
);
286 ASSERT (HttpInstance
!= NULL
);
289 // Capture the method into HttpInstance.
291 if (Request
!= NULL
) {
292 HttpInstance
->Method
= Request
->Method
;
295 if (HttpInstance
->State
< HTTP_STATE_HTTP_CONFIGED
) {
296 return EFI_NOT_STARTED
;
299 if (Request
== NULL
) {
301 // Request would be NULL only for PUT/POST operation (in the current implementation)
303 if ((HttpInstance
->Method
!= HttpMethodPut
) && (HttpInstance
->Method
!= HttpMethodPost
)) {
304 return EFI_INVALID_PARAMETER
;
308 // For PUT/POST, we need to have the TCP already configured. Bail out if it is not!
310 if (HttpInstance
->State
< HTTP_STATE_TCP_CONFIGED
) {
311 return EFI_INVALID_PARAMETER
;
315 // We need to have the Message Body for sending the HTTP message across in these cases.
317 if (HttpMsg
->Body
== NULL
|| HttpMsg
->BodyLength
== 0) {
318 return EFI_INVALID_PARAMETER
;
322 // Use existing TCP instance to transmit the packet.
328 // Check whether the token already existed.
330 if (EFI_ERROR (NetMapIterate (&HttpInstance
->TxTokens
, HttpTokenExist
, Token
))) {
331 return EFI_ACCESS_DENIED
;
335 // Parse the URI of the remote host.
337 Url
= HttpInstance
->Url
;
338 UrlLen
= StrLen (Request
->Url
) + 1;
339 if (UrlLen
> HTTP_URL_BUFFER_LEN
) {
340 Url
= AllocateZeroPool (UrlLen
);
342 return EFI_OUT_OF_RESOURCES
;
344 FreePool (HttpInstance
->Url
);
345 HttpInstance
->Url
= Url
;
349 UnicodeStrToAsciiStrS (Request
->Url
, Url
, UrlLen
);
352 // From the information in Url, the HTTP instance will
353 // be able to determine whether to use http or https.
355 HttpInstance
->UseHttps
= IsHttpsUrl (Url
);
358 // HTTP is disabled, return directly if the URI is not HTTPS.
360 if (!PcdGetBool (PcdAllowHttpConnections
) && !(HttpInstance
->UseHttps
)) {
362 DEBUG ((EFI_D_ERROR
, "EfiHttpRequest: HTTP is disabled.\n"));
364 return EFI_ACCESS_DENIED
;
368 // Check whether we need to create Tls child and open the TLS protocol.
370 if (HttpInstance
->UseHttps
&& HttpInstance
->TlsChildHandle
== NULL
) {
372 // Use TlsSb to create Tls child and open the TLS protocol.
374 HttpInstance
->TlsChildHandle
= TlsCreateChild (
375 HttpInstance
->Service
->ImageHandle
,
376 &(HttpInstance
->Tls
),
377 &(HttpInstance
->TlsConfiguration
)
379 if (HttpInstance
->TlsChildHandle
== NULL
) {
380 return EFI_DEVICE_ERROR
;
387 Status
= HttpParseUrl (Url
, (UINT32
) AsciiStrLen (Url
), FALSE
, &UrlParser
);
388 if (EFI_ERROR (Status
)) {
393 Status
= HttpUrlGetHostName (Url
, UrlParser
, &HostName
);
394 if (EFI_ERROR (Status
)) {
398 Status
= HttpUrlGetPort (Url
, UrlParser
, &RemotePort
);
399 if (EFI_ERROR (Status
)) {
400 if (HttpInstance
->UseHttps
) {
401 RemotePort
= HTTPS_DEFAULT_PORT
;
403 RemotePort
= HTTP_DEFAULT_PORT
;
407 // If Configure is TRUE, it indicates the first time to call Request();
408 // If ReConfigure is TRUE, it indicates the request URL is not same
409 // with the previous call to Request();
414 if (HttpInstance
->RemoteHost
== NULL
) {
416 // Request() is called the first time.
420 if ((HttpInstance
->RemotePort
== RemotePort
) &&
421 (AsciiStrCmp (HttpInstance
->RemoteHost
, HostName
) == 0) &&
422 (!HttpInstance
->UseHttps
|| (HttpInstance
->UseHttps
&&
424 HttpInstance
->TlsSessionState
== EfiTlsSessionDataTransferring
))) {
426 // Host Name and port number of the request URL are the same with previous call to Request().
427 // If Https protocol used, the corresponding SessionState is EfiTlsSessionDataTransferring.
428 // Check whether previous TCP packet sent out.
431 if (EFI_ERROR (NetMapIterate (&HttpInstance
->TxTokens
, HttpTcpNotReady
, NULL
))) {
433 // Wrap the HTTP token in HTTP_TOKEN_WRAP
435 Wrap
= AllocateZeroPool (sizeof (HTTP_TOKEN_WRAP
));
437 Status
= EFI_OUT_OF_RESOURCES
;
441 Wrap
->HttpToken
= Token
;
442 Wrap
->HttpInstance
= HttpInstance
;
444 Status
= HttpCreateTcpTxEvent (Wrap
);
445 if (EFI_ERROR (Status
)) {
449 Status
= NetMapInsertTail (&HttpInstance
->TxTokens
, Token
, Wrap
);
450 if (EFI_ERROR (Status
)) {
454 Wrap
->TcpWrap
.Method
= Request
->Method
;
459 // Queue the HTTP token and return.
464 // Use existing TCP instance to transmit the packet.
471 // Need close existing TCP instance and create a new TCP instance for data transmit.
473 if (HttpInstance
->RemoteHost
!= NULL
) {
474 FreePool (HttpInstance
->RemoteHost
);
475 HttpInstance
->RemoteHost
= NULL
;
476 HttpInstance
->RemotePort
= 0;
484 // Parse Url for IPv4 or IPv6 address, if failed, perform DNS resolution.
486 if (!HttpInstance
->LocalAddressIsIPv6
) {
487 Status
= NetLibAsciiStrToIp4 (HostName
, &HttpInstance
->RemoteAddr
);
489 Status
= HttpUrlGetIp6 (Url
, UrlParser
, &HttpInstance
->RemoteIpv6Addr
);
492 if (EFI_ERROR (Status
)) {
493 HostNameSize
= AsciiStrSize (HostName
);
494 HostNameStr
= AllocateZeroPool (HostNameSize
* sizeof (CHAR16
));
495 if (HostNameStr
== NULL
) {
496 Status
= EFI_OUT_OF_RESOURCES
;
500 AsciiStrToUnicodeStrS (HostName
, HostNameStr
, HostNameSize
);
501 if (!HttpInstance
->LocalAddressIsIPv6
) {
502 Status
= HttpDns4 (HttpInstance
, HostNameStr
, &HttpInstance
->RemoteAddr
);
504 Status
= HttpDns6 (HttpInstance
, HostNameStr
, &HttpInstance
->RemoteIpv6Addr
);
507 FreePool (HostNameStr
);
508 if (EFI_ERROR (Status
)) {
514 // Save the RemotePort and RemoteHost.
516 ASSERT (HttpInstance
->RemoteHost
== NULL
);
517 HttpInstance
->RemotePort
= RemotePort
;
518 HttpInstance
->RemoteHost
= HostName
;
524 // The request URL is different from previous calls to Request(), close existing TCP instance.
526 if (!HttpInstance
->LocalAddressIsIPv6
) {
527 ASSERT (HttpInstance
->Tcp4
!= NULL
);
529 ASSERT (HttpInstance
->Tcp6
!= NULL
);
532 if (HttpInstance
->UseHttps
&& !TlsConfigure
) {
533 Status
= TlsCloseSession (HttpInstance
);
534 if (EFI_ERROR (Status
)) {
538 TlsCloseTxRxEvent (HttpInstance
);
541 HttpCloseConnection (HttpInstance
);
542 EfiHttpCancel (This
, NULL
);
546 // Wrap the HTTP token in HTTP_TOKEN_WRAP
548 Wrap
= AllocateZeroPool (sizeof (HTTP_TOKEN_WRAP
));
550 Status
= EFI_OUT_OF_RESOURCES
;
554 Wrap
->HttpToken
= Token
;
555 Wrap
->HttpInstance
= HttpInstance
;
556 if (Request
!= NULL
) {
557 Wrap
->TcpWrap
.Method
= Request
->Method
;
560 Status
= HttpInitSession (
563 Configure
|| ReConfigure
,
566 if (EFI_ERROR (Status
)) {
570 if (!Configure
&& !ReConfigure
&& !TlsConfigure
) {
572 // For the new HTTP token, create TX TCP token events.
574 Status
= HttpCreateTcpTxEvent (Wrap
);
575 if (EFI_ERROR (Status
)) {
581 // Create request message.
584 if (Url
!= NULL
&& *FileUrl
!= '/') {
586 // Convert the absolute-URI to the absolute-path
588 while (*FileUrl
!= ':') {
591 if ((*(FileUrl
+1) == '/') && (*(FileUrl
+2) == '/')) {
593 while (*FileUrl
!= '/') {
597 Status
= EFI_INVALID_PARAMETER
;
602 Status
= HttpGenRequestMessage (HttpMsg
, FileUrl
, &RequestMsg
, &RequestMsgSize
);
604 if (EFI_ERROR (Status
) || NULL
== RequestMsg
) {
608 ASSERT (RequestMsg
!= NULL
);
611 // Every request we insert a TxToken and a response call would remove the TxToken.
612 // In cases of PUT/POST, after an initial request-response pair, we would do a
613 // continuous request without a response call. So, in such cases, where Request
614 // structure is NULL, we would not insert a TxToken.
616 if (Request
!= NULL
) {
617 Status
= NetMapInsertTail (&HttpInstance
->TxTokens
, Token
, Wrap
);
618 if (EFI_ERROR (Status
)) {
624 // Transmit the request message.
626 Status
= HttpTransmitTcp (
632 if (EFI_ERROR (Status
)) {
638 if (HostName
!= NULL
) {
646 // We would have inserted a TxToken only if Request structure is not NULL.
647 // Hence check before we do a remove in this error case.
649 if (Request
!= NULL
) {
650 NetMapRemoveTail (&HttpInstance
->TxTokens
, NULL
);
654 if (RequestMsg
!= NULL
) {
655 FreePool (RequestMsg
);
659 if (HttpInstance
->UseHttps
) {
660 TlsCloseSession (HttpInstance
);
661 TlsCloseTxRxEvent (HttpInstance
);
665 HttpCloseConnection (HttpInstance
);
667 HttpCloseTcpConnCloseEvent (HttpInstance
);
668 if (NULL
!= Wrap
->TcpWrap
.Tx4Token
.CompletionToken
.Event
) {
669 gBS
->CloseEvent (Wrap
->TcpWrap
.Tx4Token
.CompletionToken
.Event
);
670 Wrap
->TcpWrap
.Tx4Token
.CompletionToken
.Event
= NULL
;
672 if (NULL
!= Wrap
->TcpWrap
.Tx6Token
.CompletionToken
.Event
) {
673 gBS
->CloseEvent (Wrap
->TcpWrap
.Tx6Token
.CompletionToken
.Event
);
674 Wrap
->TcpWrap
.Tx6Token
.CompletionToken
.Event
= NULL
;
678 if (HostName
!= NULL
) {
684 if (UrlParser
!= NULL
) {
685 HttpUrlFreeParser (UrlParser
);
693 Cancel a user's Token.
695 @param[in] Map The HTTP instance's token queue.
696 @param[in] Item Object container for one HTTP token and token's wrap.
697 @param[in] Context The user's token to cancel.
699 @retval EFI_SUCCESS Continue to check the next Item.
700 @retval EFI_ABORTED The user's Token (Token != NULL) is cancelled.
707 IN NET_MAP_ITEM
*Item
,
711 EFI_HTTP_TOKEN
*Token
;
712 HTTP_TOKEN_WRAP
*Wrap
;
713 HTTP_PROTOCOL
*HttpInstance
;
715 Token
= (EFI_HTTP_TOKEN
*) Context
;
718 // Return EFI_SUCCESS to check the next item in the map if
719 // this one doesn't match.
721 if ((Token
!= NULL
) && (Token
!= Item
->Key
)) {
725 Wrap
= (HTTP_TOKEN_WRAP
*) Item
->Value
;
726 ASSERT (Wrap
!= NULL
);
727 HttpInstance
= Wrap
->HttpInstance
;
729 if (!HttpInstance
->LocalAddressIsIPv6
) {
730 if (Wrap
->TcpWrap
.Rx4Token
.CompletionToken
.Event
!= NULL
) {
732 // Cancle the Token before close its Event.
734 HttpInstance
->Tcp4
->Cancel (HttpInstance
->Tcp4
, &Wrap
->TcpWrap
.Rx4Token
.CompletionToken
);
737 // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.
742 if (Wrap
->TcpWrap
.Rx6Token
.CompletionToken
.Event
!= NULL
) {
744 // Cancle the Token before close its Event.
746 HttpInstance
->Tcp6
->Cancel (HttpInstance
->Tcp6
, &Wrap
->TcpWrap
.Rx6Token
.CompletionToken
);
749 // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.
756 // If only one item is to be cancel, return EFI_ABORTED to stop
757 // iterating the map any more.
767 Cancel the user's receive/transmit request. It is the worker function of
768 EfiHttpCancel API. If a matching token is found, it will call HttpCancelTokens to cancel the
771 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
772 @param[in] Token The token to cancel. If NULL, all token will be
775 @retval EFI_SUCCESS The token is cancelled.
776 @retval EFI_NOT_FOUND The asynchronous request or response token is not found.
777 @retval Others Other error as indicated.
782 IN HTTP_PROTOCOL
*HttpInstance
,
783 IN EFI_HTTP_TOKEN
*Token
789 // First check the tokens queued by EfiHttpRequest().
791 Status
= NetMapIterate (&HttpInstance
->TxTokens
, HttpCancelTokens
, Token
);
792 if (EFI_ERROR (Status
)) {
794 if (Status
== EFI_ABORTED
) {
802 if (!HttpInstance
->UseHttps
) {
804 // Then check the tokens queued by EfiHttpResponse(), except for Https.
806 Status
= NetMapIterate (&HttpInstance
->RxTokens
, HttpCancelTokens
, Token
);
807 if (EFI_ERROR (Status
)) {
809 if (Status
== EFI_ABORTED
) {
812 return EFI_NOT_FOUND
;
819 if (!HttpInstance
->LocalAddressIsIPv6
) {
820 HttpInstance
->Tcp4
->Cancel (HttpInstance
->Tcp4
, &HttpInstance
->Tcp4TlsRxToken
.CompletionToken
);
822 HttpInstance
->Tcp6
->Cancel (HttpInstance
->Tcp6
, &HttpInstance
->Tcp6TlsRxToken
.CompletionToken
);
831 Abort an asynchronous HTTP request or response token.
833 The Cancel() function aborts a pending HTTP request or response transaction. If
834 Token is not NULL and the token is in transmit or receive queues when it is being
835 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will
836 be signaled. If the token is not in one of the queues, which usually means that the
837 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,
838 all asynchronous tokens issued by Request() or Response() will be aborted.
840 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
841 @param[in] Token Point to storage containing HTTP request or response
844 @retval EFI_SUCCESS Request and Response queues are successfully flushed.
845 @retval EFI_INVALID_PARAMETER This is NULL.
846 @retval EFI_NOT_STARTED This instance hasn't been configured.
847 @retval EFI_NOT_FOUND The asynchronous request or response token is not
849 @retval EFI_UNSUPPORTED The implementation does not support this function.
855 IN EFI_HTTP_PROTOCOL
*This
,
856 IN EFI_HTTP_TOKEN
*Token
859 HTTP_PROTOCOL
*HttpInstance
;
862 return EFI_INVALID_PARAMETER
;
865 HttpInstance
= HTTP_INSTANCE_FROM_PROTOCOL (This
);
866 ASSERT (HttpInstance
!= NULL
);
868 if (HttpInstance
->State
!= HTTP_STATE_TCP_CONNECTED
) {
869 return EFI_NOT_STARTED
;
872 return HttpCancel (HttpInstance
, Token
);
877 A callback function to intercept events during message parser.
879 This function will be invoked during HttpParseMessageBody() with various events type. An error
880 return status of the callback function will cause the HttpParseMessageBody() aborted.
882 @param[in] EventType Event type of this callback call.
883 @param[in] Data A pointer to data buffer.
884 @param[in] Length Length in bytes of the Data.
885 @param[in] Context Callback context set by HttpInitMsgParser().
887 @retval EFI_SUCCESS Continue to parser the message body.
892 HttpBodyParserCallback (
893 IN HTTP_BODY_PARSE_EVENT EventType
,
899 HTTP_TOKEN_WRAP
*Wrap
;
903 if (EventType
!= BodyParseEventOnComplete
) {
907 if (Data
== NULL
|| Length
!= 0 || Context
== NULL
) {
911 Wrap
= (HTTP_TOKEN_WRAP
*) Context
;
912 Body
= Wrap
->HttpToken
->Message
->Body
;
913 BodyLength
= Wrap
->HttpToken
->Message
->BodyLength
;
914 if (Data
< Body
+ BodyLength
) {
915 Wrap
->HttpInstance
->NextMsg
= Data
;
917 Wrap
->HttpInstance
->NextMsg
= NULL
;
922 // Free Tx4Token or Tx6Token since already received corrsponding HTTP response.
930 The work function of EfiHttpResponse().
932 @param[in] Wrap Pointer to HTTP token's wrap data.
934 @retval EFI_SUCCESS Allocation succeeded.
935 @retval EFI_OUT_OF_RESOURCES Failed to complete the opration due to lack of resources.
936 @retval EFI_NOT_READY Can't find a corresponding Tx4Token/Tx6Token or
937 the EFI_HTTP_UTILITIES_PROTOCOL is not available.
942 IN HTTP_TOKEN_WRAP
*Wrap
946 EFI_HTTP_MESSAGE
*HttpMsg
;
954 CHAR8
*StatusCodeStr
;
956 HTTP_PROTOCOL
*HttpInstance
;
957 EFI_HTTP_TOKEN
*Token
;
959 HTTP_TOKEN_WRAP
*ValueInItem
;
961 NET_FRAGMENT Fragment
;
963 if (Wrap
== NULL
|| Wrap
->HttpInstance
== NULL
) {
964 return EFI_INVALID_PARAMETER
;
967 HttpInstance
= Wrap
->HttpInstance
;
968 Token
= Wrap
->HttpToken
;
969 HttpMsg
= Token
->Message
;
971 HttpInstance
->EndofHeader
= NULL
;
972 HttpInstance
->HttpHeaders
= NULL
;
973 HttpMsg
->Headers
= NULL
;
980 Fragment
.Bulk
= NULL
;
982 if (HttpMsg
->Data
.Response
!= NULL
) {
984 // Check whether we have cached header from previous call.
986 if ((HttpInstance
->CacheBody
!= NULL
) && (HttpInstance
->NextMsg
!= NULL
)) {
988 // The data is stored at [NextMsg, CacheBody + CacheLen].
990 HdrLen
= HttpInstance
->CacheBody
+ HttpInstance
->CacheLen
- HttpInstance
->NextMsg
;
991 HttpHeaders
= AllocateZeroPool (HdrLen
);
992 if (HttpHeaders
== NULL
) {
993 Status
= EFI_OUT_OF_RESOURCES
;
997 CopyMem (HttpHeaders
, HttpInstance
->NextMsg
, HdrLen
);
998 FreePool (HttpInstance
->CacheBody
);
999 HttpInstance
->CacheBody
= NULL
;
1000 HttpInstance
->NextMsg
= NULL
;
1001 HttpInstance
->CacheOffset
= 0;
1002 SizeofHeaders
= HdrLen
;
1003 BufferSize
= HttpInstance
->CacheLen
;
1006 // Check whether we cached the whole HTTP headers.
1008 EndofHeader
= AsciiStrStr (HttpHeaders
, HTTP_END_OF_HDR_STR
);
1011 HttpInstance
->EndofHeader
= &EndofHeader
;
1012 HttpInstance
->HttpHeaders
= &HttpHeaders
;
1015 if (HttpInstance
->TimeoutEvent
== NULL
) {
1017 // Create TimeoutEvent for response
1019 Status
= gBS
->CreateEvent (
1024 &HttpInstance
->TimeoutEvent
1026 if (EFI_ERROR (Status
)) {
1032 // Start the timer, and wait Timeout seconds to receive the header packet.
1034 Status
= gBS
->SetTimer (HttpInstance
->TimeoutEvent
, TimerRelative
, HTTP_RESPONSE_TIMEOUT
* TICKS_PER_SECOND
);
1035 if (EFI_ERROR (Status
)) {
1039 Status
= HttpTcpReceiveHeader (HttpInstance
, &SizeofHeaders
, &BufferSize
, HttpInstance
->TimeoutEvent
);
1041 gBS
->SetTimer (HttpInstance
->TimeoutEvent
, TimerCancel
, 0);
1043 if (EFI_ERROR (Status
)) {
1047 ASSERT (HttpHeaders
!= NULL
);
1050 // Cache the part of body.
1052 BodyLen
= BufferSize
- (EndofHeader
- HttpHeaders
);
1054 if (HttpInstance
->CacheBody
!= NULL
) {
1055 FreePool (HttpInstance
->CacheBody
);
1058 HttpInstance
->CacheBody
= AllocateZeroPool (BodyLen
);
1059 if (HttpInstance
->CacheBody
== NULL
) {
1060 Status
= EFI_OUT_OF_RESOURCES
;
1064 CopyMem (HttpInstance
->CacheBody
, EndofHeader
, BodyLen
);
1065 HttpInstance
->CacheLen
= BodyLen
;
1069 // Search for Status Code.
1071 StatusCodeStr
= HttpHeaders
+ AsciiStrLen (HTTP_VERSION_STR
) + 1;
1072 if (StatusCodeStr
== NULL
) {
1073 Status
= EFI_NOT_READY
;
1077 StatusCode
= AsciiStrDecimalToUintn (StatusCodeStr
);
1080 // Remove the first line of HTTP message, e.g. "HTTP/1.1 200 OK\r\n".
1082 Tmp
= AsciiStrStr (HttpHeaders
, HTTP_CRLF_STR
);
1084 Status
= EFI_NOT_READY
;
1089 // We could have response with just a HTTP message and no headers. For Example,
1090 // "100 Continue". In such cases, we would not want to unnecessarily call a Parse
1091 // method. A "\r\n" following Tmp string again would indicate an end. Compare and
1092 // set SizeofHeaders to 0.
1094 Tmp
= Tmp
+ AsciiStrLen (HTTP_CRLF_STR
);
1095 if (CompareMem (Tmp
, HTTP_CRLF_STR
, AsciiStrLen (HTTP_CRLF_STR
)) == 0) {
1098 SizeofHeaders
= SizeofHeaders
- (Tmp
- HttpHeaders
);
1101 HttpMsg
->Data
.Response
->StatusCode
= HttpMappingToStatusCode (StatusCode
);
1102 HttpInstance
->StatusCode
= StatusCode
;
1104 Status
= EFI_NOT_READY
;
1108 // In cases of PUT/POST, after an initial request-response pair, we would do a
1109 // continuous request without a response call. So, we would not do an insert of
1110 // TxToken. After we have sent the complete file, we will call a response to get
1111 // a final response from server. In such a case, we would not have any TxTokens.
1112 // Hence, check that case before doing a NetMapRemoveHead.
1114 if (!NetMapIsEmpty (&HttpInstance
->TxTokens
)) {
1115 NetMapRemoveHead (&HttpInstance
->TxTokens
, (VOID
**) &ValueInItem
);
1116 if (ValueInItem
== NULL
) {
1121 // The first Tx Token not transmitted yet, insert back and return error.
1123 if (!ValueInItem
->TcpWrap
.IsTxDone
) {
1128 if (SizeofHeaders
!= 0) {
1129 HeaderTmp
= AllocateZeroPool (SizeofHeaders
);
1130 if (HeaderTmp
== NULL
) {
1131 Status
= EFI_OUT_OF_RESOURCES
;
1135 CopyMem (HeaderTmp
, Tmp
, SizeofHeaders
);
1136 FreePool (HttpHeaders
);
1137 HttpHeaders
= HeaderTmp
;
1140 // Check whether the EFI_HTTP_UTILITIES_PROTOCOL is available.
1142 if (mHttpUtilities
== NULL
) {
1143 Status
= EFI_NOT_READY
;
1148 // Parse the HTTP header into array of key/value pairs.
1150 Status
= mHttpUtilities
->Parse (
1155 &HttpMsg
->HeaderCount
1157 if (EFI_ERROR (Status
)) {
1161 FreePool (HttpHeaders
);
1166 // Init message-body parser by header information.
1168 Status
= HttpInitMsgParser (
1169 HttpInstance
->Method
,
1170 HttpMsg
->Data
.Response
->StatusCode
,
1171 HttpMsg
->HeaderCount
,
1173 HttpBodyParserCallback
,
1174 (VOID
*) ValueInItem
,
1175 &HttpInstance
->MsgParser
1177 if (EFI_ERROR (Status
)) {
1182 // Check whether we received a complete HTTP message.
1184 if (HttpInstance
->CacheBody
!= NULL
) {
1185 Status
= HttpParseMessageBody (HttpInstance
->MsgParser
, HttpInstance
->CacheLen
, HttpInstance
->CacheBody
);
1186 if (EFI_ERROR (Status
)) {
1190 if (HttpIsMessageComplete (HttpInstance
->MsgParser
)) {
1192 // Free the MsgParse since we already have a full HTTP message.
1194 HttpFreeMsgParser (HttpInstance
->MsgParser
);
1195 HttpInstance
->MsgParser
= NULL
;
1200 if ((HttpMsg
->Body
== NULL
) || (HttpMsg
->BodyLength
== 0)) {
1201 Status
= EFI_SUCCESS
;
1207 // Receive the response body.
1212 // First check whether we cached some data.
1214 if (HttpInstance
->CacheBody
!= NULL
) {
1216 // Calculate the length of the cached data.
1218 if (HttpInstance
->NextMsg
!= NULL
) {
1220 // We have a cached HTTP message which includes a part of HTTP header of next message.
1222 BodyLen
= HttpInstance
->NextMsg
- (HttpInstance
->CacheBody
+ HttpInstance
->CacheOffset
);
1224 BodyLen
= HttpInstance
->CacheLen
- HttpInstance
->CacheOffset
;
1229 // We have some cached data. Just copy the data and return.
1231 if (HttpMsg
->BodyLength
< BodyLen
) {
1232 CopyMem (HttpMsg
->Body
, HttpInstance
->CacheBody
+ HttpInstance
->CacheOffset
, HttpMsg
->BodyLength
);
1233 HttpInstance
->CacheOffset
= HttpInstance
->CacheOffset
+ HttpMsg
->BodyLength
;
1236 // Copy all cached data out.
1238 CopyMem (HttpMsg
->Body
, HttpInstance
->CacheBody
+ HttpInstance
->CacheOffset
, BodyLen
);
1239 HttpInstance
->CacheOffset
= BodyLen
+ HttpInstance
->CacheOffset
;
1240 HttpMsg
->BodyLength
= BodyLen
;
1242 if (HttpInstance
->NextMsg
== NULL
) {
1244 // There is no HTTP header of next message. Just free the cache buffer.
1246 FreePool (HttpInstance
->CacheBody
);
1247 HttpInstance
->CacheBody
= NULL
;
1248 HttpInstance
->NextMsg
= NULL
;
1249 HttpInstance
->CacheOffset
= 0;
1253 // Return since we aready received required data.
1255 Status
= EFI_SUCCESS
;
1259 if (BodyLen
== 0 && HttpInstance
->MsgParser
== NULL
) {
1261 // We received a complete HTTP message, and we don't have more data to return to caller.
1263 HttpMsg
->BodyLength
= 0;
1264 Status
= EFI_SUCCESS
;
1269 ASSERT (HttpInstance
->MsgParser
!= NULL
);
1272 // We still need receive more data when there is no cache data and MsgParser is not NULL;
1274 if (!HttpInstance
->UseHttps
) {
1275 Status
= HttpTcpReceiveBody (Wrap
, HttpMsg
);
1277 if (EFI_ERROR (Status
)) {
1282 if (HttpInstance
->TimeoutEvent
== NULL
) {
1284 // Create TimeoutEvent for response
1286 Status
= gBS
->CreateEvent (
1291 &HttpInstance
->TimeoutEvent
1293 if (EFI_ERROR (Status
)) {
1299 // Start the timer, and wait Timeout seconds to receive the body packet.
1301 Status
= gBS
->SetTimer (HttpInstance
->TimeoutEvent
, TimerRelative
, HTTP_RESPONSE_TIMEOUT
* TICKS_PER_SECOND
);
1302 if (EFI_ERROR (Status
)) {
1306 Status
= HttpsReceive (HttpInstance
, &Fragment
, HttpInstance
->TimeoutEvent
);
1308 gBS
->SetTimer (HttpInstance
->TimeoutEvent
, TimerCancel
, 0);
1310 if (EFI_ERROR (Status
)) {
1315 // Check whether we receive a complete HTTP message.
1317 Status
= HttpParseMessageBody (
1318 HttpInstance
->MsgParser
,
1319 (UINTN
) Fragment
.Len
,
1320 (CHAR8
*) Fragment
.Bulk
1322 if (EFI_ERROR (Status
)) {
1326 if (HttpIsMessageComplete (HttpInstance
->MsgParser
)) {
1328 // Free the MsgParse since we already have a full HTTP message.
1330 HttpFreeMsgParser (HttpInstance
->MsgParser
);
1331 HttpInstance
->MsgParser
= NULL
;
1335 // We receive part of header of next HTTP msg.
1337 if (HttpInstance
->NextMsg
!= NULL
) {
1338 HttpMsg
->BodyLength
= MIN ((UINTN
) (HttpInstance
->NextMsg
- (CHAR8
*) Fragment
.Bulk
), HttpMsg
->BodyLength
);
1339 CopyMem (HttpMsg
->Body
, Fragment
.Bulk
, HttpMsg
->BodyLength
);
1341 HttpInstance
->CacheLen
= Fragment
.Len
- HttpMsg
->BodyLength
;
1342 if (HttpInstance
->CacheLen
!= 0) {
1343 if (HttpInstance
->CacheBody
!= NULL
) {
1344 FreePool (HttpInstance
->CacheBody
);
1347 HttpInstance
->CacheBody
= AllocateZeroPool (HttpInstance
->CacheLen
);
1348 if (HttpInstance
->CacheBody
== NULL
) {
1349 Status
= EFI_OUT_OF_RESOURCES
;
1353 CopyMem (HttpInstance
->CacheBody
, Fragment
.Bulk
+ HttpMsg
->BodyLength
, HttpInstance
->CacheLen
);
1354 HttpInstance
->CacheOffset
= 0;
1356 HttpInstance
->NextMsg
= HttpInstance
->CacheBody
+ (UINTN
) (HttpInstance
->NextMsg
- (CHAR8
*) (Fragment
.Bulk
+ HttpMsg
->BodyLength
));
1359 HttpMsg
->BodyLength
= MIN (Fragment
.Len
, (UINT32
) HttpMsg
->BodyLength
);
1360 CopyMem (HttpMsg
->Body
, Fragment
.Bulk
, HttpMsg
->BodyLength
);
1361 HttpInstance
->CacheLen
= Fragment
.Len
- HttpMsg
->BodyLength
;
1362 if (HttpInstance
->CacheLen
!= 0) {
1363 if (HttpInstance
->CacheBody
!= NULL
) {
1364 FreePool (HttpInstance
->CacheBody
);
1367 HttpInstance
->CacheBody
= AllocateZeroPool (HttpInstance
->CacheLen
);
1368 if (HttpInstance
->CacheBody
== NULL
) {
1369 Status
= EFI_OUT_OF_RESOURCES
;
1373 CopyMem (HttpInstance
->CacheBody
, Fragment
.Bulk
+ HttpMsg
->BodyLength
, HttpInstance
->CacheLen
);
1374 HttpInstance
->CacheOffset
= 0;
1378 if (Fragment
.Bulk
!= NULL
) {
1379 FreePool (Fragment
.Bulk
);
1380 Fragment
.Bulk
= NULL
;
1389 Item
= NetMapFindKey (&Wrap
->HttpInstance
->RxTokens
, Wrap
->HttpToken
);
1391 NetMapRemoveItem (&Wrap
->HttpInstance
->RxTokens
, Item
, NULL
);
1394 if (HttpInstance
->StatusCode
>= HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE
) {
1395 Token
->Status
= EFI_HTTP_ERROR
;
1397 Token
->Status
= Status
;
1400 gBS
->SignalEvent (Token
->Event
);
1401 HttpCloseTcpRxEvent (Wrap
);
1406 if (ValueInItem
!= NULL
) {
1407 NetMapInsertHead (&HttpInstance
->TxTokens
, ValueInItem
->HttpToken
, ValueInItem
);
1411 Item
= NetMapFindKey (&Wrap
->HttpInstance
->RxTokens
, Wrap
->HttpToken
);
1413 NetMapRemoveItem (&Wrap
->HttpInstance
->RxTokens
, Item
, NULL
);
1416 if (!HttpInstance
->UseHttps
) {
1417 HttpTcpTokenCleanup (Wrap
);
1422 if (HttpHeaders
!= NULL
) {
1423 FreePool (HttpHeaders
);
1427 if (Fragment
.Bulk
!= NULL
) {
1428 FreePool (Fragment
.Bulk
);
1429 Fragment
.Bulk
= NULL
;
1432 if (HttpMsg
->Headers
!= NULL
) {
1433 FreePool (HttpMsg
->Headers
);
1434 HttpMsg
->Headers
= NULL
;
1437 if (HttpInstance
->CacheBody
!= NULL
) {
1438 FreePool (HttpInstance
->CacheBody
);
1439 HttpInstance
->CacheBody
= NULL
;
1442 if (HttpInstance
->StatusCode
>= HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE
) {
1443 Token
->Status
= EFI_HTTP_ERROR
;
1445 Token
->Status
= Status
;
1448 gBS
->SignalEvent (Token
->Event
);
1456 The Response() function queues an HTTP response to this HTTP instance, similar to
1457 Receive() function in the EFI TCP driver. When the HTTP response is received successfully,
1458 or if there is an error, Status in token will be updated and Event will be signaled.
1460 The HTTP driver will queue a receive token to the underlying TCP instance. When data
1461 is received in the underlying TCP instance, the data will be parsed and Token will
1462 be populated with the response data. If the data received from the remote host
1463 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting
1464 (asynchronously) for more data to be sent from the remote host before signaling
1467 It is the responsibility of the caller to allocate a buffer for Body and specify the
1468 size in BodyLength. If the remote host provides a response that contains a content
1469 body, up to BodyLength bytes will be copied from the receive buffer into Body and
1470 BodyLength will be updated with the amount of bytes received and copied to Body. This
1471 allows the client to download a large file in chunks instead of into one contiguous
1472 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is
1473 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive
1474 token to underlying TCP instance. If data arrives in the receive buffer, up to
1475 BodyLength bytes of data will be copied to Body. The HTTP driver will then update
1476 BodyLength with the amount of bytes received and copied to Body.
1478 If the HTTP driver does not have an open underlying TCP connection with the host
1479 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is
1480 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain
1481 an open TCP connection between client and host.
1483 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
1484 @param[in] Token Pointer to storage containing HTTP response token.
1486 @retval EFI_SUCCESS Allocation succeeded.
1487 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been
1489 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1492 Token->Message->Headers is NULL.
1493 Token->Message is NULL.
1494 Token->Message->Body is not NULL,
1495 Token->Message->BodyLength is non-zero, and
1496 Token->Message->Data is NULL, but a previous call to
1497 Response() has not been completed successfully.
1498 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
1499 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host
1500 specified by response URL.
1505 IN EFI_HTTP_PROTOCOL
*This
,
1506 IN EFI_HTTP_TOKEN
*Token
1510 EFI_HTTP_MESSAGE
*HttpMsg
;
1511 HTTP_PROTOCOL
*HttpInstance
;
1512 HTTP_TOKEN_WRAP
*Wrap
;
1514 if ((This
== NULL
) || (Token
== NULL
)) {
1515 return EFI_INVALID_PARAMETER
;
1518 HttpMsg
= Token
->Message
;
1519 if (HttpMsg
== NULL
) {
1520 return EFI_INVALID_PARAMETER
;
1523 HttpInstance
= HTTP_INSTANCE_FROM_PROTOCOL (This
);
1524 ASSERT (HttpInstance
!= NULL
);
1526 if (HttpInstance
->State
!= HTTP_STATE_TCP_CONNECTED
) {
1527 return EFI_NOT_STARTED
;
1531 // Check whether the token already existed.
1533 if (EFI_ERROR (NetMapIterate (&HttpInstance
->RxTokens
, HttpTokenExist
, Token
))) {
1534 return EFI_ACCESS_DENIED
;
1537 Wrap
= AllocateZeroPool (sizeof (HTTP_TOKEN_WRAP
));
1539 return EFI_OUT_OF_RESOURCES
;
1542 Wrap
->HttpInstance
= HttpInstance
;
1543 Wrap
->HttpToken
= Token
;
1546 // Notes: For Https, receive token wrapped in HTTP_TOKEN_WRAP is not used to
1547 // receive the https response. A special TlsRxToken is used for receiving TLS
1548 // related messages. It should be a blocking response.
1550 if (!HttpInstance
->UseHttps
) {
1551 Status
= HttpCreateTcpRxEvent (Wrap
);
1552 if (EFI_ERROR (Status
)) {
1557 Status
= NetMapInsertTail (&HttpInstance
->RxTokens
, Token
, Wrap
);
1558 if (EFI_ERROR (Status
)) {
1563 // If already have pending RxTokens, return directly.
1565 if (NetMapGetCount (&HttpInstance
->RxTokens
) > 1) {
1569 return HttpResponseWorker (Wrap
);
1573 if (Wrap
->TcpWrap
.Rx4Token
.CompletionToken
.Event
!= NULL
) {
1574 gBS
->CloseEvent (Wrap
->TcpWrap
.Rx4Token
.CompletionToken
.Event
);
1577 if (Wrap
->TcpWrap
.Rx6Token
.CompletionToken
.Event
!= NULL
) {
1578 gBS
->CloseEvent (Wrap
->TcpWrap
.Rx6Token
.CompletionToken
.Event
);
1587 The Poll() function can be used by network drivers and applications to increase the
1588 rate that data packets are moved between the communication devices and the transmit
1591 In some systems, the periodic timer event in the managed network driver may not poll
1592 the underlying communications device fast enough to transmit and/or receive all data
1593 packets without missing incoming packets or dropping outgoing packets. Drivers and
1594 applications that are experiencing packet loss should try calling the Poll() function
1597 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
1599 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1600 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1601 @retval EFI_INVALID_PARAMETER This is NULL.
1602 @retval EFI_NOT_READY No incoming or outgoing data is processed.
1603 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
1609 IN EFI_HTTP_PROTOCOL
*This
1613 HTTP_PROTOCOL
*HttpInstance
;
1616 return EFI_INVALID_PARAMETER
;
1619 HttpInstance
= HTTP_INSTANCE_FROM_PROTOCOL (This
);
1620 ASSERT (HttpInstance
!= NULL
);
1622 if (HttpInstance
->State
!= HTTP_STATE_TCP_CONNECTED
) {
1623 return EFI_NOT_STARTED
;
1626 if (HttpInstance
->LocalAddressIsIPv6
) {
1627 if (HttpInstance
->Tcp6
== NULL
) {
1628 return EFI_NOT_STARTED
;
1630 Status
= HttpInstance
->Tcp6
->Poll (HttpInstance
->Tcp6
);
1632 if (HttpInstance
->Tcp4
== NULL
) {
1633 return EFI_NOT_STARTED
;
1635 Status
= HttpInstance
->Tcp4
->Poll (HttpInstance
->Tcp4
);