]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/HttpDxe/HttpImpl.c
NetworkPkg: Update HttpDxe driver to consume EFI_HTTP_UTILITIES_PROTOCOL
[mirror_edk2.git] / NetworkPkg / HttpDxe / HttpImpl.c
1 /** @file
2 Implementation of EFI_HTTP_PROTOCOL protocol interfaces.
3
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include "HttpDriver.h"
17
18 EFI_HTTP_PROTOCOL mEfiHttpTemplate = {
19 EfiHttpGetModeData,
20 EfiHttpConfigure,
21 EfiHttpRequest,
22 EfiHttpCancel,
23 EfiHttpResponse,
24 EfiHttpPoll
25 };
26
27 /**
28 Returns the operational parameters for the current HTTP child instance.
29
30 The GetModeData() function is used to read the current mode data (operational
31 parameters) for this HTTP protocol instance.
32
33 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
34 @param[out] HttpConfigData Point to buffer for operational parameters of this
35 HTTP instance.
36
37 @retval EFI_SUCCESS Operation succeeded.
38 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
39 This is NULL.
40 HttpConfigData is NULL.
41 HttpConfigData->AccessPoint is NULL.
42 @retval EFI_NOT_STARTED The HTTP instance is not configured.
43
44 **/
45 EFI_STATUS
46 EFIAPI
47 EfiHttpGetModeData (
48 IN EFI_HTTP_PROTOCOL *This,
49 OUT EFI_HTTP_CONFIG_DATA *HttpConfigData
50 )
51 {
52 HTTP_PROTOCOL *HttpInstance;
53
54 if ((This == NULL) || (HttpConfigData == NULL)) {
55 return EFI_INVALID_PARAMETER;
56 }
57
58 HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
59 ASSERT (HttpInstance != NULL);
60
61 if (HttpInstance->State < HTTP_STATE_HTTP_CONFIGED) {
62 return EFI_NOT_STARTED;
63 }
64
65 if (HttpConfigData->AccessPoint.IPv4Node == NULL) {
66 return EFI_INVALID_PARAMETER;
67 }
68
69 HttpConfigData->HttpVersion = HttpInstance->HttpVersion;
70 HttpConfigData->TimeOutMillisec = HttpInstance->TimeOutMillisec;
71 HttpConfigData->LocalAddressIsIPv6 = HttpInstance->LocalAddressIsIPv6;
72
73 CopyMem (
74 HttpConfigData->AccessPoint.IPv4Node,
75 &HttpInstance->IPv4Node,
76 sizeof (HttpInstance->IPv4Node)
77 );
78
79 return EFI_SUCCESS;
80 }
81
82 /**
83 Initialize or brutally reset the operational parameters for this EFI HTTP instance.
84
85 The Configure() function does the following:
86 When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring
87 timeout, local address, port, etc.
88 When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active
89 connections with remote hosts, canceling all asynchronous tokens, and flush request
90 and response buffers without informing the appropriate hosts.
91
92 Except for GetModeData() and Configure(), No other EFI HTTP function can be executed
93 by this instance until the Configure() function is executed and returns successfully.
94
95 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
96 @param[in] HttpConfigData Pointer to the configure data to configure the instance.
97
98 @retval EFI_SUCCESS Operation succeeded.
99 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
100 This is NULL.
101 HttpConfigData->LocalAddressIsIPv6 is FALSE and
102 HttpConfigData->IPv4Node is NULL.
103 HttpConfigData->LocalAddressIsIPv6 is TRUE and
104 HttpConfigData->IPv6Node is NULL.
105 @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling
106 Configure() with NULL to reset it.
107 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
108 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
109 executing Configure().
110 @retval EFI_UNSUPPORTED One or more options in HttpConfigData are not supported
111 in the implementation.
112 **/
113 EFI_STATUS
114 EFIAPI
115 EfiHttpConfigure (
116 IN EFI_HTTP_PROTOCOL *This,
117 IN EFI_HTTP_CONFIG_DATA *HttpConfigData
118 )
119 {
120 HTTP_PROTOCOL *HttpInstance;
121 EFI_STATUS Status;
122
123 if (This == NULL) {
124 return EFI_INVALID_PARAMETER;
125 }
126
127 HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
128 ASSERT (HttpInstance != NULL && HttpInstance->Service != NULL);
129
130 if (HttpConfigData != NULL) {
131 //
132 // Check input parameters.
133 //
134 if (HttpConfigData->LocalAddressIsIPv6) {
135 if (HttpConfigData->AccessPoint.IPv6Node == NULL) {
136 return EFI_INVALID_PARAMETER;
137 }
138 } else {
139 if (HttpConfigData->AccessPoint.IPv4Node == NULL) {
140 return EFI_INVALID_PARAMETER;
141 }
142 }
143 //
144 // Now configure this HTTP instance.
145 //
146 if (HttpInstance->State != HTTP_STATE_UNCONFIGED) {
147 return EFI_ALREADY_STARTED;
148 }
149
150 HttpInstance->HttpVersion = HttpConfigData->HttpVersion;
151 HttpInstance->TimeOutMillisec = HttpConfigData->TimeOutMillisec;
152 HttpInstance->LocalAddressIsIPv6 = HttpConfigData->LocalAddressIsIPv6;
153
154 if (HttpConfigData->LocalAddressIsIPv6) {
155 return EFI_UNSUPPORTED;
156 } else {
157 CopyMem (
158 &HttpInstance->IPv4Node,
159 HttpConfigData->AccessPoint.IPv4Node,
160 sizeof (HttpInstance->IPv4Node)
161 );
162
163 HttpInstance->State = HTTP_STATE_HTTP_CONFIGED;
164 return EFI_SUCCESS;
165 }
166
167 } else {
168 if (HttpInstance->LocalAddressIsIPv6) {
169 return EFI_UNSUPPORTED;
170 } else {
171 HttpCleanProtocol (HttpInstance);
172 Status = HttpInitProtocol (HttpInstance->Service, HttpInstance);
173 if (EFI_ERROR (Status)) {
174 return Status;
175 }
176
177 HttpInstance->State = HTTP_STATE_UNCONFIGED;
178 return EFI_SUCCESS;
179 }
180 }
181 }
182
183
184 /**
185 The Request() function queues an HTTP request to this HTTP instance.
186
187 Similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent
188 successfully, or if there is an error, Status in token will be updated and Event will
189 be signaled.
190
191 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
192 @param[in] Token Pointer to storage containing HTTP request token.
193
194 @retval EFI_SUCCESS Outgoing data was processed.
195 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
196 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
197 @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.
198 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
199 @retval EFI_UNSUPPORTED The HTTP method is not supported in current
200 implementation.
201 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
202 This is NULL.
203 Token->Message is NULL.
204 Token->Message->Body is not NULL,
205 Token->Message->BodyLength is non-zero, and
206 Token->Message->Data is NULL, but a previous call to
207 Request()has not been completed successfully.
208 **/
209 EFI_STATUS
210 EFIAPI
211 EfiHttpRequest (
212 IN EFI_HTTP_PROTOCOL *This,
213 IN EFI_HTTP_TOKEN *Token
214 )
215 {
216 EFI_HTTP_MESSAGE *HttpMsg;
217 EFI_HTTP_REQUEST_DATA *Request;
218 VOID *UrlParser;
219 EFI_STATUS Status;
220 CHAR8 *HostName;
221 UINT16 RemotePort;
222 HTTP_PROTOCOL *HttpInstance;
223 BOOLEAN Configure;
224 BOOLEAN ReConfigure;
225 CHAR8 *RequestStr;
226 CHAR8 *Url;
227 CHAR16 *HostNameStr;
228 HTTP_TOKEN_WRAP *Wrap;
229 HTTP_TCP_TOKEN_WRAP *TcpWrap;
230 CHAR8 *FileUrl;
231
232 if ((This == NULL) || (Token == NULL)) {
233 return EFI_INVALID_PARAMETER;
234 }
235
236 HttpMsg = Token->Message;
237 if ((HttpMsg == NULL) || (HttpMsg->Headers == NULL)) {
238 return EFI_INVALID_PARAMETER;
239 }
240
241 //
242 // Current implementation does not support POST/PUT method.
243 // If future version supports these two methods, Request could be NULL for a special case that to send large amounts
244 // of data. For this case, the implementation need check whether previous call to Request() has been completed or not.
245 //
246 //
247 Request = HttpMsg->Data.Request;
248 if ((Request == NULL) || (Request->Url == NULL)) {
249 return EFI_INVALID_PARAMETER;
250 }
251
252 //
253 // Only support GET and HEAD method in current implementation.
254 //
255 if ((Request->Method != HttpMethodGet) && (Request->Method != HttpMethodHead)) {
256 return EFI_UNSUPPORTED;
257 }
258
259 HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
260 ASSERT (HttpInstance != NULL);
261
262 if (HttpInstance->State < HTTP_STATE_HTTP_CONFIGED) {
263 return EFI_NOT_STARTED;
264 }
265
266 if (HttpInstance->LocalAddressIsIPv6) {
267 return EFI_UNSUPPORTED;
268 }
269
270 //
271 // Check whether the token already existed.
272 //
273 if (EFI_ERROR (NetMapIterate (&HttpInstance->TxTokens, HttpTokenExist, Token))) {
274 return EFI_ACCESS_DENIED;
275 }
276
277 Url = NULL;
278 HostName = NULL;
279 Wrap = NULL;
280 HostNameStr = NULL;
281 TcpWrap = NULL;
282
283 //
284 // Parse the URI of the remote host.
285 //
286 Url = AllocatePool (StrLen (Request->Url) + 1);
287 if (Url == NULL) {
288 return EFI_OUT_OF_RESOURCES;
289 }
290
291 UnicodeStrToAsciiStr (Request->Url, Url);
292 UrlParser = NULL;
293 Status = HttpParseUrl (Url, (UINT32) AsciiStrLen (Url), FALSE, &UrlParser);
294 if (EFI_ERROR (Status)) {
295 goto Error1;
296 }
297
298 RequestStr = NULL;
299 HostName = NULL;
300 Status = HttpUrlGetHostName (Url, UrlParser, &HostName);
301 if (EFI_ERROR (Status)) {
302 goto Error1;
303 }
304
305 Status = HttpUrlGetPort (Url, UrlParser, &RemotePort);
306 if (EFI_ERROR (Status)) {
307 RemotePort = HTTP_DEFAULT_PORT;
308 }
309
310 Configure = TRUE;
311 ReConfigure = TRUE;
312
313 if (HttpInstance->RemoteHost == NULL && HttpInstance->RemotePort == 0) {
314 //
315 // Request() is called the first time.
316 //
317 ReConfigure = FALSE;
318 } else {
319 if ((HttpInstance->RemotePort == RemotePort) &&
320 (AsciiStrCmp (HttpInstance->RemoteHost, HostName) == 0)) {
321 //
322 // Host Name and port number of the request URL are the same with previous call to Request().
323 // Check whether previous TCP packet sent out.
324 //
325 if (EFI_ERROR (NetMapIterate (&HttpInstance->TxTokens, HttpTcpNotReady, NULL))) {
326 //
327 // Wrap the HTTP token in HTTP_TOKEN_WRAP
328 //
329 Wrap = AllocateZeroPool (sizeof (HTTP_TOKEN_WRAP));
330 if (Wrap == NULL) {
331 Status = EFI_OUT_OF_RESOURCES;
332 goto Error1;
333 }
334
335 Wrap->HttpToken = Token;
336 Wrap->HttpInstance = HttpInstance;
337
338 Status = HttpCreateTcp4TxEvent (Wrap);
339 if (EFI_ERROR (Status)) {
340 goto Error1;
341 }
342
343 Status = NetMapInsertTail (&HttpInstance->TxTokens, Token, Wrap);
344 if (EFI_ERROR (Status)) {
345 goto Error1;
346 }
347
348 Wrap->TcpWrap.Method = Request->Method;
349
350 FreePool (Url);
351 FreePool (HostName);
352
353 //
354 // Queue the HTTP token and return.
355 //
356 return EFI_SUCCESS;
357 } else {
358 //
359 // Use existing TCP instance to transmit the packet.
360 //
361 Configure = FALSE;
362 ReConfigure = FALSE;
363 }
364 } else {
365 //
366 // Need close existing TCP instance and create a new TCP instance for data transmit.
367 //
368 if (HttpInstance->RemoteHost != NULL) {
369 FreePool (HttpInstance->RemoteHost);
370 HttpInstance->RemoteHost = NULL;
371 }
372 }
373 }
374
375 if (Configure) {
376 //
377 // Parse Url for IPv4 address, if failed, perform DNS resolution.
378 //
379 Status = NetLibAsciiStrToIp4 (HostName, &HttpInstance->RemoteAddr);
380 if (EFI_ERROR (Status)) {
381 HostNameStr = AllocateZeroPool ((AsciiStrLen (HostName) + 1) * sizeof (UINT16));
382 if (HostNameStr == NULL) {
383 Status = EFI_OUT_OF_RESOURCES;
384 goto Error1;
385 }
386
387 AsciiStrToUnicodeStr (HostName, HostNameStr);
388 Status = HttpDns4 (HttpInstance, HostNameStr, &HttpInstance->RemoteAddr);
389 FreePool (HostNameStr);
390 if (EFI_ERROR (Status)) {
391 goto Error1;
392 }
393 }
394
395 //
396 // Save the RemotePort and RemoteHost.
397 //
398 ASSERT (HttpInstance->RemoteHost == NULL);
399 HttpInstance->RemotePort = RemotePort;
400 HttpInstance->RemoteHost = HostName;
401 HostName = NULL;
402 }
403
404 if (ReConfigure) {
405 //
406 // The request URL is different from previous calls to Request(), close existing TCP instance.
407 //
408 ASSERT (HttpInstance->Tcp4 != NULL);
409 HttpCloseConnection (HttpInstance);
410 EfiHttpCancel (This, NULL);
411 }
412
413 //
414 // Wrap the HTTP token in HTTP_TOKEN_WRAP
415 //
416 Wrap = AllocateZeroPool (sizeof (HTTP_TOKEN_WRAP));
417 if (Wrap == NULL) {
418 Status = EFI_OUT_OF_RESOURCES;
419 goto Error1;
420 }
421
422 Wrap->HttpToken = Token;
423 Wrap->HttpInstance = HttpInstance;
424 Wrap->TcpWrap.Method = Request->Method;
425
426 if (Configure) {
427 //
428 // Configure TCP instance.
429 //
430 Status = HttpConfigureTcp4 (HttpInstance, Wrap);
431 if (EFI_ERROR (Status)) {
432 goto Error1;
433 }
434 //
435 // Connect TCP.
436 //
437 Status = HttpConnectTcp4 (HttpInstance);
438 if (EFI_ERROR (Status)) {
439 goto Error2;
440 }
441 } else {
442 //
443 // For the new HTTP token, create TX TCP token events.
444 //
445 Status = HttpCreateTcp4TxEvent (Wrap);
446 if (EFI_ERROR (Status)) {
447 goto Error1;
448 }
449 }
450
451 //
452 // Create request message.
453 //
454 FileUrl = Url;
455 if (*FileUrl != '/') {
456 //
457 // Convert the absolute-URI to the absolute-path
458 //
459 while (*FileUrl != ':') {
460 FileUrl++;
461 }
462 if ((*(FileUrl+1) == '/') && (*(FileUrl+2) == '/')) {
463 FileUrl += 3;
464 while (*FileUrl != '/') {
465 FileUrl++;
466 }
467 } else {
468 Status = EFI_INVALID_PARAMETER;
469 goto Error3;
470 }
471 }
472 RequestStr = HttpGenRequestString (HttpInstance, HttpMsg, FileUrl);
473 if (RequestStr == NULL) {
474 Status = EFI_OUT_OF_RESOURCES;
475 goto Error3;
476 }
477
478 Status = NetMapInsertTail (&HttpInstance->TxTokens, Token, Wrap);
479 if (EFI_ERROR (Status)) {
480 goto Error4;
481 }
482
483 FreePool (Url);
484 if (HostName != NULL) {
485 FreePool (HostName);
486 }
487
488 //
489 // Transmit the request message.
490 //
491 Status = HttpTransmitTcp4 (
492 HttpInstance,
493 Wrap,
494 (UINT8*) RequestStr,
495 AsciiStrLen (RequestStr)
496 );
497 if (EFI_ERROR (Status)) {
498 goto Error5;
499 }
500
501 return EFI_SUCCESS;
502
503 Error5:
504 NetMapRemoveTail (&HttpInstance->TxTokens, NULL);
505
506 Error4:
507 if (RequestStr != NULL) {
508 FreePool (RequestStr);
509 }
510
511 Error3:
512 HttpCloseConnection (HttpInstance);
513
514
515 Error2:
516 HttpCloseTcp4ConnCloseEvent (HttpInstance);
517 if (NULL != Wrap->TcpWrap.TxToken.CompletionToken.Event) {
518 gBS->CloseEvent (Wrap->TcpWrap.TxToken.CompletionToken.Event);
519 }
520
521 Error1:
522 if (Url != NULL) {
523 FreePool (Url);
524 }
525 if (HostName != NULL) {
526 FreePool (HostName);
527 }
528 if (Wrap != NULL) {
529 FreePool (Wrap);
530 }
531 if (UrlParser!= NULL) {
532 HttpUrlFreeParser (UrlParser);
533 }
534
535 return Status;
536
537 }
538
539 /**
540 Cancel a TxToken or RxToken.
541
542 @param[in] Map The HTTP instance's token queue.
543 @param[in] Item Object container for one HTTP token and token's wrap.
544 @param[in] Context The user's token to cancel.
545
546 @retval EFI_SUCCESS Continue to check the next Item.
547 @retval EFI_ABORTED The user's Token (Token != NULL) is cancelled.
548
549 **/
550 EFI_STATUS
551 EFIAPI
552 HttpCancelTokens (
553 IN NET_MAP *Map,
554 IN NET_MAP_ITEM *Item,
555 IN VOID *Context
556 )
557 {
558
559 EFI_HTTP_TOKEN *Token;
560 HTTP_TOKEN_WRAP *Wrap;
561
562 Token = (EFI_HTTP_TOKEN *) Context;
563
564 //
565 // Return EFI_SUCCESS to check the next item in the map if
566 // this one doesn't match.
567 //
568 if ((Token != NULL) && (Token != Item->Key)) {
569 return EFI_SUCCESS;
570 }
571
572 Wrap = (HTTP_TOKEN_WRAP *) Item->Value;
573 ASSERT (Wrap != NULL);
574
575 //
576 // Free resources.
577 //
578 NetMapRemoveItem (Map, Item, NULL);
579
580 if (Wrap->TcpWrap.TxToken.CompletionToken.Event != NULL) {
581 gBS->CloseEvent (Wrap->TcpWrap.TxToken.CompletionToken.Event);
582 }
583
584 if (Wrap->TcpWrap.RxToken.CompletionToken.Event != NULL) {
585 gBS->CloseEvent (Wrap->TcpWrap.RxToken.CompletionToken.Event);
586 }
587
588 if (Wrap->TcpWrap.RxToken.Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
589 FreePool (Wrap->TcpWrap.RxToken.Packet.RxData->FragmentTable[0].FragmentBuffer);
590 }
591
592 FreePool (Wrap);
593
594 //
595 // If only one item is to be cancel, return EFI_ABORTED to stop
596 // iterating the map any more.
597 //
598 if (Token != NULL) {
599 return EFI_ABORTED;
600 }
601
602 return EFI_SUCCESS;
603 }
604
605 /**
606 Cancel the user's receive/transmit request. It is the worker function of
607 EfiHttpCancel API. If a matching token is found, it will call HttpCancelTokens to cancel the
608 token.
609
610 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
611 @param[in] Token The token to cancel. If NULL, all token will be
612 cancelled.
613
614 @retval EFI_SUCCESS The token is cancelled.
615 @retval EFI_NOT_FOUND The asynchronous request or response token is not found.
616 @retval Others Other error as indicated.
617
618 **/
619 EFI_STATUS
620 HttpCancel (
621 IN HTTP_PROTOCOL *HttpInstance,
622 IN EFI_HTTP_TOKEN *Token
623 )
624 {
625 EFI_STATUS Status;
626
627 //
628 // First check the tokens queued by EfiHttpRequest().
629 //
630 Status = NetMapIterate (&HttpInstance->TxTokens, HttpCancelTokens, Token);
631 if (EFI_ERROR (Status)) {
632 if (Token != NULL) {
633 if (Status == EFI_ABORTED) {
634 return EFI_SUCCESS;
635 }
636 } else {
637 return Status;
638 }
639 }
640
641 //
642 // Then check the tokens queued by EfiHttpResponse().
643 //
644 Status = NetMapIterate (&HttpInstance->RxTokens, HttpCancelTokens, Token);
645 if (EFI_ERROR (Status)) {
646 if (Token != NULL) {
647 if (Status == EFI_ABORTED) {
648 return EFI_SUCCESS;
649 } else {
650 return EFI_NOT_FOUND;
651 }
652 } else {
653 return Status;
654 }
655 }
656
657 return EFI_SUCCESS;
658 }
659
660
661 /**
662 Abort an asynchronous HTTP request or response token.
663
664 The Cancel() function aborts a pending HTTP request or response transaction. If
665 Token is not NULL and the token is in transmit or receive queues when it is being
666 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will
667 be signaled. If the token is not in one of the queues, which usually means that the
668 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,
669 all asynchronous tokens issued by Request() or Response() will be aborted.
670
671 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
672 @param[in] Token Point to storage containing HTTP request or response
673 token.
674
675 @retval EFI_SUCCESS Request and Response queues are successfully flushed.
676 @retval EFI_INVALID_PARAMETER This is NULL.
677 @retval EFI_NOT_STARTED This instance hasn't been configured.
678 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP,
679 BOOTP, RARP, etc.) hasn't finished yet.
680 @retval EFI_NOT_FOUND The asynchronous request or response token is not
681 found.
682 @retval EFI_UNSUPPORTED The implementation does not support this function.
683
684 **/
685 EFI_STATUS
686 EFIAPI
687 EfiHttpCancel (
688 IN EFI_HTTP_PROTOCOL *This,
689 IN EFI_HTTP_TOKEN *Token
690 )
691 {
692 HTTP_PROTOCOL *HttpInstance;
693
694 if (This == NULL) {
695 return EFI_INVALID_PARAMETER;
696 }
697
698 HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
699 ASSERT (HttpInstance != NULL);
700
701 if (HttpInstance->State != HTTP_STATE_TCP_CONNECTED) {
702 return EFI_NOT_STARTED;
703 }
704
705 return HttpCancel (HttpInstance, Token);
706
707 }
708
709 /**
710 A callback function to intercept events during message parser.
711
712 This function will be invoked during HttpParseMessageBody() with various events type. An error
713 return status of the callback function will cause the HttpParseMessageBody() aborted.
714
715 @param[in] EventType Event type of this callback call.
716 @param[in] Data A pointer to data buffer.
717 @param[in] Length Length in bytes of the Data.
718 @param[in] Context Callback context set by HttpInitMsgParser().
719
720 @retval EFI_SUCCESS Continue to parser the message body.
721
722 **/
723 EFI_STATUS
724 EFIAPI
725 HttpBodyParserCallback (
726 IN HTTP_BODY_PARSE_EVENT EventType,
727 IN CHAR8 *Data,
728 IN UINTN Length,
729 IN VOID *Context
730 )
731 {
732 HTTP_TOKEN_WRAP *Wrap;
733
734 if (EventType != BodyParseEventOnComplete) {
735 return EFI_SUCCESS;
736 }
737
738 if (Data == NULL || Length != 0 || Context == NULL) {
739 return EFI_SUCCESS;
740 }
741
742 Wrap = (HTTP_TOKEN_WRAP *) Context;
743 Wrap->HttpInstance->NextMsg = Data;
744
745 //
746 // Free TxToken since already received corrsponding HTTP response.
747 //
748 FreePool (Wrap);
749
750 return EFI_SUCCESS;
751 }
752
753 /**
754 The work function of EfiHttpResponse().
755
756 @param[in] Wrap Pointer to HTTP token's wrap data.
757
758 @retval EFI_SUCCESS Allocation succeeded.
759 @retval EFI_OUT_OF_RESOURCES Failed to complete the opration due to lack of resources.
760 @retval EFI_NOT_READY Can't find a corresponding TxToken or
761 the EFI_HTTP_UTILITIES_PROTOCOL is not available.
762
763 **/
764 EFI_STATUS
765 HttpResponseWorker (
766 IN HTTP_TOKEN_WRAP *Wrap
767 )
768 {
769 EFI_STATUS Status;
770 EFI_HTTP_MESSAGE *HttpMsg;
771 EFI_TCP4_IO_TOKEN *RxToken;
772 EFI_TCP4_PROTOCOL *Tcp4;
773 CHAR8 *EndofHeader;
774 CHAR8 *HttpHeaders;
775 UINTN SizeofHeaders;
776 CHAR8 *Buffer;
777 UINTN BufferSize;
778 UINTN StatusCode;
779 CHAR8 *Tmp;
780 CHAR8 *HeaderTmp;
781 CHAR8 *StatusCodeStr;
782 UINTN BodyLen;
783 HTTP_PROTOCOL *HttpInstance;
784 EFI_HTTP_TOKEN *Token;
785 NET_MAP_ITEM *Item;
786 HTTP_TOKEN_WRAP *ValueInItem;
787 UINTN HdrLen;
788
789 if (Wrap == NULL || Wrap->HttpInstance == NULL) {
790 return EFI_INVALID_PARAMETER;
791 }
792
793 HttpInstance = Wrap->HttpInstance;
794 Token = Wrap->HttpToken;
795
796 HttpMsg = Token->Message;
797
798 Tcp4 = HttpInstance->Tcp4;
799 ASSERT (Tcp4 != NULL);
800 HttpMsg->Headers = NULL;
801 HttpHeaders = NULL;
802 SizeofHeaders = 0;
803 Buffer = NULL;
804 BufferSize = 0;
805 EndofHeader = NULL;
806
807 if (HttpMsg->Data.Response != NULL) {
808 //
809 // Need receive the HTTP headers, prepare buffer.
810 //
811 Status = HttpCreateTcp4RxEventForHeader (HttpInstance);
812 if (EFI_ERROR (Status)) {
813 goto Error;
814 }
815
816 //
817 // Check whether we have cached header from previous call.
818 //
819 if ((HttpInstance->CacheBody != NULL) && (HttpInstance->NextMsg != NULL)) {
820 //
821 // The data is stored at [NextMsg, CacheBody + CacheLen].
822 //
823 HdrLen = HttpInstance->CacheBody + HttpInstance->CacheLen - HttpInstance->NextMsg;
824 HttpHeaders = AllocateZeroPool (HdrLen);
825 if (HttpHeaders == NULL) {
826 Status = EFI_OUT_OF_RESOURCES;
827 goto Error;
828 }
829
830 CopyMem (HttpHeaders, HttpInstance->NextMsg, HdrLen);
831 FreePool (HttpInstance->CacheBody);
832 HttpInstance->CacheBody = NULL;
833 HttpInstance->NextMsg = NULL;
834 HttpInstance->CacheOffset = 0;
835 SizeofHeaders = HdrLen;
836 BufferSize = HttpInstance->CacheLen;
837
838 //
839 // Check whether we cached the whole HTTP headers.
840 //
841 EndofHeader = AsciiStrStr (HttpHeaders, HTTP_END_OF_HDR_STR);
842 }
843
844 RxToken = &HttpInstance->RxToken;
845 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer = AllocateZeroPool (DEF_BUF_LEN);
846 if (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer == NULL) {
847 Status = EFI_OUT_OF_RESOURCES;
848 goto Error;
849 }
850
851 //
852 // Receive the HTTP headers only when EFI_HTTP_RESPONSE_DATA is not NULL.
853 //
854 while (EndofHeader == NULL) {
855 HttpInstance->IsRxDone = FALSE;
856 RxToken->Packet.RxData->DataLength = DEF_BUF_LEN;
857 RxToken->Packet.RxData->FragmentTable[0].FragmentLength = DEF_BUF_LEN;
858 Status = Tcp4->Receive (Tcp4, RxToken);
859 if (EFI_ERROR (Status)) {
860 DEBUG ((EFI_D_ERROR, "Tcp4 receive failed: %r\n", Status));
861 goto Error;
862 }
863
864 while (!HttpInstance->IsRxDone) {
865 Tcp4->Poll (Tcp4);
866 }
867
868 Status = RxToken->CompletionToken.Status;
869 if (EFI_ERROR (Status)) {
870 goto Error;
871 }
872
873 //
874 // Append the response string.
875 //
876 BufferSize = SizeofHeaders + RxToken->Packet.RxData->FragmentTable[0].FragmentLength;
877 Buffer = AllocateZeroPool (BufferSize);
878 if (Buffer == NULL) {
879 Status = EFI_OUT_OF_RESOURCES;
880 goto Error;
881 }
882
883 if (HttpHeaders != NULL) {
884 CopyMem (Buffer, HttpHeaders, SizeofHeaders);
885 FreePool (HttpHeaders);
886 }
887
888 CopyMem (
889 Buffer + SizeofHeaders,
890 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer,
891 RxToken->Packet.RxData->FragmentTable[0].FragmentLength
892 );
893 HttpHeaders = Buffer;
894 SizeofHeaders = BufferSize;
895
896 //
897 // Check whether we received end of HTTP headers.
898 //
899 EndofHeader = AsciiStrStr (HttpHeaders, HTTP_END_OF_HDR_STR);
900 };
901
902 //
903 // Skip the CRLF after the HTTP headers.
904 //
905 EndofHeader = EndofHeader + AsciiStrLen (HTTP_END_OF_HDR_STR);
906
907 //
908 // Cache the part of body.
909 //
910 BodyLen = BufferSize - (EndofHeader - HttpHeaders);
911 if (BodyLen > 0) {
912 if (HttpInstance->CacheBody != NULL) {
913 FreePool (HttpInstance->CacheBody);
914 }
915
916 HttpInstance->CacheBody = AllocateZeroPool (BodyLen);
917 if (HttpInstance->CacheBody == NULL) {
918 Status = EFI_OUT_OF_RESOURCES;
919 goto Error;
920 }
921
922 CopyMem (HttpInstance->CacheBody, EndofHeader, BodyLen);
923 HttpInstance->CacheLen = BodyLen;
924 }
925
926 FreePool (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer);
927 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
928
929 //
930 // Search for Status Code.
931 //
932 StatusCodeStr = HttpHeaders + AsciiStrLen (HTTP_VERSION_STR) + 1;
933 if (StatusCodeStr == NULL) {
934 goto Error;
935 }
936
937 StatusCode = AsciiStrDecimalToUintn (StatusCodeStr);
938
939 //
940 // Remove the first line of HTTP message, e.g. "HTTP/1.1 200 OK\r\n".
941 //
942 Tmp = AsciiStrStr (HttpHeaders, HTTP_CRLF_STR);
943 if (Tmp == NULL) {
944 goto Error;
945 }
946
947 Tmp = Tmp + AsciiStrLen (HTTP_CRLF_STR);
948 SizeofHeaders = SizeofHeaders - (Tmp - HttpHeaders);
949 HeaderTmp = AllocateZeroPool (SizeofHeaders);
950 if (HeaderTmp == NULL) {
951 goto Error;
952 }
953
954 CopyMem (HeaderTmp, Tmp, SizeofHeaders);
955 FreePool (HttpHeaders);
956 HttpHeaders = HeaderTmp;
957
958 //
959 // Check whether the EFI_HTTP_UTILITIES_PROTOCOL is available.
960 //
961 if (mHttpUtilities == NULL) {
962 Status = EFI_NOT_READY;
963 goto Error;
964 }
965
966 //
967 // Parse the HTTP header into array of key/value pairs.
968 //
969 Status = mHttpUtilities->Parse (
970 mHttpUtilities,
971 HttpHeaders,
972 SizeofHeaders,
973 &HttpMsg->Headers,
974 &HttpMsg->HeaderCount
975 );
976 if (EFI_ERROR (Status)) {
977 goto Error;
978 }
979
980 FreePool (HttpHeaders);
981 HttpHeaders = NULL;
982
983 HttpMsg->Data.Response->StatusCode = HttpMappingToStatusCode (StatusCode);
984
985 //
986 // Init message-body parser by header information.
987 //
988 Status = EFI_NOT_READY;
989 ValueInItem = NULL;
990 NetMapRemoveHead (&HttpInstance->TxTokens, (VOID**) &ValueInItem);
991 if (ValueInItem == NULL) {
992 goto Error;
993 }
994
995 //
996 // The first TxToken not transmitted yet, insert back and return error.
997 //
998 if (!ValueInItem->TcpWrap.IsTxDone) {
999 goto Error2;
1000 }
1001
1002 Status = HttpInitMsgParser (
1003 ValueInItem->TcpWrap.Method,
1004 HttpMsg->Data.Response->StatusCode,
1005 HttpMsg->HeaderCount,
1006 HttpMsg->Headers,
1007 HttpBodyParserCallback,
1008 (VOID *) ValueInItem,
1009 &HttpInstance->MsgParser
1010 );
1011 if (EFI_ERROR (Status)) {
1012 goto Error2;
1013 }
1014
1015 //
1016 // Check whether we received a complete HTTP message.
1017 //
1018 if (HttpInstance->CacheBody != NULL) {
1019 Status = HttpParseMessageBody (HttpInstance->MsgParser, HttpInstance->CacheLen, HttpInstance->CacheBody);
1020 if (EFI_ERROR (Status)) {
1021 goto Error2;
1022 }
1023
1024 if (HttpIsMessageComplete (HttpInstance->MsgParser)) {
1025 //
1026 // Free the MsgParse since we already have a full HTTP message.
1027 //
1028 HttpFreeMsgParser (HttpInstance->MsgParser);
1029 HttpInstance->MsgParser = NULL;
1030 }
1031 }
1032
1033 if ((HttpMsg->Body == NULL) || (HttpMsg->BodyLength == 0)) {
1034 Status = EFI_SUCCESS;
1035 goto Exit;
1036 }
1037 }
1038
1039 //
1040 // Receive the response body.
1041 //
1042 BodyLen = 0;
1043
1044 //
1045 // First check whether we cached some data.
1046 //
1047 if (HttpInstance->CacheBody != NULL) {
1048 //
1049 // Calculate the length of the cached data.
1050 //
1051 if (HttpInstance->NextMsg != NULL) {
1052 //
1053 // We have a cached HTTP message which includes a part of HTTP header of next message.
1054 //
1055 BodyLen = HttpInstance->NextMsg - (HttpInstance->CacheBody + HttpInstance->CacheOffset);
1056 } else {
1057 BodyLen = HttpInstance->CacheLen - HttpInstance->CacheOffset;
1058 }
1059
1060 if (BodyLen > 0) {
1061 //
1062 // We have some cached data. Just copy the data and return.
1063 //
1064 if (HttpMsg->BodyLength < BodyLen) {
1065 CopyMem (HttpMsg->Body, HttpInstance->CacheBody + HttpInstance->CacheOffset, HttpMsg->BodyLength);
1066 HttpInstance->CacheOffset = HttpInstance->CacheOffset + HttpMsg->BodyLength;
1067 } else {
1068 //
1069 // Copy all cached data out.
1070 //
1071 CopyMem (HttpMsg->Body, HttpInstance->CacheBody + HttpInstance->CacheOffset, BodyLen);
1072 HttpInstance->CacheOffset = BodyLen + HttpInstance->CacheOffset;
1073 HttpMsg->BodyLength = BodyLen;
1074
1075 if (HttpInstance->NextMsg == NULL) {
1076 //
1077 // There is no HTTP header of next message. Just free the cache buffer.
1078 //
1079 FreePool (HttpInstance->CacheBody);
1080 HttpInstance->CacheBody = NULL;
1081 HttpInstance->NextMsg = NULL;
1082 HttpInstance->CacheOffset = 0;
1083 }
1084 }
1085 //
1086 // Return since we aready received required data.
1087 //
1088 Status = EFI_SUCCESS;
1089 goto Exit;
1090 }
1091
1092 if (BodyLen == 0 && HttpInstance->MsgParser == NULL) {
1093 //
1094 // We received a complete HTTP message, and we don't have more data to return to caller.
1095 //
1096 HttpMsg->BodyLength = 0;
1097 Status = EFI_SUCCESS;
1098 goto Exit;
1099 }
1100 }
1101
1102 ASSERT (HttpInstance->MsgParser != NULL);
1103
1104 //
1105 // We still need receive more data when there is no cache data and MsgParser is not NULL;
1106 //
1107 RxToken = &Wrap->TcpWrap.RxToken;
1108
1109 RxToken->Packet.RxData->DataLength = (UINT32) HttpMsg->BodyLength;
1110 RxToken->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) HttpMsg->BodyLength;
1111 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *) HttpMsg->Body;
1112
1113 RxToken->CompletionToken.Status = EFI_NOT_READY;
1114 Status = Tcp4->Receive (Tcp4, RxToken);
1115 if (EFI_ERROR (Status)) {
1116 DEBUG ((EFI_D_ERROR, "Tcp4 receive failed: %r\n", Status));
1117 goto Error;
1118 }
1119
1120 return Status;
1121
1122 Exit:
1123 Item = NetMapFindKey (&Wrap->HttpInstance->RxTokens, Wrap->HttpToken);
1124 if (Item != NULL) {
1125 NetMapRemoveItem (&Wrap->HttpInstance->RxTokens, Item, NULL);
1126 }
1127 Token->Status = Status;
1128 gBS->SignalEvent (Token->Event);
1129 FreePool (Wrap);
1130 return Status;
1131
1132 Error2:
1133 NetMapInsertHead (&HttpInstance->TxTokens, ValueInItem->HttpToken, ValueInItem);
1134
1135 Error:
1136 if (Wrap != NULL) {
1137 if (Wrap->TcpWrap.RxToken.CompletionToken.Event != NULL) {
1138 gBS->CloseEvent (Wrap->TcpWrap.RxToken.CompletionToken.Event);
1139 }
1140 RxToken = &Wrap->TcpWrap.RxToken;
1141 if (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
1142 FreePool (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer);
1143 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
1144 }
1145 FreePool (Wrap);
1146 }
1147
1148 if (HttpInstance->RxToken.CompletionToken.Event != NULL) {
1149 gBS->CloseEvent (HttpInstance->RxToken.CompletionToken.Event);
1150 HttpInstance->RxToken.CompletionToken.Event = NULL;
1151 }
1152
1153 RxToken = &HttpInstance->RxToken;
1154 if (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
1155 FreePool (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer);
1156 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
1157 }
1158
1159 if (HttpHeaders != NULL) {
1160 FreePool (HttpHeaders);
1161 }
1162
1163 if (HttpMsg->Headers != NULL) {
1164 FreePool (HttpMsg->Headers);
1165 }
1166
1167 if (HttpInstance->CacheBody != NULL) {
1168 FreePool (HttpInstance->CacheBody);
1169 HttpInstance->CacheBody = NULL;
1170 }
1171
1172 Token->Status = Status;
1173 gBS->SignalEvent (Token->Event);
1174
1175 return Status;
1176
1177 }
1178
1179
1180 /**
1181 The Response() function queues an HTTP response to this HTTP instance, similar to
1182 Receive() function in the EFI TCP driver. When the HTTP request is sent successfully,
1183 or if there is an error, Status in token will be updated and Event will be signaled.
1184
1185 The HTTP driver will queue a receive token to the underlying TCP instance. When data
1186 is received in the underlying TCP instance, the data will be parsed and Token will
1187 be populated with the response data. If the data received from the remote host
1188 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting
1189 (asynchronously) for more data to be sent from the remote host before signaling
1190 Event in Token.
1191
1192 It is the responsibility of the caller to allocate a buffer for Body and specify the
1193 size in BodyLength. If the remote host provides a response that contains a content
1194 body, up to BodyLength bytes will be copied from the receive buffer into Body and
1195 BodyLength will be updated with the amount of bytes received and copied to Body. This
1196 allows the client to download a large file in chunks instead of into one contiguous
1197 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is
1198 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive
1199 token to underlying TCP instance. If data arrives in the receive buffer, up to
1200 BodyLength bytes of data will be copied to Body. The HTTP driver will then update
1201 BodyLength with the amount of bytes received and copied to Body.
1202
1203 If the HTTP driver does not have an open underlying TCP connection with the host
1204 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is
1205 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain
1206 an open TCP connection between client and host.
1207
1208 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
1209 @param[in] Token Pointer to storage containing HTTP response token.
1210
1211 @retval EFI_SUCCESS Allocation succeeded.
1212 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been
1213 initialized.
1214 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1215 This is NULL.
1216 Token is NULL.
1217 Token->Message->Headers is NULL.
1218 Token->Message is NULL.
1219 Token->Message->Body is not NULL,
1220 Token->Message->BodyLength is non-zero, and
1221 Token->Message->Data is NULL, but a previous call to
1222 Response() has not been completed successfully.
1223 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
1224 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host
1225 specified by response URL.
1226 **/
1227 EFI_STATUS
1228 EFIAPI
1229 EfiHttpResponse (
1230 IN EFI_HTTP_PROTOCOL *This,
1231 IN EFI_HTTP_TOKEN *Token
1232 )
1233 {
1234 EFI_STATUS Status;
1235 EFI_HTTP_MESSAGE *HttpMsg;
1236 HTTP_PROTOCOL *HttpInstance;
1237 HTTP_TOKEN_WRAP *Wrap;
1238
1239 if ((This == NULL) || (Token == NULL)) {
1240 return EFI_INVALID_PARAMETER;
1241 }
1242
1243 HttpMsg = Token->Message;
1244 if (HttpMsg == NULL) {
1245 return EFI_INVALID_PARAMETER;
1246 }
1247
1248 HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
1249 ASSERT (HttpInstance != NULL);
1250
1251 if (HttpInstance->State != HTTP_STATE_TCP_CONNECTED) {
1252 return EFI_NOT_STARTED;
1253 }
1254
1255 if (HttpInstance->LocalAddressIsIPv6) {
1256 return EFI_UNSUPPORTED;
1257 }
1258
1259 //
1260 // Check whether the token already existed.
1261 //
1262 if (EFI_ERROR (NetMapIterate (&HttpInstance->RxTokens, HttpTokenExist, Token))) {
1263 return EFI_ACCESS_DENIED;
1264 }
1265
1266 Wrap = AllocateZeroPool (sizeof (HTTP_TOKEN_WRAP));
1267 if (Wrap == NULL) {
1268 return EFI_OUT_OF_RESOURCES;
1269 }
1270
1271 Wrap->HttpInstance = HttpInstance;
1272 Wrap->HttpToken = Token;
1273
1274 Status = HttpCreateTcp4RxEvent (Wrap);
1275 if (EFI_ERROR (Status)) {
1276 goto Error;
1277 }
1278
1279 Status = NetMapInsertTail (&HttpInstance->RxTokens, Token, Wrap);
1280 if (EFI_ERROR (Status)) {
1281 goto Error;
1282 }
1283
1284 //
1285 // If already have pending RxTokens, return directly.
1286 //
1287 if (NetMapGetCount (&HttpInstance->RxTokens) > 1) {
1288 return EFI_SUCCESS;
1289 }
1290
1291 return HttpResponseWorker (Wrap);
1292
1293 Error:
1294 if (Wrap != NULL) {
1295 if (Wrap->TcpWrap.RxToken.CompletionToken.Event != NULL) {
1296 gBS->CloseEvent (Wrap->TcpWrap.RxToken.CompletionToken.Event);
1297 }
1298 FreePool (Wrap);
1299 }
1300
1301 return Status;
1302 }
1303
1304 /**
1305 The Poll() function can be used by network drivers and applications to increase the
1306 rate that data packets are moved between the communication devices and the transmit
1307 and receive queues.
1308
1309 In some systems, the periodic timer event in the managed network driver may not poll
1310 the underlying communications device fast enough to transmit and/or receive all data
1311 packets without missing incoming packets or dropping outgoing packets. Drivers and
1312 applications that are experiencing packet loss should try calling the Poll() function
1313 more often.
1314
1315 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
1316
1317 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1318 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1319 @retval EFI_INVALID_PARAMETER This is NULL.
1320 @retval EFI_NOT_READY No incoming or outgoing data is processed.
1321 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
1322
1323 **/
1324 EFI_STATUS
1325 EFIAPI
1326 EfiHttpPoll (
1327 IN EFI_HTTP_PROTOCOL *This
1328 )
1329 {
1330 HTTP_PROTOCOL *HttpInstance;
1331
1332 if (This == NULL) {
1333 return EFI_INVALID_PARAMETER;
1334 }
1335
1336 HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
1337 ASSERT (HttpInstance != NULL);
1338
1339 if (HttpInstance->LocalAddressIsIPv6) {
1340 return EFI_UNSUPPORTED;
1341 }
1342
1343 if (HttpInstance->Tcp4 == NULL || HttpInstance->State != HTTP_STATE_TCP_CONNECTED) {
1344 return EFI_NOT_STARTED;
1345 }
1346
1347 return HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
1348 }