Implementation of EFI_HTTP_PROTOCOL protocol interfaces.\r
\r
Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
+ (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
sizeof (HttpInstance->IPv4Node)\r
);\r
}\r
+ \r
//\r
// Creat Tcp child\r
//\r
HTTP_PROTOCOL *HttpInstance;\r
BOOLEAN Configure;\r
BOOLEAN ReConfigure;\r
- CHAR8 *RequestStr;\r
+ CHAR8 *RequestMsg;\r
CHAR8 *Url;\r
UINTN UrlLen;\r
CHAR16 *HostNameStr;\r
HTTP_TOKEN_WRAP *Wrap;\r
CHAR8 *FileUrl;\r
+ UINTN RequestMsgSize;\r
\r
if ((This == NULL) || (Token == NULL)) {\r
return EFI_INVALID_PARAMETER;\r
goto Error1;\r
}\r
\r
- RequestStr = NULL;\r
+ RequestMsg = NULL;\r
HostName = NULL;\r
Status = HttpUrlGetHostName (Url, UrlParser, &HostName);\r
if (EFI_ERROR (Status)) {\r
goto Error3;\r
}\r
}\r
- RequestStr = HttpGenRequestString (HttpInstance, HttpMsg, FileUrl);\r
- if (RequestStr == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
+\r
+ Status = HttpGenRequestMessage (HttpMsg, FileUrl, &RequestMsg, &RequestMsgSize);\r
+\r
+ if (EFI_ERROR (Status)) {\r
goto Error3;\r
}\r
\r
Status = HttpTransmitTcp (\r
HttpInstance,\r
Wrap,\r
- (UINT8*) RequestStr,\r
- AsciiStrLen (RequestStr)\r
+ (UINT8*) RequestMsg,\r
+ RequestMsgSize\r
);\r
if (EFI_ERROR (Status)) {\r
goto Error5; \r
NetMapRemoveTail (&HttpInstance->TxTokens, NULL);\r
\r
Error4:\r
- if (RequestStr != NULL) {\r
- FreePool (RequestStr);\r
+ if (RequestMsg != NULL) {\r
+ FreePool (RequestMsg);\r
} \r
\r
Error3:\r
HttpInstance->EndofHeader = &EndofHeader;\r
HttpInstance->HttpHeaders = &HttpHeaders;\r
\r
- Status = HttpTcpReceiveHeader (HttpInstance, &SizeofHeaders, &BufferSize);\r
+\r
+ if (HttpInstance->TimeoutEvent == NULL) {\r
+ //\r
+ // Create TimeoutEvent for response\r
+ //\r
+ Status = gBS->CreateEvent (\r
+ EVT_TIMER,\r
+ TPL_CALLBACK,\r
+ NULL,\r
+ NULL,\r
+ &HttpInstance->TimeoutEvent\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Start the timer, and wait Timeout seconds to receive the header packet.\r
+ //\r
+ Status = gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, HTTP_RESPONSE_TIMEOUT * TICKS_PER_SECOND);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
+ Status = HttpTcpReceiveHeader (HttpInstance, &SizeofHeaders, &BufferSize, HttpInstance->TimeoutEvent);\r
+\r
+ gBS->SetTimer (HttpInstance->TimeoutEvent, TimerCancel, 0);\r
+\r
if (EFI_ERROR (Status)) {\r
goto Error;\r
}\r
\r
ASSERT (HttpInstance->MsgParser != NULL);\r
\r
+ if (HttpInstance->TimeoutEvent == NULL) {\r
+ //\r
+ // Create TimeoutEvent for response\r
+ //\r
+ Status = gBS->CreateEvent (\r
+ EVT_TIMER,\r
+ TPL_CALLBACK,\r
+ NULL,\r
+ NULL,\r
+ &HttpInstance->TimeoutEvent\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Start the timer, and wait Timeout seconds to receive the body packet.\r
+ //\r
+ Status = gBS->SetTimer (HttpInstance->TimeoutEvent, TimerRelative, HTTP_RESPONSE_TIMEOUT * TICKS_PER_SECOND);\r
+ if (EFI_ERROR (Status)) {\r
+ goto Error;\r
+ }\r
+\r
//\r
// We still need receive more data when there is no cache data and MsgParser is not NULL;\r
//\r
- Status = HttpTcpReceiveBody (Wrap, HttpMsg);\r
+ Status = HttpTcpReceiveBody (Wrap, HttpMsg, HttpInstance->TimeoutEvent);\r
+\r
+ gBS->SetTimer (HttpInstance->TimeoutEvent, TimerCancel, 0);\r
+\r
if (EFI_ERROR (Status)) {\r
goto Error;\r
}\r