IN VOID *Context\r
)\r
{\r
+ HTTP_CALLBACK_DATA *CallbackData;\r
HTTP_TOKEN_WRAP *Wrap;\r
UINTN BodyLength;\r
CHAR8 *Body;\r
return EFI_SUCCESS;\r
}\r
\r
- Wrap = (HTTP_TOKEN_WRAP *) Context;\r
- Body = Wrap->HttpToken->Message->Body;\r
- BodyLength = Wrap->HttpToken->Message->BodyLength;\r
+ CallbackData = (HTTP_CALLBACK_DATA *) Context;\r
+\r
+ Wrap = (HTTP_TOKEN_WRAP *) (CallbackData->Wrap);\r
+ Body = CallbackData->ParseData;\r
+ BodyLength = CallbackData->ParseDataLength;\r
+\r
if (Data < Body + BodyLength) {\r
Wrap->HttpInstance->NextMsg = Data;\r
} else {\r
Wrap->HttpInstance->NextMsg = NULL;\r
}\r
\r
-\r
- //\r
- // Free Tx4Token or Tx6Token since already received corrsponding HTTP response.\r
- //\r
- FreePool (Wrap);\r
-\r
return EFI_SUCCESS;\r
}\r
\r
HttpMsg->HeaderCount,\r
HttpMsg->Headers,\r
HttpBodyParserCallback,\r
- (VOID *) ValueInItem,\r
+ (VOID *) (&HttpInstance->CallbackData),\r
&HttpInstance->MsgParser\r
);\r
if (EFI_ERROR (Status)) {\r
// Check whether we received a complete HTTP message.\r
//\r
if (HttpInstance->CacheBody != NULL) {\r
+ //\r
+ // Record the CallbackData data.\r
+ //\r
+ HttpInstance->CallbackData.Wrap = (VOID *) Wrap;\r
+ HttpInstance->CallbackData.ParseData = (VOID *) HttpInstance->CacheBody;\r
+ HttpInstance->CallbackData.ParseDataLength = HttpInstance->CacheLen;\r
+\r
+ //\r
+ // Parse message with CallbackData data.\r
+ //\r
Status = HttpParseMessageBody (HttpInstance->MsgParser, HttpInstance->CacheLen, HttpInstance->CacheBody);\r
if (EFI_ERROR (Status)) {\r
goto Error2;\r
}\r
+ }\r
\r
- if (HttpIsMessageComplete (HttpInstance->MsgParser)) {\r
- //\r
- // Free the MsgParse since we already have a full HTTP message.\r
- //\r
- HttpFreeMsgParser (HttpInstance->MsgParser);\r
- HttpInstance->MsgParser = NULL;\r
- }\r
+ if (HttpIsMessageComplete (HttpInstance->MsgParser)) {\r
+ //\r
+ // Free the MsgParse since we already have a full HTTP message.\r
+ //\r
+ HttpFreeMsgParser (HttpInstance->MsgParser);\r
+ HttpInstance->MsgParser = NULL;\r
}\r
}\r
\r
}\r
\r
//\r
- // Check whether we receive a complete HTTP message.\r
+ // Process the received the body packet.\r
+ //\r
+ HttpMsg->BodyLength = MIN (Fragment.Len, (UINT32) HttpMsg->BodyLength);\r
+\r
+ CopyMem (HttpMsg->Body, Fragment.Bulk, HttpMsg->BodyLength);\r
+\r
+ //\r
+ // Record the CallbackData data.\r
+ //\r
+ HttpInstance->CallbackData.Wrap = (VOID *) Wrap;\r
+ HttpInstance->CallbackData.ParseData = HttpMsg->Body;\r
+ HttpInstance->CallbackData.ParseDataLength = HttpMsg->BodyLength;\r
+\r
+ //\r
+ // Parse Body with CallbackData data.\r
//\r
Status = HttpParseMessageBody (\r
HttpInstance->MsgParser,\r
- (UINTN) Fragment.Len,\r
- (CHAR8 *) Fragment.Bulk\r
+ HttpMsg->BodyLength,\r
+ HttpMsg->Body\r
);\r
if (EFI_ERROR (Status)) {\r
goto Error2;\r
}\r
\r
//\r
- // We receive part of header of next HTTP msg.\r
+ // Check whether there is the next message header in the HttpMsg->Body.\r
//\r
if (HttpInstance->NextMsg != NULL) {\r
- HttpMsg->BodyLength = MIN ((UINTN) HttpInstance->NextMsg - (UINTN) Fragment.Bulk, HttpMsg->BodyLength);\r
- CopyMem (HttpMsg->Body, Fragment.Bulk, HttpMsg->BodyLength);\r
-\r
- HttpInstance->CacheLen = Fragment.Len - HttpMsg->BodyLength;\r
- if (HttpInstance->CacheLen != 0) {\r
- if (HttpInstance->CacheBody != NULL) {\r
- FreePool (HttpInstance->CacheBody);\r
- }\r
-\r
- HttpInstance->CacheBody = AllocateZeroPool (HttpInstance->CacheLen);\r
- if (HttpInstance->CacheBody == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Error2;\r
- }\r
-\r
- CopyMem (HttpInstance->CacheBody, Fragment.Bulk + HttpMsg->BodyLength, HttpInstance->CacheLen);\r
- HttpInstance->CacheOffset = 0;\r
+ HttpMsg->BodyLength = HttpInstance->NextMsg - (CHAR8 *) HttpMsg->Body;\r
+ }\r
\r
- HttpInstance->NextMsg = HttpInstance->CacheBody + ((UINTN) HttpInstance->NextMsg - (UINTN) (Fragment.Bulk + HttpMsg->BodyLength));\r
+ HttpInstance->CacheLen = Fragment.Len - HttpMsg->BodyLength;\r
+ if (HttpInstance->CacheLen != 0) {\r
+ if (HttpInstance->CacheBody != NULL) {\r
+ FreePool (HttpInstance->CacheBody);\r
}\r
- } else {\r
- HttpMsg->BodyLength = MIN (Fragment.Len, (UINT32) HttpMsg->BodyLength);\r
- CopyMem (HttpMsg->Body, Fragment.Bulk, HttpMsg->BodyLength);\r
- HttpInstance->CacheLen = Fragment.Len - HttpMsg->BodyLength;\r
- if (HttpInstance->CacheLen != 0) {\r
- if (HttpInstance->CacheBody != NULL) {\r
- FreePool (HttpInstance->CacheBody);\r
- }\r
\r
- HttpInstance->CacheBody = AllocateZeroPool (HttpInstance->CacheLen);\r
- if (HttpInstance->CacheBody == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Error2;\r
- }\r
+ HttpInstance->CacheBody = AllocateZeroPool (HttpInstance->CacheLen);\r
+ if (HttpInstance->CacheBody == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto Error2;\r
+ }\r
\r
- CopyMem (HttpInstance->CacheBody, Fragment.Bulk + HttpMsg->BodyLength, HttpInstance->CacheLen);\r
- HttpInstance->CacheOffset = 0;\r
+ CopyMem (HttpInstance->CacheBody, Fragment.Bulk + HttpMsg->BodyLength, HttpInstance->CacheLen);\r
+ HttpInstance->CacheOffset = 0;\r
+ if (HttpInstance->NextMsg != NULL) {\r
+ HttpInstance->NextMsg = HttpInstance->CacheBody;\r
}\r
}\r
\r