Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
MdeModulePkg/Include/Library/HttpLib.h | 4 +-
MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c | 118 +++++++++++++--------------
2 files changed, 60 insertions(+), 62 deletions(-)
diff --git a/MdeModulePkg/Include/Library/HttpLib.h b/MdeModulePkg/Include/Library/HttpLib.h
index 285a831..9975aea 100644
--- a/MdeModulePkg/Include/Library/HttpLib.h
+++ b/MdeModulePkg/Include/Library/HttpLib.h
@@ -432,13 +432,13 @@ HttpFreeHeaderFields (
@param[in] Url The URL of a remote host.
@param[out] RequestMsg Pointer to the created HTTP request message.
NULL if any error occured.
@param[out] RequestMsgSize Size of the RequestMsg (in bytes).
- @return EFI_SUCCESS If HTTP request string was created successfully
+ @retval EFI_SUCCESS If HTTP request string was created successfully.
@retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
- @retval EFI_INVALID_PARAMETER The input arguments are invalid
+ @retval EFI_INVALID_PARAMETER The input arguments are invalid.
**/
EFI_STATUS
EFIAPI
HttpGenRequestMessage (
diff --git a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
index 327ca9e..4e5cf84 100644
--- a/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
+++ b/MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.c
@@ -53,11 +53,12 @@ UriPercentDecode (
Index = 0;
Offset = 0;
HexStr[2] = '\0';
while (Index < BufferLength) {
if (Buffer[Index] == '%') {
- if (Index + 1 >= BufferLength || Index + 2 >= BufferLength || !NET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR (Buffer[Index+2])) {
+ if (Index + 1 >= BufferLength || Index + 2 >= BufferLength ||
+ !NET_IS_HEX_CHAR (Buffer[Index+1]) || !NET_IS_HEX_CHAR (Buffer[Index+2])) {
return EFI_INVALID_PARAMETER;
}
HexStr[0] = Buffer[Index+1];
HexStr[1] = Buffer[Index+2];
ResultBuffer[Offset] = (CHAR8) AsciiStrHexToUintn (HexStr);
@@ -506,11 +507,11 @@ HttpUrlGetHostName (
if (Url == NULL || UrlParser == NULL || HostName == NULL) {
return EFI_INVALID_PARAMETER;
}
- Parser = (HTTP_URL_PARSER*) UrlParser;
+ Parser = (HTTP_URL_PARSER *) UrlParser;
if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) == 0) {
return EFI_NOT_FOUND;
}
@@ -566,11 +567,11 @@ HttpUrlGetIp4 (
if (Url == NULL || UrlParser == NULL || Ip4Address == NULL) {
return EFI_INVALID_PARAMETER;
}
- Parser = (HTTP_URL_PARSER*) UrlParser;
+ Parser = (HTTP_URL_PARSER *) UrlParser;
if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) == 0) {
return EFI_NOT_FOUND;
}
@@ -629,11 +630,11 @@ HttpUrlGetIp6 (
if (Url == NULL || UrlParser == NULL || Ip6Address == NULL) {
return EFI_INVALID_PARAMETER;
}
- Parser = (HTTP_URL_PARSER*) UrlParser;
+ Parser = (HTTP_URL_PARSER *) UrlParser;
if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_HOST)) == 0) {
return EFI_NOT_FOUND;
}
@@ -694,25 +695,25 @@ HttpUrlGetPort (
IN CHAR8 *Url,
IN VOID *UrlParser,
OUT UINT16 *Port
)
{
- CHAR8 *PortString;
- EFI_STATUS Status;
- UINTN Index;
- UINTN Data;
- UINT32 ResultLength;
+ CHAR8 *PortString;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN Data;
+ UINT32 ResultLength;
HTTP_URL_PARSER *Parser;
if (Url == NULL || UrlParser == NULL || Port == NULL) {
return EFI_INVALID_PARAMETER;
}
*Port = 0;
Index = 0;
- Parser = (HTTP_URL_PARSER*) UrlParser;
+ Parser = (HTTP_URL_PARSER *) UrlParser;
if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PORT)) == 0) {
return EFI_NOT_FOUND;
}
@@ -786,11 +787,11 @@ HttpUrlGetPath (
if (Url == NULL || UrlParser == NULL || Path == NULL) {
return EFI_INVALID_PARAMETER;
}
- Parser = (HTTP_URL_PARSER*) UrlParser;
+ Parser = (HTTP_URL_PARSER *) UrlParser;
if ((Parser->FieldBitMap & BIT (HTTP_URI_FIELD_PATH)) == 0) {
return EFI_NOT_FOUND;
}
@@ -1156,21 +1157,21 @@ HttpParseMessageBody (
if (MsgParser == NULL) {
return EFI_INVALID_PARAMETER;
}
- Parser = (HTTP_BODY_PARSER*) MsgParser;
+ Parser = (HTTP_BODY_PARSER *) MsgParser;
if (Parser->IgnoreBody) {
Parser->State = BodyParserComplete;
if (Parser->Callback != NULL) {
Status = Parser->Callback (
- BodyParseEventOnComplete,
- Body,
- 0,
- Parser->Context
- );
+ BodyParseEventOnComplete,
+ Body,
+ 0,
+ Parser->Context
+ );
if (EFI_ERROR (Status)) {
return Status;
}
}
return EFI_SUCCESS;
@@ -1198,30 +1199,30 @@ HttpParseMessageBody (
//
// Identity transfer-coding, just notify user to save the body data.
//
if (Parser->Callback != NULL) {
Status = Parser->Callback (
- BodyParseEventOnData,
- Char,
- MIN (BodyLength, Parser->ContentLength - Parser->ParsedBodyLength),
- Parser->Context
- );
+ BodyParseEventOnData,
+ Char,
+ MIN (BodyLength, Parser->ContentLength - Parser->ParsedBodyLength),
+ Parser->Context
+ );
if (EFI_ERROR (Status)) {
return Status;
}
}
Char += MIN (BodyLength, Parser->ContentLength - Parser->ParsedBodyLength);
Parser->ParsedBodyLength += MIN (BodyLength, Parser->ContentLength - Parser->ParsedBodyLength);
if (Parser->ParsedBodyLength == Parser->ContentLength) {
Parser->State = BodyParserComplete;
if (Parser->Callback != NULL) {
Status = Parser->Callback (
- BodyParseEventOnComplete,
- Char,
- 0,
- Parser->Context
- );
+ BodyParseEventOnComplete,
+ Char,
+ 0,
+ Parser->Context
+ );
if (EFI_ERROR (Status)) {
return Status;
}
}
}
@@ -1302,15 +1303,15 @@ HttpParseMessageBody (
if (*Char == '\n') {
Parser->State = BodyParserComplete;
Char++;
if (Parser->Callback != NULL) {
Status = Parser->Callback (
- BodyParseEventOnComplete,
- Char,
- 0,
- Parser->Context
- );
+ BodyParseEventOnComplete,
+ Char,
+ 0,
+ Parser->Context
+ );
if (EFI_ERROR (Status)) {
return Status;
}
}
break;
@@ -1332,15 +1333,15 @@ HttpParseMessageBody (
//
RemainderLengthInThis = BodyLength - (Char - Body);
LengthForCallback = MIN (Parser->CurrentChunkSize - Parser->CurrentChunkParsedSize, RemainderLengthInThis);
if (Parser->Callback != NULL) {
Status = Parser->Callback (
- BodyParseEventOnData,
- Char,
- LengthForCallback,
- Parser->Context
- );
+ BodyParseEventOnData,
+ Char,
+ LengthForCallback,
+ Parser->Context
+ );
if (EFI_ERROR (Status)) {
return Status;
}
}
Char += LengthForCallback;
@@ -1401,11 +1402,11 @@ HttpIsMessageComplete (
if (MsgParser == NULL) {
return FALSE;
}
- Parser = (HTTP_BODY_PARSER*) MsgParser;
+ Parser = (HTTP_BODY_PARSER *) MsgParser;
if (Parser->State == BodyParserComplete) {
return TRUE;
}
return FALSE;
@@ -1435,11 +1436,11 @@ HttpGetEntityLength (
if (MsgParser == NULL || ContentLength == NULL) {
return EFI_INVALID_PARAMETER;
}
- Parser = (HTTP_BODY_PARSER*) MsgParser;
+ Parser = (HTTP_BODY_PARSER *) MsgParser;
if (!Parser->ContentLengthIsValid) {
return EFI_NOT_READY;
}
@@ -1473,11 +1474,10 @@ HttpFreeMsgParser (
@return Pointer to the next string.
@return NULL if not find or String is NULL.
**/
CHAR8 *
-EFIAPI
AsciiStrGetNextToken (
IN CONST CHAR8 *String,
IN CHAR8 Separator
)
{
@@ -1618,20 +1618,20 @@ HttpGetFieldNameAndValue (
while (TRUE) {
if (*FieldValueStr == ' ' || *FieldValueStr == '\t') {
//
// Boundary condition check.
//
- if ((UINTN)EndofHeader - (UINTN)(FieldValueStr) < 1) {
+ if ((UINTN) EndofHeader - (UINTN) FieldValueStr < 1) {
return NULL;
}
FieldValueStr ++;
} else if (*FieldValueStr == '\r') {
//
// Boundary condition check.
//
- if ((UINTN)EndofHeader - (UINTN)(FieldValueStr) < 3) {
+ if ((UINTN) EndofHeader - (UINTN) FieldValueStr < 3) {
return NULL;
}
if (*(FieldValueStr + 1) == '\n' && (*(FieldValueStr + 2) == ' ' || *(FieldValueStr + 2) == '\t')) {
FieldValueStr = FieldValueStr + 3;
@@ -1713,13 +1713,13 @@ HttpFreeHeaderFields (
@param[in] Url The URL of a remote host.
@param[out] RequestMsg Pointer to the created HTTP request message.
NULL if any error occured.
@param[out] RequestMsgSize Size of the RequestMsg (in bytes).
- @return EFI_SUCCESS If HTTP request string was created successfully
+ @retval EFI_SUCCESS If HTTP request string was created successfully.
@retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
- @retval EFI_INVALID_PARAMETER The input arguments are invalid
+ @retval EFI_INVALID_PARAMETER The input arguments are invalid.
**/
EFI_STATUS
EFIAPI
HttpGenRequestMessage (
@@ -1767,11 +1767,11 @@ HttpGenRequestMessage (
// Locate the HTTP_UTILITIES protocol.
//
Status = gBS->LocateProtocol (
&gEfiHttpUtilitiesProtocolGuid,
NULL,
- (VOID **)&HttpUtilitiesProtocol
+ (VOID **) &HttpUtilitiesProtocol
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR,"Failed to locate Http Utilities protocol. Status = %r.\n", Status));
return Status;
@@ -1791,24 +1791,22 @@ HttpGenRequestMessage (
//
// Build raw HTTP Headers
//
Status = HttpUtilitiesProtocol->Build (
- HttpUtilitiesProtocol,
- 0,
- NULL,
- 0,
- NULL,
- Message->HeaderCount,
- AppendList,
- &HttpHdrSize,
- &HttpHdr
- );
-
- if (AppendList != NULL) {
- FreePool (AppendList);
- }
+ HttpUtilitiesProtocol,
+ 0,
+ NULL,
+ 0,
+ NULL,
+ Message->HeaderCount,
+ AppendList,
+ &HttpHdrSize,
+ &HttpHdr
+ );
+
+ FreePool (AppendList);
if (EFI_ERROR (Status) || HttpHdr == NULL){
return Status;
}
}
@@ -1834,11 +1832,11 @@ HttpGenRequestMessage (
MsgSize += Message->BodyLength;
//
// memory for the string that needs to be sent to TCP
//
- *RequestMsg = NULL;
+ *RequestMsg = NULL;
*RequestMsg = AllocateZeroPool (MsgSize);
if (*RequestMsg == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
--
1.9.5.msysgit.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2025 Red Hat, Inc.