]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Update HttpDxe driver to consume EFI_HTTP_UTILITIES_PROTOCOL
authorJiaxin Wu <jiaxin.wu@intel.com>
Wed, 26 Aug 2015 06:19:53 +0000 (06:19 +0000)
committerjiaxinwu <jiaxinwu@Edk2>
Wed, 26 Aug 2015 06:19:53 +0000 (06:19 +0000)
v2:
* Register a notification function to be executed for Http utilities protocol
in the drivers entry points.

Since we add EFI_HTTP_UTILITIES_PROTOCOL support, HttpDxe driver should
be updated to remove internal http utilities functions and consume this
protocol directly.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Samer El-Haj-Mahmoud <elhaj@hp.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18316 6f19259b-4bc3-4df7-8a09-765794883524

NetworkPkg/HttpDxe/HttpDriver.c
NetworkPkg/HttpDxe/HttpDriver.h
NetworkPkg/HttpDxe/HttpDxe.inf
NetworkPkg/HttpDxe/HttpImpl.c
NetworkPkg/HttpDxe/HttpProto.c
NetworkPkg/HttpDxe/HttpUtilities.c [deleted file]
NetworkPkg/HttpDxe/HttpUtilities.h [deleted file]

index 43f42e29bf0c975b7dffdddabfb85e3ce6ce5a5b..bd1d04e78cc430acbba194d78f2e5eb9e9b8a5a3 100644 (file)
@@ -15,6 +15,8 @@
 \r
 #include "HttpDriver.h"\r
 \r
+EFI_HTTP_UTILITIES_PROTOCOL *mHttpUtilities = NULL;\r
+\r
 ///\r
 /// Driver Binding Protocol instance\r
 ///\r
@@ -100,6 +102,35 @@ HttpCleanService (
   }\r
 }\r
 \r
