]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Use the New Functions from HttpLib
authorGhazi Belaam <Ghazi.belaam@hpe.com>
Fri, 4 Mar 2016 22:07:50 +0000 (06:07 +0800)
committerFu Siyuan <siyuan.fu@intel.com>
Thu, 10 Mar 2016 02:01:42 +0000 (10:01 +0800)
After submitting changes for HttpLib, other modules should be able to use
those functions
1 remove the private function and their calls
2 update it with the functions from httpLib

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ghazi Belaam <Ghazi.belaam@hpe.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Samer EL-Haj-Mahmoud <elhaj@hpe.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
NetworkPkg/HttpBootDxe/HttpBootSupport.c
NetworkPkg/HttpDxe/HttpImpl.c
NetworkPkg/HttpDxe/HttpProto.c
NetworkPkg/HttpDxe/HttpProto.h
NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.h
NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesImpl.c [deleted file]
NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesProtocol.c

index f30d9f7fb0db7475f2293ac6cb4f4d48219dae94..e678379bf48bb96f041e97882d8c6db5a582648d 100644 (file)
@@ -2,8 +2,9 @@
   Support functions implementation for UEFI HTTP boot driver.\r
 \r
 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials are licensed and made available under \r
-the terms and conditions of the BSD License that accompanies this distribution.  \r
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
+This program and the accompanying materials are licensed and made available under\r
+the terms and conditions of the BSD License that accompanies this distribution.\r
 The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php.                                          \r
     \r
@@ -547,45 +548,11 @@ HttpBootFreeHeader (
   }\r
 }\r
 \r
