]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/HttpLib.h
ModulePkg/DxeHttpLib: Adding Functions to HttpLib
[mirror_edk2.git] / MdeModulePkg / Include / Library / HttpLib.h
index cd97b644f1e9a975c3da58c62e519e42c0a958cb..af9ab5f012c6b71e8353875bb10856ffee320bbc 100644 (file)
@@ -3,6 +3,7 @@
   It provides the helper routines to parse the HTTP message byte stream.\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<BR>\r
@@ -18,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Protocol/Http.h>\r
 \r
+\r
 /**\r
   Decode a percent-encoded URI component to the ASCII character.\r
   \r
@@ -343,5 +345,132 @@ HttpFreeMsgParser (
   );\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
+EFIAPI\r
+HttpFindHeader (\r
+  IN  UINTN                HeaderCount,\r
+  IN  EFI_HTTP_HEADER      *Headers,\r
+  IN  CHAR8                *FieldName\r
+  );\r
+\r
+/**\r
+  Set FieldName and FieldValue into specified HttpHeader.\r
+\r
+  @param[in,out]  HttpHeader          Specified HttpHeader.\r
+  @param[in]      FieldName           FieldName of this HttpHeader, a NULL terminated ASCII string.\r
+  @param[in]      FieldValue          FieldValue of this HttpHeader, a NULL terminated ASCII string.\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
+EFIAPI\r
+HttpSetFieldNameAndValue (\r
+   IN  OUT   EFI_HTTP_HEADER       *HttpHeader,\r
+   IN  CONST CHAR8                 *FieldName,\r
+   IN  CONST CHAR8                 *FieldValue\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          Points directly to field name within 'HttpHeader'.\r
+  @param[out] FieldValue         Points directly to field value within 'HttpHeader'.\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
+EFIAPI\r
+HttpGetFieldNameAndValue (\r
+  IN     CHAR8   *String,\r
+     OUT CHAR8   **FieldName,\r
+     OUT CHAR8   **FieldValue\r
+  );\r
+\r
+/**\r
+  Free existing HeaderFields.\r
+\r
+  @param[in]  HeaderFields       Pointer to array of key/value header pairs waiting for free.\r
+  @param[in]  FieldCount         The number of header pairs in HeaderFields.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HttpFreeHeaderFields (\r
+  IN  EFI_HTTP_HEADER  *HeaderFields,\r
+  IN  UINTN            FieldCount\r
+  );\r
+\r
+/**\r
+  Generate HTTP request string.\r
+\r
+  @param[in]   Message            Pointer to storage containing HTTP message data.\r
+  @param[in]   Url                The URL of a remote host.\r
+  @param[out]  RequestString      Pointer to the created HTTP request string.\r
+                                  NULL if any error occured.\r
+\r
+  @return EFI_SUCCESS             If HTTP request string was created successfully\r
+  @retval EFI_OUT_OF_RESOURCES    Failed to allocate resources.\r
+  @retval EFI_INVALID_PARAMETER   The input arguments are invalid\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HttpGenRequestString (\r
+  IN     CONST EFI_HTTP_MESSAGE        *Message,\r
+  IN     CONST CHAR8                   *Url,\r
+     OUT CHAR8                         **RequestString\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
+EFIAPI\r
+HttpMappingToStatusCode (\r
+  IN UINTN                  StatusCode\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
+EFIAPI\r
+HttpIsValidHttpHeader (\r
+  IN  CHAR8            *DeleteList[],\r
+  IN  UINTN            DeleteCount,\r
+  IN  CHAR8            *FieldName\r
+  );\r
+\r
+\r
 #endif\r
 \r