+/**\r
+  The event process routine when the http utilities protocol is installed\r
+  in the system.\r
+\r
+  @param[in]     Event         Not used.\r
+  @param[in]     Context       The pointer to the IP4 config2 instance data.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HttpUtilitiesInstalledCallback (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  )\r
+{\r
+  gBS->LocateProtocol (\r
+         &gEfiHttpUtilitiesProtocolGuid, \r
+         NULL, \r
+         (VOID **) &mHttpUtilities\r
+         );\r
+                \r
+  //\r
+  // Close the event if Http utilities protocol is loacted.\r
+  //\r
+  if (mHttpUtilities != NULL && Event != NULL) {\r
+     gBS->CloseEvent (Event);\r
+  }\r
+}\r
+\r
 /**\r
   This is the declaration of an EFI image entry point. This entry point is\r
   the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including\r
@@ -118,7 +149,28 @@ HttpDxeDriverEntryPoint (
   IN EFI_HANDLE        ImageHandle,\r
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
-{\r
+{ \r
+  VOID           *Registration;\r
+\r
+  gBS->LocateProtocol (\r
+         &gEfiHttpUtilitiesProtocolGuid, \r
+         NULL, \r
+         (VOID **) &mHttpUtilities\r
+         );\r
+\r
+  if (mHttpUtilities == NULL) {\r
+    //\r
+    // No Http utilities protocol, register a notify.\r
+    //\r
+    EfiCreateProtocolNotifyEvent (\r
+      &gEfiHttpUtilitiesProtocolGuid,\r
+      TPL_CALLBACK,\r
+      HttpUtilitiesInstalledCallback,\r
+      NULL,\r
+      &Registration\r
+      );\r
+  }\r
+\r
   //\r
   // Install UEFI Driver Model protocol(s).\r
   //\r
index 5bad7059f3d76def9df90a87a3677a000a81b21e..d95b05b634928f4f92a59909c99186167f4e6ce5 100644 (file)
@@ -41,6 +41,7 @@
 //\r
 // Consumed Protocols\r
 //\r
+#include <Protocol/HttpUtilities.h>\r
 #include <Protocol/Tcp4.h>\r
 #include <Protocol/Dns4.h>\r
 #include <Protocol/Ip4Config2.h>\r
@@ -62,6 +63,8 @@ extern EFI_DRIVER_BINDING_PROTOCOL  gHttpDxeDriverBinding;
 extern EFI_COMPONENT_NAME2_PROTOCOL gHttpDxeComponentName2;\r
 extern EFI_COMPONENT_NAME_PROTOCOL  gHttpDxeComponentName;\r
 \r
+extern EFI_HTTP_UTILITIES_PROTOCOL  *mHttpUtilities;\r
+\r
 //\r
 // Include files with function prototypes\r
 //\r
@@ -69,7 +72,6 @@ extern EFI_COMPONENT_NAME_PROTOCOL  gHttpDxeComponentName;
 #include "HttpImpl.h"\r
 #include "HttpProto.h"\r
 #include "HttpDns.h"\r
-#include "HttpUtilities.h"\r
 \r
 typedef struct {\r
   EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;\r
index 4632934720c51ac6051cb07a8c2e94744beefe3d..e8117006d6e7e014edb1e005b2821deea6bfa5ca 100644 (file)
@@ -38,8 +38,6 @@
   HttpImpl.c\r
   HttpProto.h\r
   HttpProto.c\r
-  HttpUtilities.h\r
-  HttpUtilities.c\r
 \r
 [LibraryClasses]\r
   UefiDriverEntryPoint\r
@@ -54,6 +52,7 @@
 [Protocols]\r
   gEfiHttpServiceBindingProtocolGuid               ## BY_START\r
   gEfiHttpProtocolGuid                             ## BY_START\r
+  gEfiHttpUtilitiesProtocolGuid                    ## CONSUMES\r
   gEfiTcp4ServiceBindingProtocolGuid               ## TO_START\r
   gEfiTcp4ProtocolGuid                             ## TO_START\r
   gEfiDns4ServiceBindingProtocolGuid               ## SOMETIMES_CONSUMES\r
index 80e819201ec1b667dbf78d325b380b56df2763b1..5b3c5d058cb1de9fbaec6d43bb3f87dac2118d8f 100644 (file)
@@ -757,7 +757,8 @@ HttpBodyParserCallback (
 \r
   @retval EFI_SUCCESS             Allocation succeeded.\r
   @retval EFI_OUT_OF_RESOURCES    Failed to complete the opration due to lack of resources.\r
-  @retval EFI_NOT_READY           Can't find a corresponding TxToken.\r
+  @retval EFI_NOT_READY           Can't find a corresponding TxToken or \r
+                                  the EFI_HTTP_UTILITIES_PROTOCOL is not available.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -953,10 +954,25 @@ HttpResponseWorker (
     CopyMem (HeaderTmp, Tmp, SizeofHeaders);\r
     FreePool (HttpHeaders);\r
     HttpHeaders = HeaderTmp;\r
+\r
+    //\r
+    // Check whether the EFI_HTTP_UTILITIES_PROTOCOL is available.\r
+    //\r
+    if (mHttpUtilities == NULL) {\r
+      Status = EFI_NOT_READY;\r
+      goto Error;\r
+    }\r
+    \r
     //\r
     // Parse the HTTP header into array of key/value pairs.\r
     //\r
-    Status = HttpUtilitiesParse (HttpHeaders, SizeofHeaders, &HttpMsg->Headers, &HttpMsg->HeaderCount);\r
+    Status = mHttpUtilities->Parse (\r
+                               mHttpUtilities, \r
+                               HttpHeaders, \r
+                               SizeofHeaders, \r
+                               &HttpMsg->Headers, \r
+                               &HttpMsg->HeaderCount\r
+                               );\r
     if (EFI_ERROR (Status)) {\r
       goto Error;\r
     }\r
index 50ade4c230571bd13c74f9f75a6986b0ab28f1a8..829758ad5ea4173e1ab23333cf623912cc025cc7 100644 (file)
@@ -1071,19 +1071,27 @@ HttpGenRequestString (
     AppendList[Index] = &Message->Headers[Index];\r
   }\r
 \r
+  //\r
+  // Check whether the EFI_HTTP_UTILITIES_PROTOCOL is available.\r
+  //\r
+  if (mHttpUtilities == NULL) {\r
+    return NULL;\r
+  }\r
+\r
   //\r
   // Build raw unformatted HTTP headers.\r
-  //  \r
-  Status = HttpUtilitiesBuild (\r
-             0,\r
-             NULL,\r
-             0,\r
-             NULL,\r
-             Message->HeaderCount,\r
-             AppendList,\r
-             &HttpHdrSize,\r
-             &HttpHdr\r
-             );\r
+  //\r
+  Status = mHttpUtilities->Build (\r
+                             mHttpUtilities,\r
+                             0,\r
+                             NULL,\r
+                             0,\r
+                             NULL,\r
+                             Message->HeaderCount,\r
+                             AppendList,\r
+                             &HttpHdrSize,\r
+                             &HttpHdr\r
+                             );\r
   FreePool (AppendList);\r
   if (EFI_ERROR (Status) || HttpHdr == NULL) {\r
     return NULL;\r
diff --git a/NetworkPkg/HttpDxe/HttpUtilities.c b/NetworkPkg/HttpDxe/HttpUtilities.c
deleted file mode 100644 (file)
index c2a99a4..0000000
+++ /dev/null
@@ -1,622 +0,0 @@
-/** @file\r
-\r
-Implementation of help functions to parse HTTP message header.\r
-\r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "HttpDriver.h"\r
-\r
-/**\r
-  Get the next string, which is distinguished by specified seperator. \r
-\r
-  @param[in]  String             Pointer to the string.\r
-  @param[in]  Seperator          Specified seperator used to distinguish where is the beginning \r
-                                 of next string.\r
-\r
-  @return     Pointer to the next string.\r
-  @return     NULL if not find or String is NULL.\r
-\r
-**/\r
-CHAR8 *\r
-AsciiStrGetNextToken (\r
-  IN CONST CHAR8 *String,\r
-  IN       CHAR8 Seperator\r
-  )\r
-{\r
-  CONST CHAR8 *Token;\r
-\r
-  Token = String;\r
-  while (TRUE) {\r
-    if (*Token == 0) {\r
-      return NULL;\r
-    }\r
-    if (*Token == Seperator) {\r
-      return (CHAR8 *) (Token + 1);\r
-    }\r
-    Token++;\r
-  }\r
-}\r
-\r
-/**\r
-  Free existing HeaderFields.\r
-\r
-  @param[in]  HeaderFields       Pointer to array of key/value header pairs waitting for free.\r
-  @param[in]  FieldCount         The number of header pairs in HeaderFields.\r
-\r
-**/\r
-VOID\r
-FreeHeaderFields (\r
-  IN  EFI_HTTP_HEADER  *HeaderFields,\r
-  IN  UINTN            FieldCount\r
-  )\r
-{\r
-  UINTN                       Index;\r
-  \r
-  if (HeaderFields != NULL) {\r
-    for (Index = 0; Index < FieldCount; Index++) {\r
-      if(HeaderFields[Index].FieldName != NULL) {\r
-        FreePool (HeaderFields[Index].FieldName);\r
-      }\r
-      if(HeaderFields[Index].FieldValue != NULL) {\r
-        FreePool (HeaderFields[Index].FieldValue);\r
-      }\r
-    }\r
-\r
-    FreePool (HeaderFields);\r
-  }\r
-}\r
-\r
-/**\r
-  Find required header field in HeaderFields.\r
-\r
-  @param[in]  HeaderFields        Pointer to array of key/value header pairs.\r
-  @param[in]  FieldCount          The number of header pairs.\r
-  @param[in]  FieldName           Pointer to header field's name.\r
-\r
-  @return     Pointer to the queried header field.\r
-  @return     NULL if not find this required header field.\r
-\r
-**/\r
-EFI_HTTP_HEADER *\r
-FindHttpHeader (\r
-  IN  EFI_HTTP_HEADER  *HeaderFields,\r
-  IN  UINTN            FieldCount,\r
-  IN  CHAR8            *FieldName\r
-  )\r
-{\r
-  UINTN                       Index;\r
-\r
-  for (Index = 0; Index < FieldCount; Index++) {\r
-    if (AsciiStrCmp (FieldName, HeaderFields[Index].FieldName) == 0) {\r
-      //\r
-      // Find the required header field.\r
-      //\r
-      return &HeaderFields[Index];\r
-    }\r
-  }\r
-  return NULL;\r
-}\r
-\r
-/**\r
-  Check whether header field called FieldName is in DeleteList.\r
-\r
-  @param[in]  DeleteList        Pointer to array of key/value header pairs.\r
-  @param[in]  DeleteCount       The number of header pairs.\r
-  @param[in]  FieldName         Pointer to header field's name.\r
-\r
-  @return     TRUE if FieldName is not in DeleteList, that means this header field is valid.\r
-  @return     FALSE if FieldName is in DeleteList, that means this header field is invalid.\r
-\r
-**/\r
-BOOLEAN\r
-IsValidHttpHeader (\r
-  IN  CHAR8            *DeleteList[],\r
-  IN  UINTN            DeleteCount,\r
-  IN  CHAR8            *FieldName\r
-  )\r
-{\r
-  UINTN                       Index;\r
-\r
-  for (Index = 0; Index < DeleteCount; Index++) {\r
-    if (AsciiStrCmp (FieldName, DeleteList[Index]) == 0) {\r
-      return FALSE;\r
-    }\r
-  }\r
-  \r
-  return TRUE;\r
-}\r
-\r
-/**\r
-  Set FieldName and FieldValue into specified HttpHeader.\r
-\r
-  @param[in]  HttpHeader          Specified HttpHeader.\r
-  @param[in]  FieldName           FieldName of this HttpHeader.\r
-  @param[in]  FieldValue          FieldValue of this HttpHeader.\r
-\r
-\r
-  @retval EFI_SUCCESS             The FieldName and FieldValue are set into HttpHeader successfully.\r
-  @retval EFI_OUT_OF_RESOURCES    Failed to allocate resources.\r
-\r
-**/\r
-EFI_STATUS\r
-SetFieldNameAndValue (\r
-  IN  EFI_HTTP_HEADER     *HttpHeader,\r
-  IN  CHAR8               *FieldName, \r
-  IN  CHAR8               *FieldValue\r
-  )\r
-{  \r
-  UINTN                       FieldNameSize;\r
-  UINTN                       FieldValueSize;\r
-\r
-  if (HttpHeader->FieldName != NULL) {\r
-    FreePool (HttpHeader->FieldName);\r
-  }\r
-  if (HttpHeader->FieldValue != NULL) {\r
-    FreePool (HttpHeader->FieldValue);\r
-  }\r
-\r
-  FieldNameSize = AsciiStrSize (FieldName);\r
-  HttpHeader->FieldName = AllocateZeroPool (FieldNameSize);\r
-  if (HttpHeader->FieldName == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  CopyMem (HttpHeader->FieldName, FieldName, FieldNameSize);\r
-  HttpHeader->FieldName[FieldNameSize - 1] = 0;\r
-\r
-  FieldValueSize = AsciiStrSize (FieldValue);\r
-  HttpHeader->FieldValue = AllocateZeroPool (FieldValueSize);\r
-  if (HttpHeader->FieldValue == NULL) {\r
-    FreePool (HttpHeader->FieldName);\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-  CopyMem (HttpHeader->FieldValue, FieldValue, FieldValueSize);\r
-  HttpHeader->FieldValue[FieldValueSize - 1] = 0;\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Get one key/value header pair from the raw string.\r
-\r
-  @param[in]  String             Pointer to the raw string.\r
-  @param[out] FieldName          Pointer to header field's name.\r
-  @param[out] FieldValue         Pointer to header field's value.\r
-\r
-  @return     Pointer to the next raw string.\r
-  @return     NULL if no key/value header pair from this raw string.\r
-\r
-**/\r
-CHAR8 *\r
-GetFieldNameAndValue (\r
-  IN  CHAR8   *String,\r
-  OUT CHAR8   **FieldName,\r
-  OUT CHAR8   **FieldValue\r
-  )\r
-{\r
-  CHAR8  *FieldNameStr;\r
-  CHAR8  *FieldValueStr;\r
-  CHAR8  *StrPtr;\r
-\r
-  if (String == NULL || FieldName == NULL || FieldValue == NULL) {\r
-    return NULL;\r
-  }\r
-  \r
-  *FieldName    = NULL;\r
-  *FieldValue   = NULL;\r
-  FieldNameStr  = NULL;\r
-  FieldValueStr = NULL;\r
-  StrPtr        = NULL;\r
-\r
-  //\r
-  // Each header field consists of a name followed by a colon (":") and the field value.\r
-  //\r
-  FieldNameStr = String;\r
-  FieldValueStr = AsciiStrGetNextToken (FieldNameStr, ':');\r
-  if (FieldValueStr == NULL) {\r
-    return NULL;\r
-  }\r
-  \r
-  *(FieldValueStr - 1) = 0; /// Replace ':' with 0\r
-  \r
-  //\r
-  // The field value MAY be preceded by any amount of LWS, though a single SP is preferred.\r
-  //\r
-  while (TRUE) {\r
-    if(*FieldValueStr == ' ' || *FieldValueStr == '\t') {\r
-      FieldValueStr ++;\r
-    } else if (*FieldValueStr == '\r' && *(FieldValueStr + 1) == '\n' && \r
-               (*(FieldValueStr + 2) == ' ' || *(FieldValueStr + 2) == '\t')) {\r
-      FieldValueStr = FieldValueStr + 3;\r
-    } else {\r
-      break;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Header fields can be extended over multiple lines by preceding each extra\r
-  // line with at least one SP or HT.\r
-  //\r
-  StrPtr = FieldValueStr;\r
-  do {\r
-    StrPtr = AsciiStrGetNextToken (StrPtr, '\r');\r
-    if (StrPtr == NULL || *StrPtr != '\n') {\r
-      return NULL;\r
-    }\r
-    \r
-    StrPtr++;\r
-  } while (*StrPtr == ' ' || *StrPtr == '\t');\r
-\r
-  //\r
-  // Replace '\r' with 0.\r
-  //\r
-  *(StrPtr - 2) = 0;\r
-\r
-  //\r
-  // Get FieldName and FieldValue.\r
-  //\r
-  *FieldName = FieldNameStr;\r
-  *FieldValue = FieldValueStr;\r
-    \r
-  return StrPtr;\r
-}\r
-\r
-/**\r
-  This function is used to manage the headers portion of an HTTP message by providing \r
-  the ability to add, remove, or replace HTTP headers.\r
-\r
-  @param[in]   SeedMessageSize       Size in bytes of the initial HTTP header. This can be zero.  \r
-  @param[in]   SeedMessage           Initial raw unformatted HTTP header to be used as a base for \r
-                                     building a new unformatted HTTP header. If NULL, SeedMessageSize \r
-                                     is ignored. The buffer containing this message will be allocated \r
-                                     and released by the caller.           \r
-  @param[in]   DeleteCount           Number of null-terminated HTTP header field names in DeleteList.\r
-  @param[in]   DeleteList            List of null-terminated HTTP header field names to remove from SeedMessage. \r
-                                     Only the field names are in this list because the field values are irrelevant \r
-                                     to this operation. If NULL, DeleteCount is ignored. The buffer containing the \r
-                                     list will be allocated and released by the caller.\r
-  @param[in]   AppendCount           Number of header fields in AppendList. \r
-  @param[in]   AppendList            List of HTTP headers to populate NewMessage with. If SeedMessage is not NULL, \r
-                                     AppendList will be appended to the existing list from SeedMessage in NewMessage.\r
-  @param[out]  NewMessageSize        Pointer to the size in bytes of the new unformatted HTTP header in NewMessage.       \r
-  @param[out]  NewMessage            Pointer to a new unformatted HTTP header. The storage for this NewMessage is \r
-                                     allocated by the driver publishing this protocol, and must be freed by the caller. \r
-  \r
-  @retval EFI_SUCCESS                Add, remove, and replace operations succeeded.\r
-  @retval EFI_OUT_OF_RESOURCES       Could not allocate memory for NewMessage.\r
-  \r
-**/\r
-EFI_STATUS\r
-HttpUtilitiesBuild(\r
-  IN     UINTN                       SeedMessageSize,\r
-  IN     VOID                        *SeedMessage, OPTIONAL\r
-  IN     UINTN                       DeleteCount,\r
-  IN     CHAR8                       *DeleteList[], OPTIONAL\r
-  IN     UINTN                       AppendCount,\r
-  IN     EFI_HTTP_HEADER             *AppendList[], OPTIONAL\r
-     OUT UINTN                       *NewMessageSize,\r
-     OUT VOID                        **NewMessage\r
-  )\r
-{\r
-  EFI_STATUS                Status;  \r
-  EFI_HTTP_HEADER           *SeedHeaderFields;\r
-  UINTN                     SeedFieldCount;\r
-  UINTN                     Index;\r
-  EFI_HTTP_HEADER           *TempHeaderFields;\r
-  UINTN                     TempFieldCount;\r
-  EFI_HTTP_HEADER           *NewHeaderFields;\r
-  UINTN                     NewFieldCount;\r
-  EFI_HTTP_HEADER           *HttpHeader;\r
-  UINTN                     StrLength;\r
-  UINT8                     *NewMessagePtr;\r
-\r
-  SeedHeaderFields = NULL;\r
-  SeedFieldCount   = 0;\r
-  TempHeaderFields = NULL;\r
-  TempFieldCount   = 0;\r
-  NewHeaderFields  = NULL;\r
-  NewFieldCount    = 0;\r
-\r
-  HttpHeader       = NULL;  \r
-  StrLength        = 0;\r
-  NewMessagePtr    = NULL;\r
-  *NewMessageSize  = 0;\r
-  Status           = EFI_SUCCESS;\r
-\r
-  if (SeedMessage != NULL) {\r
-    Status = HttpUtilitiesParse (\r
-              SeedMessage,\r
-              SeedMessageSize,\r
-              &SeedHeaderFields,\r
-              &SeedFieldCount\r
-              );\r
-    if (EFI_ERROR (Status)){\r
-      goto ON_EXIT;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Handle DeleteList\r
-  //\r
-  if(SeedFieldCount != 0 && DeleteCount != 0) {\r
-    TempHeaderFields = AllocateZeroPool (SeedFieldCount * sizeof(EFI_HTTP_HEADER));\r
-    if (TempHeaderFields == NULL) {\r
-      Status = EFI_OUT_OF_RESOURCES;\r
-      goto ON_EXIT;\r
-    }\r
-    \r
-    for (Index = 0, TempFieldCount = 0; Index < SeedFieldCount; Index++) {\r
-      //\r
-      // Check whether each SeedHeaderFields member is in DeleteList\r
-      //\r
-      if (IsValidHttpHeader(DeleteList, DeleteCount, SeedHeaderFields[Index].FieldName)) {\r
-        Status = SetFieldNameAndValue(\r
-                   &TempHeaderFields[TempFieldCount],\r
-                   SeedHeaderFields[Index].FieldName,\r
-                   SeedHeaderFields[Index].FieldValue\r
-                   );\r
-        if (EFI_ERROR (Status)){\r
-          goto ON_EXIT;\r
-        }\r
-        TempFieldCount++;\r
-      }\r
-    }\r
-  } else {\r
-    TempHeaderFields = SeedHeaderFields;\r
-    TempFieldCount = SeedFieldCount;\r
-  }\r
-\r
-  //\r
-  // Handle AppendList\r
-  //\r
-  NewHeaderFields = AllocateZeroPool ((TempFieldCount + AppendCount) * sizeof(EFI_HTTP_HEADER));\r
-  if (NewHeaderFields == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  for (Index = 0; Index < TempFieldCount; Index++) {\r
-    Status = SetFieldNameAndValue(\r
-               &NewHeaderFields[Index],\r
-               TempHeaderFields[Index].FieldName,\r
-               TempHeaderFields[Index].FieldValue\r
-               );\r
-    if (EFI_ERROR (Status)){\r
-      goto ON_EXIT;\r
-    }\r
-  }\r
-  \r
-  NewFieldCount = TempFieldCount;\r
-\r
-  for (Index = 0; Index < AppendCount; Index++) {\r
-    HttpHeader = FindHttpHeader(NewHeaderFields, NewFieldCount, AppendList[Index]->FieldName);\r
-    if(HttpHeader != NULL) {\r
-      Status = SetFieldNameAndValue(\r
-                 HttpHeader,\r
-                 AppendList[Index]->FieldName,\r
-                 AppendList[Index]->FieldValue\r
-                 );\r
-      if (EFI_ERROR (Status)){\r
-        goto ON_EXIT;\r
-      }\r
-    } else {\r
-      Status = SetFieldNameAndValue\r
-                 (&NewHeaderFields[NewFieldCount],\r
-                 AppendList[Index]->FieldName,\r
-                 AppendList[Index]->FieldValue\r
-                 );\r
-      if (EFI_ERROR (Status)){\r
-        goto ON_EXIT;\r
-      }\r
-      NewFieldCount++;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Calculate NewMessageSize, then build NewMessage\r
-  //\r
-  for (Index = 0; Index < NewFieldCount; Index++) {\r
-    HttpHeader = &NewHeaderFields[Index];\r
-\r
-    StrLength = AsciiStrLen (HttpHeader->FieldName);\r
-    *NewMessageSize += StrLength;\r
-\r
-    StrLength = sizeof(": ") - 1;\r
-    *NewMessageSize += StrLength;\r
-\r
-    StrLength = AsciiStrLen (HttpHeader->FieldValue);\r
-    *NewMessageSize += StrLength;\r
-\r
-    StrLength = sizeof(HTTP_CRLF_STR) - 1;\r
-    *NewMessageSize += StrLength;\r
-  }\r
-  StrLength = sizeof(HTTP_CRLF_STR) - 1;\r
-  *NewMessageSize += StrLength;\r
-  //\r
-  // Final 0 for end flag.\r
-  //\r
-  *NewMessageSize += 1;\r
-\r
-  *NewMessage = AllocateZeroPool (*NewMessageSize);\r
-  if (*NewMessage == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ON_EXIT;\r
-  }\r
-\r
-  NewMessagePtr = (UINT8 *)(*NewMessage);\r
-\r
-  for (Index = 0; Index < NewFieldCount; Index++) {\r
-    HttpHeader = &NewHeaderFields[Index];\r
-\r
-    StrLength = AsciiStrLen (HttpHeader->FieldName);\r
-    CopyMem (NewMessagePtr, HttpHeader->FieldName, StrLength);\r
-    NewMessagePtr += StrLength;\r
-\r
-    StrLength = sizeof(": ") - 1;\r
-    CopyMem (NewMessagePtr, ": ", StrLength);\r
-    NewMessagePtr += StrLength;\r
-\r
-    StrLength = AsciiStrLen (HttpHeader->FieldValue);\r
-    CopyMem (NewMessagePtr, HttpHeader->FieldValue, StrLength);\r
-    NewMessagePtr += StrLength;\r
-\r
-    StrLength = sizeof(HTTP_CRLF_STR) - 1;\r
-    CopyMem (NewMessagePtr, HTTP_CRLF_STR, StrLength);\r
-    NewMessagePtr += StrLength;\r
-  }\r
-  StrLength = sizeof(HTTP_CRLF_STR) - 1;\r
-  CopyMem (NewMessagePtr, HTTP_CRLF_STR, StrLength);\r
-  NewMessagePtr += StrLength;\r
-\r
-  *NewMessagePtr = 0;\r
-\r
-  ASSERT (*NewMessageSize == (UINTN) NewMessagePtr - (UINTN) (*NewMessage) + 1);\r
-\r
-  //\r
-  // Free allocated buffer \r
-  //\r
-ON_EXIT:\r
-  if(SeedHeaderFields != NULL) {\r
-    FreeHeaderFields(SeedHeaderFields, SeedFieldCount);\r
-  }\r
-  \r
-  if(TempHeaderFields != NULL) {\r
-    FreeHeaderFields(TempHeaderFields, TempFieldCount);\r
-  }\r
-\r
-  if(NewHeaderFields != NULL) {\r
-    FreeHeaderFields(NewHeaderFields, NewFieldCount);\r
-  }\r
-  \r
-  return Status;\r
-}\r
-\r
-/**\r
-  This function is used to transform data stored in HttpMessage into a list of fields \r
-  paired with their corresponding values.\r
-\r
-  @param[in]   HttpMessage           Contains raw unformatted HTTP header string. The buffer for this string will \r
-                                     be allocated and released by the caller.\r
-  @param[in]   HttpMessageSize       Size in bytes of raw unformatted HTTP header.      \r
-  @param[out]  HeaderFields          Array of key/value header pairs. The storage for all header pairs is allocated\r
-                                     by the driver publishing this protocol, and must be freed by the caller. \r
-  @param[out]  FieldCount            Number of headers in HeaderFields.\r
-  \r
-  @retval EFI_SUCCESS                Parse HTTP header into array of key/value pairs succeeded.\r
-  @retval EFI_OUT_OF_RESOURCES       Could not allocate memory for NewMessage.\r
-  @retval EFI_INVALID_PARAMETER      One or more of the following conditions is TRUE:\r
-                                     HttpMessage is NULL.\r
-                                     HeaderFields is NULL.\r
-                                     FieldCount is NULL.\r
-  \r
-**/\r
-EFI_STATUS\r
-HttpUtilitiesParse(\r
-  IN  CHAR8                        *HttpMessage,\r
-  IN  UINTN                        HttpMessageSize,\r
-  OUT EFI_HTTP_HEADER              **HeaderFields,\r
-  OUT UINTN                        *FieldCount\r
-  )\r
-{\r
-  EFI_STATUS                Status;\r
-  CHAR8                     *TempHttpMessage;\r
-  CHAR8                     *Token;\r
-  CHAR8                     *NextToken;\r
-  CHAR8                     *FieldName;\r
-  CHAR8                     *FieldValue;\r
-  UINTN                     Index;\r
-\r
-  if (HttpMessage == NULL || HeaderFields == NULL || FieldCount == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
\r
-  Status          = EFI_SUCCESS;\r
-  TempHttpMessage = NULL;\r
-  *FieldCount     = 0;\r
-  Token           = NULL;\r
-  NextToken       = NULL;\r
-  FieldName       = NULL;\r
-  FieldValue      = NULL;\r
-  Index           = 0;  \r
-\r
-  TempHttpMessage = AllocateZeroPool (HttpMessageSize);\r
-  if (TempHttpMessage == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
-  CopyMem (TempHttpMessage, HttpMessage, HttpMessageSize);\r
-  \r
-  //\r
-  // Get header number\r
-  //\r
-  Token = TempHttpMessage;\r
-  while (TRUE) {\r
-    FieldName     = NULL;\r
-    FieldValue    = NULL;\r
-    NextToken = GetFieldNameAndValue (Token, &FieldName, &FieldValue);\r
-    Token     = NextToken;\r
-    if (FieldName == NULL || FieldValue == NULL) {\r
-      break;\r
-    }\r
-\r
-    (*FieldCount)++;\r
-  }\r
-\r
-  if(*FieldCount == 0) {\r
-    Status =  EFI_INVALID_PARAMETER;\r
-    goto ON_EXIT;\r
-  }\r
-  \r
-  //\r
-  // Allocate buffer for header\r
-  //\r
-  *HeaderFields = AllocateZeroPool ((*FieldCount) * sizeof(EFI_HTTP_HEADER));\r
-  if (*HeaderFields == NULL) {\r
-    *FieldCount = 0;\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto ON_EXIT;\r
-  }\r
-  \r
-  CopyMem (TempHttpMessage, HttpMessage, HttpMessageSize);\r
-  \r
-  //\r
-  // Set Field and Value to each header\r
-  //\r
-  Token = TempHttpMessage;\r
-  while (Index < *FieldCount) {\r
-    FieldName     = NULL;\r
-    FieldValue    = NULL;\r
-    NextToken = GetFieldNameAndValue (Token, &FieldName, &FieldValue);\r
-    Token     = NextToken;\r
-    if (FieldName == NULL || FieldValue == NULL) {\r
-      break;\r
-    }\r
-\r
-    Status = SetFieldNameAndValue(&(*HeaderFields)[Index], FieldName, FieldValue);\r
-    if(EFI_ERROR(Status)){\r
-      *FieldCount = 0;\r
-      FreeHeaderFields (*HeaderFields, Index);\r
-      goto ON_EXIT;\r
-    }\r
-    \r
-    Index++;\r
-  }\r
-\r
-  //\r
-  // Free allocated buffer \r
-  //\r
-ON_EXIT:\r
-  if (TempHttpMessage != NULL) {\r
-    FreePool(TempHttpMessage);\r
-  }\r
-  \r
-  return Status;\r
-}\r
diff --git a/NetworkPkg/HttpDxe/HttpUtilities.h b/NetworkPkg/HttpDxe/HttpUtilities.h
deleted file mode 100644 (file)
index bd4ef0b..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/** @file\r
-  The header files of HTTP helper functions for HttpDxe driver.\r
-\r
-Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __EFI_HTTP_UTILITIES_H__\r
-#define __EFI_HTTP_UTILITIES_H__\r
-\r
-/**\r
-  This function is used to manage the headers portion of an HTTP message by providing \r
-  the ability to add, remove, or replace HTTP headers.\r
-\r
-  @param[in]   SeedMessageSize       Size in bytes of the initial HTTP header. This can be zero.  \r
-  @param[in]   SeedMessage           Initial raw unformatted HTTP header to be used as a base for \r
-                                     building a new unformatted HTTP header. If NULL, SeedMessageSize \r
-                                     is ignored. The buffer containing this message will be allocated \r
-                                     and released by the caller.           \r
-  @param[in]   DeleteCount           Number of null-terminated HTTP header field names in DeleteList.\r
-  @param[in]   DeleteList            List of null-terminated HTTP header field names to remove from SeedMessage. \r
-                                     Only the field names are in this list because the field values are irrelevant \r
-                                     to this operation. If NULL, DeleteCount is ignored. The buffer containing the \r
-                                     list will be allocated and released by the caller.\r
-  @param[in]   AppendCount           Number of header fields in AppendList. \r
-  @param[in]   AppendList            List of HTTP headers to populate NewMessage with. If SeedMessage is not NULL, \r
-                                     AppendList will be appended to the existing list from SeedMessage in NewMessage.\r
-  @param[out]  NewMessageSize        Pointer to the size in bytes of the new unformatted HTTP header in NewMessage.       \r
-  @param[out]  NewMessage            Pointer to a new unformatted HTTP header. The storage for this NewMessage is \r
-                                     allocated by the driver publishing this protocol, and must be freed by the caller. \r
-  \r
-  @retval EFI_SUCCESS                Add, remove, and replace operations succeeded.\r
-  @retval EFI_OUT_OF_RESOURCES       Could not allocate memory for NewMessage.\r
-  \r
-**/\r
-EFI_STATUS\r
-HttpUtilitiesBuild(\r
-  IN     UINTN                       SeedMessageSize,\r
-  IN     VOID                        *SeedMessage, OPTIONAL\r
-  IN     UINTN                       DeleteCount,\r
-  IN     CHAR8                       *DeleteList[], OPTIONAL\r
-  IN     UINTN                       AppendCount,\r
-  IN     EFI_HTTP_HEADER             *AppendList[], OPTIONAL\r
-     OUT UINTN                       *NewMessageSize,\r
-     OUT VOID                        **NewMessage\r
-  );\r
-\r
-/**\r
-  This function is used to transform data stored in HttpMessage into a list of fields \r
-  paired with their corresponding values.\r
-\r
-  @param[in]   HttpMessage           Contains raw unformatted HTTP header string. The buffer for this string will \r
-                                     be allocated and released by the caller.\r
-  @param[in]   HttpMessageSize       Size in bytes of raw unformatted HTTP header.      \r
-  @param[out]  HeaderFields          Array of key/value header pairs. The storage for all header pairs is allocated\r
-                                     by the driver publishing this protocol, and must be freed by the caller. \r
-  @param[out]  FieldCount            Number of headers in HeaderFields.\r
-  \r
-  @retval EFI_SUCCESS                Parse HTTP header into array of key/value pairs succeeded.\r
-  @retval EFI_OUT_OF_RESOURCES       Could not allocate memory for NewMessage.\r
-  @retval EFI_INVALID_PARAMETER      One or more of the following conditions is TRUE:\r
-                                     HttpMessage is NULL.\r
-                                     HeaderFields is NULL.\r
-                                     FieldCount is NULL.\r
-  \r
-**/\r
-EFI_STATUS\r
-HttpUtilitiesParse(\r
-  IN  CHAR8                        *HttpMessage,\r
-  IN  UINTN                        HttpMessageSize,\r
-  OUT EFI_HTTP_HEADER              **HeaderFields,\r
-  OUT UINTN                        *FieldCount\r
-  );\r
-\r
-#endif\r