}\r
\r
CallbackData = (HTTP_BOOT_CALLBACK_DATA *) Context;\r
-\r
- //\r
- // Save the data into cache list.\r
- //\r
- NewEntityData = AllocatePool (sizeof (HTTP_BOOT_ENTITY_DATA));\r
- if (NewEntityData == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- if (CallbackData->NewBlock) {\r
- NewEntityData->Block = CallbackData->Block;\r
- CallbackData->Block = NULL;\r
- }\r
- NewEntityData->DataLength = Length;\r
- NewEntityData->DataStart = (UINT8*) Data;\r
- InsertTailList (&CallbackData->Cache->EntityDataList, &NewEntityData->Link);\r
-\r
//\r
// Copy data if caller has provided a buffer.\r
//\r
CallbackData->CopyedSize += MIN (Length, CallbackData->BufferSize - CallbackData->CopyedSize);\r
}\r
\r
+ //\r
+ // The caller doesn't provide a buffer, save the block into cache list.\r
+ //\r
+ if (CallbackData->Cache != NULL) {\r
+ NewEntityData = AllocatePool (sizeof (HTTP_BOOT_ENTITY_DATA));\r
+ if (NewEntityData == NULL) {\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+ if (CallbackData->NewBlock) {\r
+ NewEntityData->Block = CallbackData->Block;\r
+ CallbackData->Block = NULL;\r
+ }\r
+ NewEntityData->DataLength = Length;\r
+ NewEntityData->DataStart = (UINT8*) Data;\r
+ InsertTailList (&CallbackData->Cache->EntityDataList, &NewEntityData->Link);\r
+ }\r
return EFI_SUCCESS;\r
}\r
\r
//\r
\r
//\r
- // 1. Create a temp cache item for the requested URI.\r
+ // 1. Create a temp cache item for the requested URI if caller doesn't provide buffer.\r
//\r
Cache = NULL;\r
- if (!HeaderOnly) {\r
+ if ((!HeaderOnly) && (*BufferSize == 0)) {\r
Cache = AllocateZeroPool (sizeof (HTTP_BOOT_CACHE_CONTENT));\r
if (Cache == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
//\r
// 2.3 Record the request info in a temp cache item.\r
//\r
- if (!HeaderOnly) {\r
+ if (Cache != NULL) {\r
Cache->RequestData = RequestData;\r
}\r
\r
//\r
// 3.2 Cache the response header.\r
//\r
- if (!HeaderOnly) {\r
+ if (Cache != NULL) {\r
Cache->ResponseData = ResponseData;\r
}\r
\r
//\r
// 3.4 Continue to receive and parse message-body if needed.\r
//\r
+ Block = NULL;\r
if (!HeaderOnly) {\r
ZeroMem (&ResponseBody, sizeof (HTTP_IO_RESOPNSE_DATA));\r
while (!HttpIsMessageComplete (Parser)) {\r
//\r
- // Allocate a new block to hold the message-body.\r
+ // Allocate a block to hold the message-body, if caller doesn't provide\r
+ // a buffer, the block will be cached and we will allocate a new one here.\r
//\r
- Block = AllocatePool (HTTP_BOOT_BLOCK_SIZE);\r
- if (Block == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto ERROR_6;\r
+ if (Block == NULL || Context.BufferSize == 0) {\r
+ Block = AllocatePool (HTTP_BOOT_BLOCK_SIZE);\r
+ if (Block == NULL) {\r
+ Status = EFI_OUT_OF_RESOURCES;\r
+ goto ERROR_6;\r
+ }\r
+ Context.NewBlock = TRUE;\r
+ Context.Block = Block;\r
+ } else {\r
+ Context.NewBlock = FALSE;\r
}\r
+\r
ResponseBody.Body = (CHAR8*) Block;\r
ResponseBody.BodyLength = HTTP_BOOT_BLOCK_SIZE;\r
Status = HttpIoRecvResponse (\r
//\r
// Parse the new received block of the message-body, the block will be saved in cache.\r
//\r
- Context.NewBlock = TRUE;\r
- Context.Block = Block;\r
Status = HttpParseMessageBody (\r
Parser,\r
ResponseBody.BodyLength,\r
//\r
// 4. Save the cache item to driver's cache list and return.\r
//\r
- if (!HeaderOnly) {\r
+ if (Cache != NULL) {\r
Cache->EntityLength = ContentLength;\r
InsertTailList (&Private->CacheList, &Cache->Link);\r
}\r