-/**\r
-  Find a specified header field according to the field name.\r
-\r
-  @param[in]   HeaderCount      Number of HTTP header structures in Headers list. \r
-  @param[in]   Headers          Array containing list of HTTP headers.\r
-  @param[in]   FieldName        Null terminated string which describes a field name. \r
-\r
-  @return    Pointer to the found header or NULL.\r
-\r
-**/\r
-EFI_HTTP_HEADER *\r
-HttpBootFindHeader (\r
-  IN  UINTN                HeaderCount,\r
-  IN  EFI_HTTP_HEADER      *Headers,\r
-  IN  CHAR8                *FieldName\r
-  )\r
-{\r
-  UINTN                 Index;\r
-  \r
-  if (HeaderCount == 0 || Headers == NULL || FieldName == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  for (Index = 0; Index < HeaderCount; Index++){\r
-    //\r
-    // Field names are case-insensitive (RFC 2616).\r
-    //\r
-    if (AsciiStriCmp (Headers[Index].FieldName, FieldName) == 0) {\r
-      return &Headers[Index];\r
-    }\r
-  }\r
-  return NULL;\r
-}\r
-\r
 /**\r
   Set or update a HTTP header with the field name and corresponding value.\r
 \r
   @param[in]  HttpIoHeader       Point to the HTTP header holder.\r
-  @param[in]  FieldName          Null terminated string which describes a field name. \r
+  @param[in]  FieldName          Null terminated string which describes a field name.\r
   @param[in]  FieldValue         Null terminated string which describes the corresponding field value.\r
 \r
   @retval  EFI_SUCCESS           The HTTP header has been set or updated.\r
@@ -609,7 +576,7 @@ HttpBootSetHeader (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  Header = HttpBootFindHeader (HttpIoHeader->HeaderCount, HttpIoHeader->Headers, FieldName);\r
+  Header = HttpFindHeader (HttpIoHeader->HeaderCount, HttpIoHeader->Headers, FieldName);\r
   if (Header == NULL) {\r
     //\r
     // Add a new header.\r
index a068cfb76b4af7b57fa741b2cdde767750f53738..63b683e7e5e25962967091d66310a53a0bd79dc3 100644 (file)
@@ -2,7 +2,7 @@
   Implementation of EFI_HTTP_PROTOCOL protocol interfaces.\r
 \r
   Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
-  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
+  (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -497,9 +497,10 @@ EfiHttpRequest (
       goto Error3;\r
     }\r
   }\r
-  RequestStr = HttpGenRequestString (HttpInstance, HttpMsg, FileUrl);\r
-  if (RequestStr == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
+\r
+  Status = HttpGenRequestString (HttpMsg, FileUrl, &RequestStr);\r
+\r
+  if (EFI_ERROR (Status)) {\r
     goto Error3;\r
   }\r
 \r
index 579b9e46627070e26ab1f990df973c36f573e4f8..156f138f56d754163c224b6f8a0cfb049cb87ac3 100644 (file)
@@ -1375,107 +1375,6 @@ HttpTransmitTcp (
   return Status;\r
 }\r
 \r
-/**\r
-  Translate the status code in HTTP message to EFI_HTTP_STATUS_CODE defined \r
-  in UEFI 2.5 specification.\r
-\r
-  @param[in]  StatusCode         The status code value in HTTP message.\r
-\r
-  @return                        Value defined in EFI_HTTP_STATUS_CODE .\r
-\r
-**/\r
-EFI_HTTP_STATUS_CODE\r
-HttpMappingToStatusCode (\r
-  IN UINTN                  StatusCode\r
-  )  \r
-{\r
-  switch (StatusCode) {\r
-  case 100:\r
-    return HTTP_STATUS_100_CONTINUE;\r
-  case 101:\r
-    return HTTP_STATUS_101_SWITCHING_PROTOCOLS;\r
-  case 200:\r
-    return HTTP_STATUS_200_OK;\r
-  case 201:\r
-    return HTTP_STATUS_201_CREATED;\r
-  case 202:\r
-    return HTTP_STATUS_202_ACCEPTED;\r
-  case 203:\r
-    return HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION;\r
-  case 204:\r
-    return HTTP_STATUS_204_NO_CONTENT;\r
-  case 205:\r
-    return HTTP_STATUS_205_RESET_CONTENT;\r
-  case 206:\r
-    return HTTP_STATUS_206_PARTIAL_CONTENT;\r
-  case 300:\r
-    return HTTP_STATUS_300_MULTIPLE_CHIOCES;\r
-  case 301:\r
-    return HTTP_STATUS_301_MOVED_PERMANENTLY;\r
-  case 302:\r
-    return HTTP_STATUS_302_FOUND;\r
-  case 303:\r
-    return HTTP_STATUS_303_SEE_OTHER;\r
-  case 304:\r
-    return HTTP_STATUS_304_NOT_MODIFIED;\r
-  case 305:\r
-    return HTTP_STATUS_305_USE_PROXY;\r
-  case 307:\r
-    return HTTP_STATUS_307_TEMPORARY_REDIRECT;\r
-  case 400:\r
-    return HTTP_STATUS_400_BAD_REQUEST;\r
-  case 401:\r
-    return HTTP_STATUS_401_UNAUTHORIZED;\r
-  case 402:\r
-    return HTTP_STATUS_402_PAYMENT_REQUIRED;\r
-  case 403:\r
-    return HTTP_STATUS_403_FORBIDDEN;\r
-  case 404:\r
-    return HTTP_STATUS_404_NOT_FOUND;\r
-  case 405:\r
-    return HTTP_STATUS_405_METHOD_NOT_ALLOWED;\r
-  case 406:\r
-    return HTTP_STATUS_406_NOT_ACCEPTABLE;\r
-  case 407:\r
-    return HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED;\r
-  case 408:\r
-    return HTTP_STATUS_408_REQUEST_TIME_OUT;\r
-  case 409:\r
-    return HTTP_STATUS_409_CONFLICT;\r
-  case 410:\r
-    return HTTP_STATUS_410_GONE;\r
-  case 411:\r
-    return HTTP_STATUS_411_LENGTH_REQUIRED;\r
-  case 412:\r
-    return HTTP_STATUS_412_PRECONDITION_FAILED;\r
-  case 413:\r
-    return HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE;\r
-  case 414:\r
-    return HTTP_STATUS_414_REQUEST_URI_TOO_LARGE;\r
-  case 415:\r
-    return HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE;\r
-  case 416:\r
-    return HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED;\r
-  case 417:\r
-    return HTTP_STATUS_417_EXPECTATION_FAILED;\r
-  case 500:\r
-    return HTTP_STATUS_500_INTERNAL_SERVER_ERROR;\r
-  case 501:\r
-    return HTTP_STATUS_501_NOT_IMPLEMENTED;\r
-  case 502:\r
-    return HTTP_STATUS_502_BAD_GATEWAY;\r
-  case 503:\r
-    return HTTP_STATUS_503_SERVICE_UNAVAILABLE;\r
-  case 504:\r
-    return HTTP_STATUS_504_GATEWAY_TIME_OUT;\r
-  case 505:\r
-    return HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED;\r
-\r
-  default:\r
-    return HTTP_STATUS_UNSUPPORTED_STATUS;\r
-  }\r
-}\r
-\r
 /**\r
   Check whether the user's token or event has already\r
   been enqueue on HTTP Tx or Rx Token list.\r
@@ -1584,14 +1483,15 @@ HttpTcpTransmit (
   //\r
   // Create request message.\r
   //\r
-  RequestStr = HttpGenRequestString (\r
-                 ValueInItem->HttpInstance,\r
+  Status = HttpGenRequestString (\r
                  ValueInItem->HttpToken->Message,\r
-                 Url\r
+                 Url,\r
+                 &RequestStr\r
                  );\r
   FreePool (Url);\r
-  if (RequestStr == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
+\r
+  if (EFI_ERROR (Status)){\r
+    return Status;\r
   }\r
 \r
   //\r
@@ -1942,159 +1842,3 @@ HttpTcpTokenCleanup (
   }\r
 \r
 }\r
-\r
-/**\r
-  Generate HTTP request string.\r
-\r
-  @param[in]  HttpInstance       Pointer to HTTP_PROTOCOL structure.\r
-  @param[in]  Message            Pointer to storage containing HTTP message data.\r
-  @param[in]  Url                The URL of a remote host.\r
-\r
-  @return     Pointer to the created HTTP request string.\r
-  @return     NULL if any error occured.\r
-\r
-**/\r
-CHAR8 *\r
-HttpGenRequestString (\r
-  IN  HTTP_PROTOCOL        *HttpInstance,\r
-  IN  EFI_HTTP_MESSAGE     *Message,\r
-  IN  CHAR8                *Url\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  UINTN                       StrLength;\r
-  UINT8                       *Request;\r
-  UINT8                       *RequestPtr;\r
-  UINTN                       HttpHdrSize;\r
-  UINTN                       MsgSize;\r
-  BOOLEAN                     Success;\r
-  VOID                        *HttpHdr;\r
-  EFI_HTTP_HEADER             **AppendList; \r
-  UINTN                       Index;\r
-  \r
-  ASSERT (HttpInstance != NULL);\r
-  ASSERT (Message != NULL);\r
-\r
-  DEBUG ((EFI_D_ERROR, "HttpMethod - %x\n", Message->Data.Request->Method));\r
-\r
-  Request = NULL;\r
-  Success = FALSE;\r
-  HttpHdr = NULL;\r
-  AppendList = NULL;\r
-\r
-  //\r
-  // Build AppendList\r
-  //\r
-  AppendList = AllocateZeroPool (sizeof (EFI_HTTP_HEADER *) * (Message->HeaderCount));\r
-  if (AppendList == NULL) {\r
-    return NULL;\r
-  }\r
-\r
-  for(Index = 0; Index < Message->HeaderCount; Index++){\r
-    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 = 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
-  }\r
-\r
-  //\r
-  // Calculate HTTP message length.\r
-  //\r
-  MsgSize = Message->BodyLength + HTTP_METHOD_MAXIMUM_LEN + AsciiStrLen (Url) +\r
-            AsciiStrLen (HTTP_VERSION_CRLF_STR) + HttpHdrSize;\r
-  Request = AllocateZeroPool (MsgSize);\r
-  if (Request == NULL) {\r
-    goto Exit;\r
-  }  \r
-\r
-  RequestPtr = Request;\r
-  //\r
-  // Construct header request\r
-  //\r
-  switch (Message->Data.Request->Method) {\r
-  case HttpMethodGet:\r
-    StrLength = sizeof (HTTP_METHOD_GET) - 1;\r
-    CopyMem (RequestPtr, HTTP_METHOD_GET, StrLength);\r
-    RequestPtr += StrLength;\r
-    break;\r
-  case HttpMethodHead:\r
-    StrLength = sizeof (HTTP_METHOD_HEAD) - 1;\r
-    CopyMem (RequestPtr, HTTP_METHOD_HEAD, StrLength);\r
-    RequestPtr += StrLength;\r
-    break;\r
-  default:\r
-    ASSERT (FALSE);\r
-    goto Exit;\r
-  }\r
-\r
-  StrLength = AsciiStrLen(" ");\r
-  CopyMem (RequestPtr, " ", StrLength);\r
-  RequestPtr += StrLength;\r
-\r
-  StrLength = AsciiStrLen (Url);\r
-  CopyMem (RequestPtr, Url, StrLength);\r
-  RequestPtr += StrLength;\r
-\r
-  StrLength = sizeof (HTTP_VERSION_CRLF_STR) - 1;\r
-  CopyMem (RequestPtr, HTTP_VERSION_CRLF_STR, StrLength);\r
-  RequestPtr += StrLength;\r
-\r
-  //\r
-  // Construct header\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
-  Success     = TRUE;\r
-  \r
-Exit:\r
-\r
-  if (!Success) {\r
-    if (Request != NULL) {\r
-      FreePool (Request);\r
-    }\r
-\r
-    Request = NULL;\r
-  }\r
-\r
-  if (HttpHdr != NULL) {\r
-    FreePool (HttpHdr);\r
-  }\r
-\r
-  return (CHAR8*) Request;\r
-}\r
index 3a574949de24657e084fc8445b54b37eb131050b..7b4b343b2a2e84964a67bc1667c2be1cadd5c01e 100644 (file)
@@ -2,6 +2,7 @@
   The header files of miscellaneous routines for HttpDxe driver.\r
 \r
 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
@@ -398,20 +399,6 @@ HttpTransmitTcp (
   IN  UINTN            TxStringLen\r
   );\r
 \r
-/**\r
-  Translate the status code in HTTP message to EFI_HTTP_STATUS_CODE defined \r
-  in UEFI 2.5 specification.\r
-\r
-  @param[in]  StatusCode         The status code value in HTTP message.\r
-\r
-  @return                        Value defined in EFI_HTTP_STATUS_CODE .\r
-\r
-**/\r
-EFI_HTTP_STATUS_CODE\r
-HttpMappingToStatusCode (\r
-  IN UINTN                  StatusCode\r
-  );\r
-\r
 /**\r
   Check whether the user's token or event has already\r
   been enqueue on HTTP Tx or Rx Token list.\r
@@ -556,24 +543,6 @@ HttpTcpTokenCleanup (
   IN  HTTP_TOKEN_WRAP      *Wrap\r
   );\r
 \r
-/**\r
-  Generate HTTP request string.\r
-\r
-  @param[in]  HttpInstance       Pointer to HTTP_PROTOCOL structure.\r
-  @param[in]  Message            Pointer to storage containing HTTP message data.\r
-  @param[in]  Url                The URL of a remote host.\r
-\r
-  @return     Pointer to the created HTTP request string.\r
-  @return     NULL if any error occured.\r
-\r
-**/\r
-CHAR8 *\r
-HttpGenRequestString (\r
-  IN  HTTP_PROTOCOL        *HttpInstance,\r
-  IN  EFI_HTTP_MESSAGE     *Message,\r
-  IN  CHAR8                *Url\r
-  );\r
-\r
 /**\r
   The work function of EfiHttpResponse().\r
 \r
index 70e993546c4af98094f187ae9509f009fd2c6005..7f719558a2c3e36e6f09486041ba38049d3fbaab 100644 (file)
@@ -2,6 +2,7 @@
   The header files of Http Utilities functions for HttpUtilities driver.\r
 \r
   Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -27,6 +28,7 @@
 #include <Library/BaseLib.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/HttpLib.h>\r
 \r
 //\r
 // Consumed Protocols\r
 //\r
 extern EFI_HTTP_UTILITIES_PROTOCOL mHttpUtilitiesProtocol;\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
-\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
-\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
-\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
-\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
-\r
 /**\r
   Create HTTP header based on a combination of seed header, fields\r
   to delete, and fields to append.\r
index ffdbcd54e5e176cabc61bb4d23fd1515cd7bdf8a..3f7551a302d92f730064f236b348e353a2aae3a3 100644 (file)
@@ -2,6 +2,7 @@
 #  Implementation of EFI Http Utilities Protocol interfaces.\r
 #\r
 #  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+#  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -30,7 +31,6 @@
 [Sources]\r
   HttpUtilitiesDxe.h\r
   HttpUtilitiesDxe.c\r
-  HttpUtilitiesImpl.c\r
   HttpUtilitiesProtocol.c\r
 \r
 [LibraryClasses]\r
@@ -41,6 +41,7 @@
   BaseLib\r
   UefiLib\r
   DebugLib\r
+  HttpLib\r
 \r
 [Protocols]\r
   gEfiHttpUtilitiesProtocolGuid               ## PRODUCES\r
diff --git a/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesImpl.c b/NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesImpl.c
deleted file mode 100644 (file)
index adb50af..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-/** @file\r
-  The functions for HttpUtilities driver.\r
-\r
-  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
-\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 "HttpUtilitiesDxe.h"\r
-\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
-/**\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
-/**\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
-/**\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
-/**\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
-    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
-/**\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
-  //\r
-  // Replace ':' with 0\r
-  //\r
-  *(FieldValueStr - 1) = 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
index a83c9633fc0297def5865faa498fead555b17c9e..739d3b753cddd5ca469ed461ca619d8183e0c03e 100644 (file)
@@ -2,6 +2,7 @@
   Implementation of EFI_HTTP_PROTOCOL protocol interfaces.\r
 \r
   Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<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
@@ -122,8 +123,8 @@ HttpUtilitiesBuild (
       //\r
       // Check whether each SeedHeaderFields member is in DeleteList\r
       //\r
-      if (IsValidHttpHeader( DeleteList, DeleteCount, SeedHeaderFields[Index].FieldName)) {\r
-        Status = SetFieldNameAndValue (\r
+      if (HttpIsValidHttpHeader( DeleteList, DeleteCount, SeedHeaderFields[Index].FieldName)) {\r
+        Status = HttpSetFieldNameAndValue (\r
                    &TempHeaderFields[TempFieldCount], \r
                    SeedHeaderFields[Index].FieldName, \r
                    SeedHeaderFields[Index].FieldValue\r
@@ -149,7 +150,7 @@ HttpUtilitiesBuild (
   }\r
 \r
   for (Index = 0; Index < TempFieldCount; Index++) {\r
-    Status = SetFieldNameAndValue (\r
+    Status = HttpSetFieldNameAndValue (\r
                &NewHeaderFields[Index], \r
                TempHeaderFields[Index].FieldName, \r
                TempHeaderFields[Index].FieldValue\r
@@ -162,9 +163,9 @@ HttpUtilitiesBuild (
   NewFieldCount = TempFieldCount;\r
 \r
   for (Index = 0; Index < AppendCount; Index++) {\r
-    HttpHeader = FindHttpHeader (NewHeaderFields, NewFieldCount, AppendList[Index]->FieldName);\r
+    HttpHeader = HttpFindHeader (NewFieldCount, NewHeaderFields, AppendList[Index]->FieldName);\r
     if (HttpHeader != NULL) {\r
-      Status = SetFieldNameAndValue (\r
+      Status = HttpSetFieldNameAndValue (\r
                  HttpHeader, \r
                  AppendList[Index]->FieldName, \r
                  AppendList[Index]->FieldValue\r
@@ -173,7 +174,7 @@ HttpUtilitiesBuild (
         goto ON_EXIT;\r
       }\r
     } else {\r
-      Status = SetFieldNameAndValue (\r
+      Status = HttpSetFieldNameAndValue (\r
                  &NewHeaderFields[NewFieldCount], \r
                  AppendList[Index]->FieldName, \r
                  AppendList[Index]->FieldValue\r
@@ -251,15 +252,15 @@ HttpUtilitiesBuild (
   //\r
 ON_EXIT:\r
   if (SeedHeaderFields != NULL) {\r
-    FreeHeaderFields(SeedHeaderFields, SeedFieldCount);\r
+    HttpFreeHeaderFields(SeedHeaderFields, SeedFieldCount);\r
   }\r
   \r
   if (TempHeaderFields != NULL) {\r
-    FreeHeaderFields(TempHeaderFields, TempFieldCount);\r
+    HttpFreeHeaderFields(TempHeaderFields, TempFieldCount);\r
   }\r
 \r
   if (NewHeaderFields != NULL) {\r
-    FreeHeaderFields(NewHeaderFields, NewFieldCount);\r
+    HttpFreeHeaderFields(NewHeaderFields, NewFieldCount);\r
   }\r
   \r
   return Status;\r
@@ -332,7 +333,7 @@ HttpUtilitiesParse (
   while (TRUE) {\r
     FieldName     = NULL;\r
     FieldValue    = NULL;\r
-    NextToken = GetFieldNameAndValue (Token, &FieldName, &FieldValue);\r
+    NextToken = HttpGetFieldNameAndValue (Token, &FieldName, &FieldValue);\r
     Token     = NextToken;\r
     if (FieldName == NULL || FieldValue == NULL) {\r
       break;\r
@@ -365,16 +366,16 @@ HttpUtilitiesParse (
   while (Index < *FieldCount) {\r
     FieldName     = NULL;\r
     FieldValue    = NULL;\r
-    NextToken = GetFieldNameAndValue (Token, &FieldName, &FieldValue);\r
+    NextToken = HttpGetFieldNameAndValue (Token, &FieldName, &FieldValue);\r
     Token     = NextToken;\r
     if (FieldName == NULL || FieldValue == NULL) {\r
       break;\r
     }\r
 \r
-    Status = SetFieldNameAndValue (&(*HeaderFields)[Index], FieldName, FieldValue);\r
+    Status = HttpSetFieldNameAndValue (&(*HeaderFields)[Index], FieldName, FieldValue);\r
     if (EFI_ERROR (Status)) {\r
       *FieldCount = 0;\r
-      FreeHeaderFields (*HeaderFields, Index);\r
+      HttpFreeHeaderFields (*HeaderFields, Index);\r
       goto ON_EXIT;\r
     }\r
     \r