);\r
\r
/**\r
- Generate HTTP request string.\r
+ Generate HTTP request message.\r
\r
- @param[in] Message Pointer to storage containing HTTP message data.\r
+ This function will allocate memory for the whole HTTP message and generate a\r
+ well formatted HTTP Request message in it, include the Request-Line, header\r
+ fields and also the message body. It is the caller's responsibility to free\r
+ the buffer returned in *RequestMsg.\r
+\r
+ @param[in] Message Pointer to the EFI_HTTP_MESSAGE structure which\r
+ contains the required information to generate\r
+ the HTTP request message.\r
@param[in] Url The URL of a remote host.\r
- @param[out] RequestString Pointer to the created HTTP request string.\r
+ @param[out] RequestMsg Pointer to the created HTTP request message.\r
NULL if any error occured.\r
+ @param[out] RequestMsgSize Size of the RequestMsg (in bytes).\r
\r
@return EFI_SUCCESS If HTTP request string was created successfully\r
@retval EFI_OUT_OF_RESOURCES Failed to allocate resources.\r
**/\r
EFI_STATUS\r
EFIAPI\r
-HttpGenRequestString (\r
+HttpGenRequestMessage (\r
IN CONST EFI_HTTP_MESSAGE *Message,\r
IN CONST CHAR8 *Url,\r
- OUT CHAR8 **RequestString\r
+ OUT CHAR8 **RequestMsg,\r
+ OUT UINTN *RequestMsgSize\r
);\r
\r
/**\r
}\r
\r
/**\r
- Generate HTTP request string.\r
+ Generate HTTP request message.\r
\r
- @param[in] Message Pointer to storage containing HTTP message data.\r
+ This function will allocate memory for the whole HTTP message and generate a\r
+ well formatted HTTP Request message in it, include the Request-Line, header\r
+ fields and also the message body. It is the caller's responsibility to free\r
+ the buffer returned in *RequestMsg.\r
+\r
+ @param[in] Message Pointer to the EFI_HTTP_MESSAGE structure which\r
+ contains the required information to generate\r
+ the HTTP request message.\r
@param[in] Url The URL of a remote host.\r
- @param[out] RequestString Pointer to the created HTTP request string.\r
+ @param[out] RequestMsg Pointer to the created HTTP request message.\r
NULL if any error occured.\r
+ @param[out] RequestMsgSize Size of the RequestMsg (in bytes).\r
\r
@return EFI_SUCCESS If HTTP request string was created successfully\r
@retval EFI_OUT_OF_RESOURCES Failed to allocate resources.\r
**/\r
EFI_STATUS\r
EFIAPI\r
-HttpGenRequestString (\r
+HttpGenRequestMessage (\r
IN CONST EFI_HTTP_MESSAGE *Message,\r
IN CONST CHAR8 *Url,\r
- OUT CHAR8 **Request\r
+ OUT CHAR8 **RequestMsg,\r
+ OUT UINTN *RequestMsgSize\r
)\r
{\r
EFI_STATUS Status;\r
\r
ASSERT (Message != NULL);\r
\r
- *Request = NULL;\r
+ *RequestMsg = NULL;\r
MsgSize = 0;\r
Success = FALSE;\r
HttpHdr = NULL;\r
AsciiStrLen (HTTP_VERSION_CRLF_STR) + HttpHdrSize;\r
\r
\r
- *Request = AllocateZeroPool (MsgSize);\r
- if (*Request == NULL) {\r
+ *RequestMsg = AllocateZeroPool (MsgSize);\r
+ if (*RequestMsg == NULL) {\r
Status = EFI_OUT_OF_RESOURCES;\r
goto Exit;\r
}\r
\r
- RequestPtr = *Request;\r
+ RequestPtr = *RequestMsg;\r
//\r
// Construct header request\r
//\r
CopyMem (RequestPtr, HttpHdr, HttpHdrSize);\r
RequestPtr += HttpHdrSize;\r
\r
+ //\r
+ // Construct body\r
+ //\r
+ if (Message->Body != NULL) {\r
+ CopyMem (RequestPtr, Message->Body, Message->BodyLength);\r
+ RequestPtr += Message->BodyLength;\r
+ }\r
+\r
//\r
// Done\r
//\r
- *RequestPtr = 0;\r
+ (*RequestMsgSize) = (UINTN)(RequestPtr) - (UINTN)(*RequestMsg);\r
Success = TRUE;\r
\r
Exit:\r
\r
if (!Success) {\r
- if (*Request != NULL) {\r
- FreePool (*Request);\r
+ if (*RequestMsg != NULL) {\r
+ FreePool (*RequestMsg);\r
}\r
- *Request = NULL;\r
+ *RequestMsg = NULL;\r
return Status;\r
}\r
\r