]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/HttpDxe/HttpImpl.c
NetworkPkg: Fix the HttpCloseConnection fail issue
[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 Wrap->TcpWrap.TxToken.CompletionToken.Event = NULL;
520 }
521
522 Error1:
523 if (Url != NULL) {
524 FreePool (Url);
525 }
526 if (HostName != NULL) {
527 FreePool (HostName);
528 }
529 if (Wrap != NULL) {
530 FreePool (Wrap);
531 }
532 if (UrlParser!= NULL) {
533 HttpUrlFreeParser (UrlParser);
534 }
535
536 return Status;
537
538 }
539
540 /**
541 Cancel a TxToken or RxToken.
542
543 @param[in] Map The HTTP instance's token queue.
544 @param[in] Item Object container for one HTTP token and token's wrap.
545 @param[in] Context The user's token to cancel.
546
547 @retval EFI_SUCCESS Continue to check the next Item.
548 @retval EFI_ABORTED The user's Token (Token != NULL) is cancelled.
549
550 **/
551 EFI_STATUS
552 EFIAPI
553 HttpCancelTokens (
554 IN NET_MAP *Map,
555 IN NET_MAP_ITEM *Item,
556 IN VOID *Context
557 )
558 {
559
560 EFI_HTTP_TOKEN *Token;
561 HTTP_TOKEN_WRAP *Wrap;
562
563 Token = (EFI_HTTP_TOKEN *) Context;
564
565 //
566 // Return EFI_SUCCESS to check the next item in the map if
567 // this one doesn't match.
568 //
569 if ((Token != NULL) && (Token != Item->Key)) {
570 return EFI_SUCCESS;
571 }
572
573 Wrap = (HTTP_TOKEN_WRAP *) Item->Value;
574 ASSERT (Wrap != NULL);
575
576 //
577 // Free resources.
578 //
579 NetMapRemoveItem (Map, Item, NULL);
580
581 if (Wrap->TcpWrap.TxToken.CompletionToken.Event != NULL) {
582 gBS->CloseEvent (Wrap->TcpWrap.TxToken.CompletionToken.Event);
583 }
584
585 if (Wrap->TcpWrap.RxToken.CompletionToken.Event != NULL) {
586 gBS->CloseEvent (Wrap->TcpWrap.RxToken.CompletionToken.Event);
587 }
588
589 if (Wrap->TcpWrap.RxToken.Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
590 FreePool (Wrap->TcpWrap.RxToken.Packet.RxData->FragmentTable[0].FragmentBuffer);
591 }
592
593 FreePool (Wrap);
594
595 //
596 // If only one item is to be cancel, return EFI_ABORTED to stop
597 // iterating the map any more.
598 //
599 if (Token != NULL) {
600 return EFI_ABORTED;
601 }
602
603 return EFI_SUCCESS;
604 }
605
606 /**
607 Cancel the user's receive/transmit request. It is the worker function of
608 EfiHttpCancel API. If a matching token is found, it will call HttpCancelTokens to cancel the
609 token.
610
611 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
612 @param[in] Token The token to cancel. If NULL, all token will be
613 cancelled.
614
615 @retval EFI_SUCCESS The token is cancelled.
616 @retval EFI_NOT_FOUND The asynchronous request or response token is not found.
617 @retval Others Other error as indicated.
618
619 **/
620 EFI_STATUS
621 HttpCancel (
622 IN HTTP_PROTOCOL *HttpInstance,
623 IN EFI_HTTP_TOKEN *Token
624 )
625 {
626 EFI_STATUS Status;
627
628 //
629 // First check the tokens queued by EfiHttpRequest().
630 //
631 Status = NetMapIterate (&HttpInstance->TxTokens, HttpCancelTokens, Token);
632 if (EFI_ERROR (Status)) {
633 if (Token != NULL) {
634 if (Status == EFI_ABORTED) {
635 return EFI_SUCCESS;
636 }
637 } else {
638 return Status;
639 }
640 }
641
642 //
643 // Then check the tokens queued by EfiHttpResponse().
644 //
645 Status = NetMapIterate (&HttpInstance->RxTokens, HttpCancelTokens, Token);
646 if (EFI_ERROR (Status)) {
647 if (Token != NULL) {
648 if (Status == EFI_ABORTED) {
649 return EFI_SUCCESS;
650 } else {
651 return EFI_NOT_FOUND;
652 }
653 } else {
654 return Status;
655 }
656 }
657
658 return EFI_SUCCESS;
659 }
660
661
662 /**
663 Abort an asynchronous HTTP request or response token.
664
665 The Cancel() function aborts a pending HTTP request or response transaction. If
666 Token is not NULL and the token is in transmit or receive queues when it is being
667 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will
668 be signaled. If the token is not in one of the queues, which usually means that the
669 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,
670 all asynchronous tokens issued by Request() or Response() will be aborted.
671
672 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
673 @param[in] Token Point to storage containing HTTP request or response
674 token.
675
676 @retval EFI_SUCCESS Request and Response queues are successfully flushed.
677 @retval EFI_INVALID_PARAMETER This is NULL.
678 @retval EFI_NOT_STARTED This instance hasn't been configured.
679 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP,
680 BOOTP, RARP, etc.) hasn't finished yet.
681 @retval EFI_NOT_FOUND The asynchronous request or response token is not
682 found.
683 @retval EFI_UNSUPPORTED The implementation does not support this function.
684
685 **/
686 EFI_STATUS
687 EFIAPI
688 EfiHttpCancel (
689 IN EFI_HTTP_PROTOCOL *This,
690 IN EFI_HTTP_TOKEN *Token
691 )
692 {
693 HTTP_PROTOCOL *HttpInstance;
694
695 if (This == NULL) {
696 return EFI_INVALID_PARAMETER;
697 }
698
699 HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
700 ASSERT (HttpInstance != NULL);
701
702 if (HttpInstance->State != HTTP_STATE_TCP_CONNECTED) {
703 return EFI_NOT_STARTED;
704 }
705
706 return HttpCancel (HttpInstance, Token);
707
708 }
709
710 /**
711 A callback function to intercept events during message parser.
712
713 This function will be invoked during HttpParseMessageBody() with various events type. An error
714 return status of the callback function will cause the HttpParseMessageBody() aborted.
715
716 @param[in] EventType Event type of this callback call.
717 @param[in] Data A pointer to data buffer.
718 @param[in] Length Length in bytes of the Data.
719 @param[in] Context Callback context set by HttpInitMsgParser().
720
721 @retval EFI_SUCCESS Continue to parser the message body.
722
723 **/
724 EFI_STATUS
725 EFIAPI
726 HttpBodyParserCallback (
727 IN HTTP_BODY_PARSE_EVENT EventType,
728 IN CHAR8 *Data,
729 IN UINTN Length,
730 IN VOID *Context
731 )
732 {
733 HTTP_TOKEN_WRAP *Wrap;
734
735 if (EventType != BodyParseEventOnComplete) {
736 return EFI_SUCCESS;
737 }
738
739 if (Data == NULL || Length != 0 || Context == NULL) {
740 return EFI_SUCCESS;
741 }
742
743 Wrap = (HTTP_TOKEN_WRAP *) Context;
744 Wrap->HttpInstance->NextMsg = Data;
745
746 //
747 // Free TxToken since already received corrsponding HTTP response.
748 //
749 FreePool (Wrap);
750
751 return EFI_SUCCESS;
752 }
753
754 /**
755 The work function of EfiHttpResponse().
756
757 @param[in] Wrap Pointer to HTTP token's wrap data.
758
759 @retval EFI_SUCCESS Allocation succeeded.
760 @retval EFI_OUT_OF_RESOURCES Failed to complete the opration due to lack of resources.
761 @retval EFI_NOT_READY Can't find a corresponding TxToken or
762 the EFI_HTTP_UTILITIES_PROTOCOL is not available.
763
764 **/
765 EFI_STATUS
766 HttpResponseWorker (
767 IN HTTP_TOKEN_WRAP *Wrap
768 )
769 {
770 EFI_STATUS Status;
771 EFI_HTTP_MESSAGE *HttpMsg;
772 EFI_TCP4_IO_TOKEN *RxToken;
773 EFI_TCP4_PROTOCOL *Tcp4;
774 CHAR8 *EndofHeader;
775 CHAR8 *HttpHeaders;
776 UINTN SizeofHeaders;
777 CHAR8 *Buffer;
778 UINTN BufferSize;
779 UINTN StatusCode;
780 CHAR8 *Tmp;
781 CHAR8 *HeaderTmp;
782 CHAR8 *StatusCodeStr;
783 UINTN BodyLen;
784 HTTP_PROTOCOL *HttpInstance;
785 EFI_HTTP_TOKEN *Token;
786 NET_MAP_ITEM *Item;
787 HTTP_TOKEN_WRAP *ValueInItem;
788 UINTN HdrLen;
789
790 if (Wrap == NULL || Wrap->HttpInstance == NULL) {
791 return EFI_INVALID_PARAMETER;
792 }
793
794 HttpInstance = Wrap->HttpInstance;
795 Token = Wrap->HttpToken;
796
797 HttpMsg = Token->Message;
798
799 Tcp4 = HttpInstance->Tcp4;
800 ASSERT (Tcp4 != NULL);
801 HttpMsg->Headers = NULL;
802 HttpHeaders = NULL;
803 SizeofHeaders = 0;
804 Buffer = NULL;
805 BufferSize = 0;
806 EndofHeader = NULL;
807
808 if (HttpMsg->Data.Response != NULL) {
809 //
810 // Need receive the HTTP headers, prepare buffer.
811 //
812 Status = HttpCreateTcp4RxEventForHeader (HttpInstance);
813 if (EFI_ERROR (Status)) {
814 goto Error;
815 }
816
817 //
818 // Check whether we have cached header from previous call.
819 //
820 if ((HttpInstance->CacheBody != NULL) && (HttpInstance->NextMsg != NULL)) {
821 //
822 // The data is stored at [NextMsg, CacheBody + CacheLen].
823 //
824 HdrLen = HttpInstance->CacheBody + HttpInstance->CacheLen - HttpInstance->NextMsg;
825 HttpHeaders = AllocateZeroPool (HdrLen);
826 if (HttpHeaders == NULL) {
827 Status = EFI_OUT_OF_RESOURCES;
828 goto Error;
829 }
830
831 CopyMem (HttpHeaders, HttpInstance->NextMsg, HdrLen);
832 FreePool (HttpInstance->CacheBody);
833 HttpInstance->CacheBody = NULL;
834 HttpInstance->NextMsg = NULL;
835 HttpInstance->CacheOffset = 0;
836 SizeofHeaders = HdrLen;
837 BufferSize = HttpInstance->CacheLen;
838
839 //
840 // Check whether we cached the whole HTTP headers.
841 //
842 EndofHeader = AsciiStrStr (HttpHeaders, HTTP_END_OF_HDR_STR);
843 }
844
845 RxToken = &HttpInstance->RxToken;
846 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer = AllocateZeroPool (DEF_BUF_LEN);
847 if (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer == NULL) {
848 Status = EFI_OUT_OF_RESOURCES;
849 goto Error;
850 }
851
852 //
853 // Receive the HTTP headers only when EFI_HTTP_RESPONSE_DATA is not NULL.
854 //
855 while (EndofHeader == NULL) {
856 HttpInstance->IsRxDone = FALSE;
857 RxToken->Packet.RxData->DataLength = DEF_BUF_LEN;
858 RxToken->Packet.RxData->FragmentTable[0].FragmentLength = DEF_BUF_LEN;
859 Status = Tcp4->Receive (Tcp4, RxToken);
860 if (EFI_ERROR (Status)) {
861 DEBUG ((EFI_D_ERROR, "Tcp4 receive failed: %r\n", Status));
862 goto Error;
863 }
864
865 while (!HttpInstance->IsRxDone) {
866 Tcp4->Poll (Tcp4);
867 }
868
869 Status = RxToken->CompletionToken.Status;
870 if (EFI_ERROR (Status)) {
871 goto Error;
872 }
873
874 //
875 // Append the response string.
876 //
877 BufferSize = SizeofHeaders + RxToken->Packet.RxData->FragmentTable[0].FragmentLength;
878 Buffer = AllocateZeroPool (BufferSize);
879 if (Buffer == NULL) {
880 Status = EFI_OUT_OF_RESOURCES;
881 goto Error;
882 }
883
884 if (HttpHeaders != NULL) {
885 CopyMem (Buffer, HttpHeaders, SizeofHeaders);
886 FreePool (HttpHeaders);
887 }
888
889 CopyMem (
890 Buffer + SizeofHeaders,
891 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer,
892 RxToken->Packet.RxData->FragmentTable[0].FragmentLength
893 );
894 HttpHeaders = Buffer;
895 SizeofHeaders = BufferSize;
896
897 //
898 // Check whether we received end of HTTP headers.
899 //
900 EndofHeader = AsciiStrStr (HttpHeaders, HTTP_END_OF_HDR_STR);
901 };
902
903 //
904 // Skip the CRLF after the HTTP headers.
905 //
906 EndofHeader = EndofHeader + AsciiStrLen (HTTP_END_OF_HDR_STR);
907
908 //
909 // Cache the part of body.
910 //
911 BodyLen = BufferSize - (EndofHeader - HttpHeaders);
912 if (BodyLen > 0) {
913 if (HttpInstance->CacheBody != NULL) {
914 FreePool (HttpInstance->CacheBody);
915 }
916
917 HttpInstance->CacheBody = AllocateZeroPool (BodyLen);
918 if (HttpInstance->CacheBody == NULL) {
919 Status = EFI_OUT_OF_RESOURCES;
920 goto Error;
921 }
922
923 CopyMem (HttpInstance->CacheBody, EndofHeader, BodyLen);
924 HttpInstance->CacheLen = BodyLen;
925 }
926
927 FreePool (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer);
928 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
929
930 //
931 // Search for Status Code.
932 //
933 StatusCodeStr = HttpHeaders + AsciiStrLen (HTTP_VERSION_STR) + 1;
934 if (StatusCodeStr == NULL) {
935 goto Error;
936 }
937
938 StatusCode = AsciiStrDecimalToUintn (StatusCodeStr);
939
940 //
941 // Remove the first line of HTTP message, e.g. "HTTP/1.1 200 OK\r\n".
942 //
943 Tmp = AsciiStrStr (HttpHeaders, HTTP_CRLF_STR);
944 if (Tmp == NULL) {
945 goto Error;
946 }
947
948 Tmp = Tmp + AsciiStrLen (HTTP_CRLF_STR);
949 SizeofHeaders = SizeofHeaders - (Tmp - HttpHeaders);
950 HeaderTmp = AllocateZeroPool (SizeofHeaders);
951 if (HeaderTmp == NULL) {
952 goto Error;
953 }
954
955 CopyMem (HeaderTmp, Tmp, SizeofHeaders);
956 FreePool (HttpHeaders);
957 HttpHeaders = HeaderTmp;
958
959 //
960 // Check whether the EFI_HTTP_UTILITIES_PROTOCOL is available.
961 //
962 if (mHttpUtilities == NULL) {
963 Status = EFI_NOT_READY;
964 goto Error;
965 }
966
967 //
968 // Parse the HTTP header into array of key/value pairs.
969 //
970 Status = mHttpUtilities->Parse (
971 mHttpUtilities,
972 HttpHeaders,
973 SizeofHeaders,
974 &HttpMsg->Headers,
975 &HttpMsg->HeaderCount
976 );
977 if (EFI_ERROR (Status)) {
978 goto Error;
979 }
980
981 FreePool (HttpHeaders);
982 HttpHeaders = NULL;
983
984 HttpMsg->Data.Response->StatusCode = HttpMappingToStatusCode (StatusCode);
985
986 //
987 // Init message-body parser by header information.
988 //
989 Status = EFI_NOT_READY;
990 ValueInItem = NULL;
991 NetMapRemoveHead (&HttpInstance->TxTokens, (VOID**) &ValueInItem);
992 if (ValueInItem == NULL) {
993 goto Error;
994 }
995
996 //
997 // The first TxToken not transmitted yet, insert back and return error.
998 //
999 if (!ValueInItem->TcpWrap.IsTxDone) {
1000 goto Error2;
1001 }
1002
1003 Status = HttpInitMsgParser (
1004 ValueInItem->TcpWrap.Method,
1005 HttpMsg->Data.Response->StatusCode,
1006 HttpMsg->HeaderCount,
1007 HttpMsg->Headers,
1008 HttpBodyParserCallback,
1009 (VOID *) ValueInItem,
1010 &HttpInstance->MsgParser
1011 );
1012 if (EFI_ERROR (Status)) {
1013 goto Error2;
1014 }
1015
1016 //
1017 // Check whether we received a complete HTTP message.
1018 //
1019 if (HttpInstance->CacheBody != NULL) {
1020 Status = HttpParseMessageBody (HttpInstance->MsgParser, HttpInstance->CacheLen, HttpInstance->CacheBody);
1021 if (EFI_ERROR (Status)) {
1022 goto Error2;
1023 }
1024
1025 if (HttpIsMessageComplete (HttpInstance->MsgParser)) {
1026 //
1027 // Free the MsgParse since we already have a full HTTP message.
1028 //
1029 HttpFreeMsgParser (HttpInstance->MsgParser);
1030 HttpInstance->MsgParser = NULL;
1031 }
1032 }
1033
1034 if ((HttpMsg->Body == NULL) || (HttpMsg->BodyLength == 0)) {
1035 Status = EFI_SUCCESS;
1036 goto Exit;
1037 }
1038 }
1039
1040 //
1041 // Receive the response body.
1042 //
1043 BodyLen = 0;
1044
1045 //
1046 // First check whether we cached some data.
1047 //
1048 if (HttpInstance->CacheBody != NULL) {
1049 //
1050 // Calculate the length of the cached data.
1051 //
1052 if (HttpInstance->NextMsg != NULL) {
1053 //
1054 // We have a cached HTTP message which includes a part of HTTP header of next message.
1055 //
1056 BodyLen = HttpInstance->NextMsg - (HttpInstance->CacheBody + HttpInstance->CacheOffset);
1057 } else {
1058 BodyLen = HttpInstance->CacheLen - HttpInstance->CacheOffset;
1059 }
1060
1061 if (BodyLen > 0) {
1062 //
1063 // We have some cached data. Just copy the data and return.
1064 //
1065 if (HttpMsg->BodyLength < BodyLen) {
1066 CopyMem (HttpMsg->Body, HttpInstance->CacheBody + HttpInstance->CacheOffset, HttpMsg->BodyLength);
1067 HttpInstance->CacheOffset = HttpInstance->CacheOffset + HttpMsg->BodyLength;
1068 } else {
1069 //
1070 // Copy all cached data out.
1071 //
1072 CopyMem (HttpMsg->Body, HttpInstance->CacheBody + HttpInstance->CacheOffset, BodyLen);
1073 HttpInstance->CacheOffset = BodyLen + HttpInstance->CacheOffset;
1074 HttpMsg->BodyLength = BodyLen;
1075
1076 if (HttpInstance->NextMsg == NULL) {
1077 //
1078 // There is no HTTP header of next message. Just free the cache buffer.
1079 //
1080 FreePool (HttpInstance->CacheBody);
1081 HttpInstance->CacheBody = NULL;
1082 HttpInstance->NextMsg = NULL;
1083 HttpInstance->CacheOffset = 0;
1084 }
1085 }
1086 //
1087 // Return since we aready received required data.
1088 //
1089 Status = EFI_SUCCESS;
1090 goto Exit;
1091 }
1092
1093 if (BodyLen == 0 && HttpInstance->MsgParser == NULL) {
1094 //
1095 // We received a complete HTTP message, and we don't have more data to return to caller.
1096 //
1097 HttpMsg->BodyLength = 0;
1098 Status = EFI_SUCCESS;
1099 goto Exit;
1100 }
1101 }
1102
1103 ASSERT (HttpInstance->MsgParser != NULL);
1104
1105 //
1106 // We still need receive more data when there is no cache data and MsgParser is not NULL;
1107 //
1108 RxToken = &Wrap->TcpWrap.RxToken;
1109
1110 RxToken->Packet.RxData->DataLength = (UINT32) HttpMsg->BodyLength;
1111 RxToken->Packet.RxData->FragmentTable[0].FragmentLength = (UINT32) HttpMsg->BodyLength;
1112 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer = (VOID *) HttpMsg->Body;
1113
1114 RxToken->CompletionToken.Status = EFI_NOT_READY;
1115 Status = Tcp4->Receive (Tcp4, RxToken);
1116 if (EFI_ERROR (Status)) {
1117 DEBUG ((EFI_D_ERROR, "Tcp4 receive failed: %r\n", Status));
1118 goto Error;
1119 }
1120
1121 return Status;
1122
1123 Exit:
1124 Item = NetMapFindKey (&Wrap->HttpInstance->RxTokens, Wrap->HttpToken);
1125 if (Item != NULL) {
1126 NetMapRemoveItem (&Wrap->HttpInstance->RxTokens, Item, NULL);
1127 }
1128 Token->Status = Status;
1129 gBS->SignalEvent (Token->Event);
1130 FreePool (Wrap);
1131 return Status;
1132
1133 Error2:
1134 NetMapInsertHead (&HttpInstance->TxTokens, ValueInItem->HttpToken, ValueInItem);
1135
1136 Error:
1137 if (Wrap != NULL) {
1138 if (Wrap->TcpWrap.RxToken.CompletionToken.Event != NULL) {
1139 gBS->CloseEvent (Wrap->TcpWrap.RxToken.CompletionToken.Event);
1140 }
1141 RxToken = &Wrap->TcpWrap.RxToken;
1142 if (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
1143 FreePool (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer);
1144 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
1145 }
1146 FreePool (Wrap);
1147 }
1148
1149 if (HttpInstance->RxToken.CompletionToken.Event != NULL) {
1150 gBS->CloseEvent (HttpInstance->RxToken.CompletionToken.Event);
1151 HttpInstance->RxToken.CompletionToken.Event = NULL;
1152 }
1153
1154 RxToken = &HttpInstance->RxToken;
1155 if (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer != NULL) {
1156 FreePool (RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer);
1157 RxToken->Packet.RxData->FragmentTable[0].FragmentBuffer = NULL;
1158 }
1159
1160 if (HttpHeaders != NULL) {
1161 FreePool (HttpHeaders);
1162 }
1163
1164 if (HttpMsg->Headers != NULL) {
1165 FreePool (HttpMsg->Headers);
1166 }
1167
1168 if (HttpInstance->CacheBody != NULL) {
1169 FreePool (HttpInstance->CacheBody);
1170 HttpInstance->CacheBody = NULL;
1171 }
1172
1173 Token->Status = Status;
1174 gBS->SignalEvent (Token->Event);
1175
1176 return Status;
1177
1178 }
1179
1180
1181 /**
1182 The Response() function queues an HTTP response to this HTTP instance, similar to
1183 Receive() function in the EFI TCP driver. When the HTTP request is sent successfully,
1184 or if there is an error, Status in token will be updated and Event will be signaled.
1185
1186 The HTTP driver will queue a receive token to the underlying TCP instance. When data
1187 is received in the underlying TCP instance, the data will be parsed and Token will
1188 be populated with the response data. If the data received from the remote host
1189 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting
1190 (asynchronously) for more data to be sent from the remote host before signaling
1191 Event in Token.
1192
1193 It is the responsibility of the caller to allocate a buffer for Body and specify the
1194 size in BodyLength. If the remote host provides a response that contains a content
1195 body, up to BodyLength bytes will be copied from the receive buffer into Body and
1196 BodyLength will be updated with the amount of bytes received and copied to Body. This
1197 allows the client to download a large file in chunks instead of into one contiguous
1198 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is
1199 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive
1200 token to underlying TCP instance. If data arrives in the receive buffer, up to
1201 BodyLength bytes of data will be copied to Body. The HTTP driver will then update
1202 BodyLength with the amount of bytes received and copied to Body.
1203
1204 If the HTTP driver does not have an open underlying TCP connection with the host
1205 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is
1206 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain
1207 an open TCP connection between client and host.
1208
1209 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
1210 @param[in] Token Pointer to storage containing HTTP response token.
1211
1212 @retval EFI_SUCCESS Allocation succeeded.
1213 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been
1214 initialized.
1215 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
1216 This is NULL.
1217 Token is NULL.
1218 Token->Message->Headers is NULL.
1219 Token->Message is NULL.
1220 Token->Message->Body is not NULL,
1221 Token->Message->BodyLength is non-zero, and
1222 Token->Message->Data is NULL, but a previous call to
1223 Response() has not been completed successfully.
1224 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
1225 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host
1226 specified by response URL.
1227 **/
1228 EFI_STATUS
1229 EFIAPI
1230 EfiHttpResponse (
1231 IN EFI_HTTP_PROTOCOL *This,
1232 IN EFI_HTTP_TOKEN *Token
1233 )
1234 {
1235 EFI_STATUS Status;
1236 EFI_HTTP_MESSAGE *HttpMsg;
1237 HTTP_PROTOCOL *HttpInstance;
1238 HTTP_TOKEN_WRAP *Wrap;
1239
1240 if ((This == NULL) || (Token == NULL)) {
1241 return EFI_INVALID_PARAMETER;
1242 }
1243
1244 HttpMsg = Token->Message;
1245 if (HttpMsg == NULL) {
1246 return EFI_INVALID_PARAMETER;
1247 }
1248
1249 HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
1250 ASSERT (HttpInstance != NULL);
1251
1252 if (HttpInstance->State != HTTP_STATE_TCP_CONNECTED) {
1253 return EFI_NOT_STARTED;
1254 }
1255
1256 if (HttpInstance->LocalAddressIsIPv6) {
1257 return EFI_UNSUPPORTED;
1258 }
1259
1260 //
1261 // Check whether the token already existed.
1262 //
1263 if (EFI_ERROR (NetMapIterate (&HttpInstance->RxTokens, HttpTokenExist, Token))) {
1264 return EFI_ACCESS_DENIED;
1265 }
1266
1267 Wrap = AllocateZeroPool (sizeof (HTTP_TOKEN_WRAP));
1268 if (Wrap == NULL) {
1269 return EFI_OUT_OF_RESOURCES;
1270 }
1271
1272 Wrap->HttpInstance = HttpInstance;
1273 Wrap->HttpToken = Token;
1274
1275 Status = HttpCreateTcp4RxEvent (Wrap);
1276 if (EFI_ERROR (Status)) {
1277 goto Error;
1278 }
1279
1280 Status = NetMapInsertTail (&HttpInstance->RxTokens, Token, Wrap);
1281 if (EFI_ERROR (Status)) {
1282 goto Error;
1283 }
1284
1285 //
1286 // If already have pending RxTokens, return directly.
1287 //
1288 if (NetMapGetCount (&HttpInstance->RxTokens) > 1) {
1289 return EFI_SUCCESS;
1290 }
1291
1292 return HttpResponseWorker (Wrap);
1293
1294 Error:
1295 if (Wrap != NULL) {
1296 if (Wrap->TcpWrap.RxToken.CompletionToken.Event != NULL) {
1297 gBS->CloseEvent (Wrap->TcpWrap.RxToken.CompletionToken.Event);
1298 }
1299 FreePool (Wrap);
1300 }
1301
1302 return Status;
1303 }
1304
1305 /**
1306 The Poll() function can be used by network drivers and applications to increase the
1307 rate that data packets are moved between the communication devices and the transmit
1308 and receive queues.
1309
1310 In some systems, the periodic timer event in the managed network driver may not poll
1311 the underlying communications device fast enough to transmit and/or receive all data
1312 packets without missing incoming packets or dropping outgoing packets. Drivers and
1313 applications that are experiencing packet loss should try calling the Poll() function
1314 more often.
1315
1316 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
1317
1318 @retval EFI_SUCCESS Incoming or outgoing data was processed.
1319 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
1320 @retval EFI_INVALID_PARAMETER This is NULL.
1321 @retval EFI_NOT_READY No incoming or outgoing data is processed.
1322 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
1323
1324 **/
1325 EFI_STATUS
1326 EFIAPI
1327 EfiHttpPoll (
1328 IN EFI_HTTP_PROTOCOL *This
1329 )
1330 {
1331 HTTP_PROTOCOL *HttpInstance;
1332
1333 if (This == NULL) {
1334 return EFI_INVALID_PARAMETER;
1335 }
1336
1337 HttpInstance = HTTP_INSTANCE_FROM_PROTOCOL (This);
1338 ASSERT (HttpInstance != NULL);
1339
1340 if (HttpInstance->LocalAddressIsIPv6) {
1341 return EFI_UNSUPPORTED;
1342 }
1343
1344 if (HttpInstance->Tcp4 == NULL || HttpInstance->State != HTTP_STATE_TCP_CONNECTED) {
1345 return EFI_NOT_STARTED;
1346 }
1347
1348 return HttpInstance->Tcp4->Poll (HttpInstance->Tcp4);
1349 }