Hi, Samer

After the review we think it's ok to put these interfaces to the existing 
HttpLib and it could be extend in future if necessary. And there should be a 
patch to update HttpDxe, HttpUtilityDxe and HttpBootDxe drivers to consume the 
new library interfaces. Could you please recreate a new patch for that?

Thanks
Siyuan

> -----Original Message-----
> From: Samer El-Haj-Mahmoud [mailto:samer.el-haj-mahm...@hpe.com]
> Sent: Friday, February 19, 2016 8:49 AM
> To: edk2-devel@lists.01.org
> Cc: Fu, Siyuan <siyuan...@intel.com>; Samer El-Haj-Mahmoud <samer.el-haj-
> mahm...@hpe.com>; Samer El-Haj-Mahmoud <el...@hpe.com>
> Subject: [PATCH] MdeModulePkg: Add HttpUtilLib
> 
> Add new HttpUtilLib that contains helper functions for HTTP
> Request/Response processing.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Samer El-Haj-Mahmoud <el...@hpe.com>
> ---
>  MdeModulePkg/Include/Library/HttpUtilLib.h         | 140 ++++++
>  .../Library/DxeHttpUtilLib/DxeHttpUtilLib.c        | 525
> +++++++++++++++++++++
>  .../Library/DxeHttpUtilLib/DxeHttpUtilLib.h        |  34 ++
>  .../Library/DxeHttpUtilLib/DxeHttpUtilLib.inf      |  48 ++
>  MdeModulePkg/MdeModulePkg.dec                      |   6 +
>  5 files changed, 753 insertions(+)
>  create mode 100644 MdeModulePkg/Include/Library/HttpUtilLib.h
>  create mode 100644
> MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.c
>  create mode 100644
> MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.h
>  create mode 100644
> MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.inf
> 
> diff --git a/MdeModulePkg/Include/Library/HttpUtilLib.h
> b/MdeModulePkg/Include/Library/HttpUtilLib.h
> new file mode 100644
> index 0000000..db3166d
> --- /dev/null
> +++ b/MdeModulePkg/Include/Library/HttpUtilLib.h
> @@ -0,0 +1,140 @@
> +/** @file
> +  Header file for HTTP helper functions for Messages request/responses.
> +
> + (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
> + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD
> License
> + which accompanies this distribution.  The full text of the license may be
> found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef __HTTP_UTIL_LIB_H__
> +#define __HTTP_UTIL_LIB_H__
> +
> +#include <Protocol/Http.h>
> +
> +///
> +/// Local Host IP address
> +///
> +#define LOCAL_HOST             "127.0.0.1"
> +
> +///
> +/// HTTP Request Format Strings
> +///
> +
> +#define HTTP_EOL           "\r\n"
> +
> +#define HTTP_REQUEST_LINE_FORMAT  "%a %a %a"HTTP_EOL
> +
> +#define HTTP_HEADER_FIELD_FORMAT  "%a: %a"HTTP_EOL
> +
> +
> +/**
> +  Find a specified header field according to the field name.
> +
> +  @param[in]   HeaderCount      Number of HTTP header structures in
> Headers list.
> +  @param[in]   Headers          Array containing list of HTTP headers.
> +  @param[in]   FieldName        Null terminated string which describes a 
> field
> name.
> +
> +  @return    Pointer to the found header or NULL.
> +
> +**/
> +EFI_HTTP_HEADER *
> +HttpFindHeader (
> +  IN  UINTN                HeaderCount,
> +  IN  EFI_HTTP_HEADER      *Headers,
> +  IN  CHAR8                *FieldName
> +  );
> +
> +/**
> +  Set FieldName and FieldValue into specified HttpHeader.
> +
> +  @param[in,out]  HttpHeader          Specified HttpHeader.
> +  @param[in]      FieldName           FieldName of this HttpHeader, a NULL
> terminated ASCII string.
> +  @param[in]      FieldValue          FieldValue of this HttpHeader, a NULL
> terminated ASCII string.
> +
> +
> +  @retval EFI_SUCCESS             The FieldName and FieldValue are set into
> HttpHeader successfully.
> +  @retval EFI_OUT_OF_RESOURCES    Failed to allocate resources.
> +
> +**/
> +EFI_STATUS
> +SetFieldNameAndValue (
> +   IN  OUT   EFI_HTTP_HEADER       *HttpHeader,
> +   IN  CONST CHAR8                 *FieldName,
> +   IN  CONST CHAR8                 *FieldValue
> +  );
> +
> +/**
> +  Get one key/value header pair from the raw string.
> +
> +  @param[in]  String             Pointer to the raw string.
> +  @param[out] FieldName          Points directly to field name within
> 'HttpHeader'.
> +  @param[out] FieldValue         Points directly to field value within
> 'HttpHeader'.
> +
> +  @return     Pointer to the next raw string.
> +  @return     NULL if no key/value header pair from this raw string.
> +
> +**/
> +CHAR8 *
> +GetFieldNameAndValue (
> +  IN  CHAR8   *String,
> +  OUT CHAR8   **FieldName,
> +  OUT CHAR8   **FieldValue
> +  );
> +
> +/**
> +  Free existing HeaderFields.
> +
> +  @param[in]  HeaderFields       Pointer to array of key/value header pairs
> waiting for free.
> +  @param[in]  FieldCount         The number of header pairs in HeaderFields.
> +
> +**/
> +VOID
> +FreeHeaderFields (
> +  IN  EFI_HTTP_HEADER  *HeaderFields,
> +  IN  UINTN            FieldCount
> +  );
> +
> +/**
> +  Generate HTTP request string.
> +
> +  @param[in]   Message            Pointer to storage containing HTTP message
> data.
> +  @param[in]   Url                The URL of a remote host.
> +  @param[out]  RequestString      Pointer to the created HTTP request string.
> +                                  NULL if any error occured.
> +
> +  @return 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
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +HttpGenRequestString (
> +  IN  CONST EFI_HTTP_MESSAGE        *Message,
> +  IN  CONST CHAR8                   *Url,
> +  OUT CHAR8                         **RequestString
> +  );
> +
> +/**
> +  Translate the status code in HTTP message to EFI_HTTP_STATUS_CODE
> defined
> +  in UEFI Specification.
> +
> +  @param[in]  StatusCode         The status code value in HTTP message.
> +
> +  @return                        Value defined in EFI_HTTP_STATUS_CODE .
> +
> +**/
> +EFI_HTTP_STATUS_CODE
> +HttpMappingToStatusCode (
> +  IN UINTN                  StatusCode
> +  );
> +
> +#endif
> +
> diff --git a/MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.c
> b/MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.c
> new file mode 100644
> index 0000000..0fd108d
> --- /dev/null
> +++ b/MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.c
> @@ -0,0 +1,525 @@
> +/** @file
> +
> + Helper functions for HTTP Messages Request/Responses.
> +
> + (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
> + Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
> +
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD
> License
> + which accompanies this distribution.  The full text of the license may be
> found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +#include "DxeHttpUtilLib.h"
> +
> +
> +/**
> +  Get the next string, which is distinguished by specified seperator.
> +
> +  @param[in]  String             Pointer to the string.
> +  @param[in]  Seperator          Specified seperator used to distinguish 
> where is
> the beginning
> +                                 of next string.
> +
> +  @return     Pointer to the next string.
> +  @return     NULL if not find or String is NULL.
> +
> +**/
> +CHAR8 *
> +AsciiStrGetNextToken (
> +  IN CONST CHAR8 *String,
> +  IN       CHAR8 Seperator
> +  )
> +{
> +  CONST CHAR8 *Token;
> +
> +  Token = String;
> +  while (TRUE) {
> +    if (*Token == 0) {
> +      return NULL;
> +    }
> +    if (*Token == Seperator) {
> +      return (CHAR8 *)(Token + 1);
> +    }
> +    Token++;
> +  }
> +}
> +
> +/**
> +  Find a specified header field according to the field name.
> +
> +  @param[in]   HeaderCount      Number of HTTP header structures in
> Headers list.
> +  @param[in]   Headers          Array containing list of HTTP headers.
> +  @param[in]   FieldName        Null terminated string which describes a 
> field
> name.
> +
> +  @return    Pointer to the found header or NULL.
> +
> +**/
> +EFI_HTTP_HEADER *
> +HttpFindHeader (
> +  IN  UINTN                HeaderCount,
> +  IN  EFI_HTTP_HEADER      *Headers,
> +  IN  CHAR8                *FieldName
> +  )
> +{
> +  UINTN                 Index;
> +
> +  if (HeaderCount == 0 || Headers == NULL || FieldName == NULL) {
> +    return NULL;
> +  }
> +
> +  for (Index = 0; Index < HeaderCount; Index++){
> +    //
> +    // Field names are case-insensitive (RFC 2616).
> +    //
> +    if (AsciiStriCmp (Headers[Index].FieldName, FieldName) == 0) {
> +      return &Headers[Index];
> +    }
> +  }
> +  return NULL;
> +}
> +
> +/**
> +  Set FieldName and FieldValue into specified HttpHeader.
> +
> +  @param[in,out]  HttpHeader      Specified HttpHeader.
> +  @param[in]  FieldName           FieldName of this HttpHeader, a NULL
> terminated ASCII string.
> +  @param[in]  FieldValue          FieldValue of this HttpHeader, a NULL
> terminated ASCII string.
> +
> +
> +  @retval EFI_SUCCESS             The FieldName and FieldValue are set into
> HttpHeader successfully.
> +  @retval EFI_OUT_OF_RESOURCES    Failed to allocate resources.
> +
> +**/
> +EFI_STATUS
> +SetFieldNameAndValue (
> +  IN  OUT   EFI_HTTP_HEADER       *HttpHeader,
> +  IN  CONST CHAR8                 *FieldName,
> +  IN  CONST CHAR8                 *FieldValue
> +  )
> +{
> +  UINTN                       FieldNameSize;
> +  UINTN                       FieldValueSize;
> +
> +  if (HttpHeader->FieldName != NULL) {
> +    FreePool (HttpHeader->FieldName);
> +  }
> +  if (HttpHeader->FieldValue != NULL) {
> +    FreePool (HttpHeader->FieldValue);
> +  }
> +
> +  FieldNameSize = AsciiStrSize (FieldName);
> +  HttpHeader->FieldName = AllocateZeroPool (FieldNameSize);
> +  if (HttpHeader->FieldName == NULL) {
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +  CopyMem (HttpHeader->FieldName, FieldName, FieldNameSize);
> +  HttpHeader->FieldName[FieldNameSize - 1] = 0;
> +
> +  FieldValueSize = AsciiStrSize (FieldValue);
> +  HttpHeader->FieldValue = AllocateZeroPool (FieldValueSize);
> +  if (HttpHeader->FieldValue == NULL) {
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +  CopyMem (HttpHeader->FieldValue, FieldValue, FieldValueSize);
> +  HttpHeader->FieldValue[FieldValueSize - 1] = 0;
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/**
> +  Get one key/value header pair from the raw string.
> +
> +  @param[in]  String             Pointer to the raw string.
> +  @param[out] FieldName          Points directly to field name within
> 'HttpHeader'.
> +  @param[out] FieldValue         Points directly to field value within
> 'HttpHeader'.
> +
> +  @return     Pointer to the next raw string.
> +  @return     NULL if no key/value header pair from this raw string.
> +
> +**/
> +CHAR8 *
> +GetFieldNameAndValue (
> +  IN  CHAR8   *String,
> +  OUT CHAR8   **FieldName,
> +  OUT CHAR8   **FieldValue
> +  )
> +{
> +  CHAR8  *FieldNameStr;
> +  CHAR8  *FieldValueStr;
> +  CHAR8  *StrPtr;
> +
> +  if (String == NULL || FieldName == NULL || FieldValue == NULL) {
> +    return NULL;
> +  }
> +
> +  *FieldName    = NULL;
> +  *FieldValue   = NULL;
> +  FieldNameStr  = NULL;
> +  FieldValueStr = NULL;
> +  StrPtr        = NULL;
> +
> +  //
> +  // Each header field consists of a name followed by a colon (":") and the
> field value.
> +  //
> +  FieldNameStr = String;
> +  FieldValueStr = AsciiStrGetNextToken (FieldNameStr, ':');
> +  if (FieldValueStr == NULL) {
> +    return NULL;
> +  }
> +
> +  //
> +  // Replace ':' with 0
> +  //
> +  *(FieldValueStr - 1) = 0;
> +
> +  //
> +  // The field value MAY be preceded by any amount of LWS, though a single
> SP is preferred.
> +  //
> +  while (TRUE) {
> +    if (*FieldValueStr == ' ' || *FieldValueStr == '\t') {
> +      FieldValueStr ++;
> +    } else if (*FieldValueStr == '\r' && *(FieldValueStr + 1) == '\n' &&
> +               (*(FieldValueStr + 2) == ' ' || *(FieldValueStr + 2) == 
> '\t')) {
> +      FieldValueStr = FieldValueStr + 3;
> +    } else {
> +      break;
> +    }
> +  }
> +
> +  //
> +  // Header fields can be extended over multiple lines by preceding each
> extra
> +  // line with at least one SP or HT.
> +  //
> +  StrPtr = FieldValueStr;
> +  do {
> +    StrPtr = AsciiStrGetNextToken (StrPtr, '\r');
> +    if (StrPtr == NULL || *StrPtr != '\n') {
> +      return NULL;
> +    }
> +
> +    StrPtr++;
> +  } while (*StrPtr == ' ' || *StrPtr == '\t');
> +
> +  //
> +  // Replace '\r' with 0
> +  //
> +  *(StrPtr - 2) = 0;
> +
> +  //
> +  // Get FieldName and FieldValue.
> +  //
> +  *FieldName = FieldNameStr;
> +  *FieldValue = FieldValueStr;
> +
> +  return StrPtr;
> +}
> +
> +/**
> +  Free existing HeaderFields.
> +
> +  @param[in]  HeaderFields       Pointer to array of key/value header pairs
> waitting for free.
> +  @param[in]  FieldCount         The number of header pairs in HeaderFields.
> +
> +**/
> +VOID
> +FreeHeaderFields (
> +  IN  EFI_HTTP_HEADER  *HeaderFields,
> +  IN  UINTN            FieldCount
> +  )
> +{
> +  UINTN                       Index;
> +
> +  if (HeaderFields != NULL) {
> +    for (Index = 0; Index < FieldCount; Index++) {
> +      if (HeaderFields[Index].FieldName != NULL) {
> +        FreePool (HeaderFields[Index].FieldName);
> +      }
> +      if (HeaderFields[Index].FieldValue != NULL) {
> +        FreePool (HeaderFields[Index].FieldValue);
> +      }
> +    }
> +
> +    FreePool (HeaderFields);
> +  }
> +}
> +
> +/**
> +  Generate HTTP request string.
> +
> +  @param[in]   Message            Pointer to storage containing HTTP message
> data.
> +  @param[in]   Url                The URL of a remote host.
> +  @param[out]  RequestString      Pointer to the created HTTP request string.
> +                                  NULL if any error occured.
> +
> +  @return 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
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +HttpGenRequestString (
> +  IN  CONST EFI_HTTP_MESSAGE        *Message,
> +  IN  CONST CHAR8                   *Url,
> +  OUT CHAR8                         **Request
> +  )
> +{
> +  EFI_STATUS                       Status;
> +  UINTN                            StrLength;
> +  CHAR8                            *RequestPtr;
> +  UINTN                            HttpHdrSize;
> +  UINTN                            MsgSize;
> +  BOOLEAN                          Success;
> +  VOID                             *HttpHdr;
> +  EFI_HTTP_HEADER                  **AppendList;
> +  UINTN                            Index;
> +  EFI_HTTP_UTILITIES_PROTOCOL      *mHttpUtilitiesProtocol = NULL;
> +
> +
> +  ASSERT (Message != NULL);
> +
> +  *Request = NULL;
> +  MsgSize = 0;
> +  Success = FALSE;
> +  HttpHdr = NULL;
> +  AppendList = NULL;
> +
> +  //
> +  // Locate the HTTP_UTILITIES protocol.
> +  //
> +  Status = gBS->LocateProtocol (
> +                  &gEfiHttpUtilitiesProtocolGuid,
> +                  NULL,
> +                  (VOID **)&mHttpUtilitiesProtocol
> +                  );
> +
> +  if (EFI_ERROR(Status)) {
> +    DEBUG ((DEBUG_ERROR,"%a: Failed to locate Http Utilities protocol.
> Status = %r.\n", __FUNCTION__, Status));
> +    return Status;
> +  }
> +
> +  //
> +  // Build AppendList to send into HttpUtilitiesBuild
> +  //
> +  AppendList = AllocateZeroPool (sizeof (EFI_HTTP_HEADER *) * (Message-
> >HeaderCount));
> +  if (AppendList == NULL) {
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  for(Index = 0; Index < Message->HeaderCount; Index++){
> +    AppendList[Index] = &Message->Headers[Index];
> +  }
> +
> +  //
> +  // Build raw HTTP Headers
> +  //
> +  Status = mHttpUtilitiesProtocol->Build(
> +              mHttpUtilitiesProtocol,
> +              0,
> +              NULL,
> +              0,
> +              NULL,
> +              Message->HeaderCount,
> +              AppendList,
> +              &HttpHdrSize,
> +              &HttpHdr
> +              );
> +
> +  if (AppendList != NULL)
> +    FreePool(AppendList);
> +
> +  if (EFI_ERROR (Status) || HttpHdr == NULL){
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  //
> +  // Calculate HTTP message length.
> +  //
> +  MsgSize = Message->BodyLength + HTTP_METHOD_MAXIMUM_LEN +
> AsciiStrLen (Url) +
> +            AsciiStrLen (HTTP_VERSION_CRLF_STR) + HttpHdrSize;
> +
> +
> +  *Request = AllocateZeroPool (MsgSize);
> +  if (*Request == NULL) {
> +    goto Exit;
> +  }
> +
> +  RequestPtr = *Request;
> +  //
> +  // Construct header request
> +  //
> +  switch (Message->Data.Request->Method) {
> +  case HttpMethodGet:
> +    StrLength = sizeof (HTTP_METHOD_GET) - 1;
> +    CopyMem (RequestPtr, HTTP_METHOD_GET, StrLength);
> +    RequestPtr += StrLength;
> +    break;
> +  case HttpMethodPut:
> +    StrLength = sizeof (HTTP_METHOD_PUT) - 1;
> +    CopyMem (RequestPtr, HTTP_METHOD_PUT, StrLength);
> +    RequestPtr += StrLength;
> +    break;
> +  case HttpMethodPatch:
> +    StrLength = sizeof (HTTP_METHOD_PATCH) - 1;
> +    CopyMem (RequestPtr, HTTP_METHOD_PATCH, StrLength);
> +    RequestPtr += StrLength;
> +    break;
> +  case HttpMethodPost:
> +    StrLength = sizeof (HTTP_METHOD_POST) - 1;
> +    CopyMem (RequestPtr, HTTP_METHOD_POST, StrLength);
> +    RequestPtr += StrLength;
> +    break;
> +  case HttpMethodDelete:
> +    StrLength = sizeof (HTTP_METHOD_DELETE) - 1;
> +    CopyMem (RequestPtr, HTTP_METHOD_DELETE, StrLength);
> +    RequestPtr += StrLength;
> +    break;
> +  default:
> +    ASSERT (FALSE);
> +    goto Exit;
> +  }
> +
> +  StrLength = AsciiStrLen(EMPTY_SPACE);
> +  CopyMem (RequestPtr, EMPTY_SPACE, StrLength);
> +  RequestPtr += StrLength;
> +
> +  StrLength = AsciiStrLen (Url);
> +  CopyMem (RequestPtr, Url, StrLength);
> +  RequestPtr += StrLength;
> +
> +  StrLength = sizeof (HTTP_VERSION_CRLF_STR) - 1;
> +  CopyMem (RequestPtr, HTTP_VERSION_CRLF_STR, StrLength);
> +  RequestPtr += StrLength;
> +
> +  //
> +  // Construct header
> +  //
> +  CopyMem (RequestPtr, HttpHdr, HttpHdrSize);
> +  RequestPtr += HttpHdrSize;
> +
> +  //
> +  // Done
> +  //
> +  *RequestPtr = 0;
> +  Success     = TRUE;
> +
> +Exit:
> +
> +  if (!Success) {
> +    if (*Request != NULL) {
> +      FreePool(*Request);
> +    }
> +    *Request = NULL;
> +  }
> +
> +  if (HttpHdr != NULL) {
> +    FreePool (HttpHdr);
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/**
> +  Translate the status code in HTTP message to EFI_HTTP_STATUS_CODE
> defined
> +  in UEFI 2.5 specification.
> +
> +  @param[in]  StatusCode         The status code value in HTTP message.
> +
> +  @return                        Value defined in EFI_HTTP_STATUS_CODE .
> +
> +**/
> +EFI_HTTP_STATUS_CODE
> +HttpMappingToStatusCode (
> +  IN UINTN                  StatusCode
> +  )
> +{
> +  switch (StatusCode) {
> +  case 100:
> +    return HTTP_STATUS_100_CONTINUE;
> +  case 101:
> +    return HTTP_STATUS_101_SWITCHING_PROTOCOLS;
> +  case 200:
> +    return HTTP_STATUS_200_OK;
> +  case 201:
> +    return HTTP_STATUS_201_CREATED;
> +  case 202:
> +    return HTTP_STATUS_202_ACCEPTED;
> +  case 203:
> +    return HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION;
> +  case 204:
> +    return HTTP_STATUS_204_NO_CONTENT;
> +  case 205:
> +    return HTTP_STATUS_205_RESET_CONTENT;
> +  case 206:
> +    return HTTP_STATUS_206_PARTIAL_CONTENT;
> +  case 300:
> +    return HTTP_STATUS_300_MULTIPLE_CHIOCES;
> +  case 301:
> +    return HTTP_STATUS_301_MOVED_PERMANENTLY;
> +  case 302:
> +    return HTTP_STATUS_302_FOUND;
> +  case 303:
> +    return HTTP_STATUS_303_SEE_OTHER;
> +  case 304:
> +    return HTTP_STATUS_304_NOT_MODIFIED;
> +  case 305:
> +    return HTTP_STATUS_305_USE_PROXY;
> +  case 307:
> +    return HTTP_STATUS_307_TEMPORARY_REDIRECT;
> +  case 400:
> +    return HTTP_STATUS_400_BAD_REQUEST;
> +  case 401:
> +    return HTTP_STATUS_401_UNAUTHORIZED;
> +  case 402:
> +    return HTTP_STATUS_402_PAYMENT_REQUIRED;
> +  case 403:
> +    return HTTP_STATUS_403_FORBIDDEN;
> +  case 404:
> +    return HTTP_STATUS_404_NOT_FOUND;
> +  case 405:
> +    return HTTP_STATUS_405_METHOD_NOT_ALLOWED;
> +  case 406:
> +    return HTTP_STATUS_406_NOT_ACCEPTABLE;
> +  case 407:
> +    return HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED;
> +  case 408:
> +    return HTTP_STATUS_408_REQUEST_TIME_OUT;
> +  case 409:
> +    return HTTP_STATUS_409_CONFLICT;
> +  case 410:
> +    return HTTP_STATUS_410_GONE;
> +  case 411:
> +    return HTTP_STATUS_411_LENGTH_REQUIRED;
> +  case 412:
> +    return HTTP_STATUS_412_PRECONDITION_FAILED;
> +  case 413:
> +    return HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE;
> +  case 414:
> +    return HTTP_STATUS_414_REQUEST_URI_TOO_LARGE;
> +  case 415:
> +    return HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE;
> +  case 416:
> +    return HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED;
> +  case 417:
> +    return HTTP_STATUS_417_EXPECTATION_FAILED;
> +  case 500:
> +    return HTTP_STATUS_500_INTERNAL_SERVER_ERROR;
> +  case 501:
> +    return HTTP_STATUS_501_NOT_IMPLEMENTED;
> +  case 502:
> +    return HTTP_STATUS_502_BAD_GATEWAY;
> +  case 503:
> +    return HTTP_STATUS_503_SERVICE_UNAVAILABLE;
> +  case 504:
> +    return HTTP_STATUS_504_GATEWAY_TIME_OUT;
> +  case 505:
> +    return HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED;
> +
> +  default:
> +    return HTTP_STATUS_UNSUPPORTED_STATUS;
> +  }
> +}
> diff --git a/MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.h
> b/MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.h
> new file mode 100644
> index 0000000..ed56907
> --- /dev/null
> +++ b/MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.h
> @@ -0,0 +1,34 @@
> +/** @file
> + Helper functions for HTTP Messages Request/Responses.
> +
> + (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
> +
> + This program and the accompanying materials
> + are licensed and made available under the terms and conditions of the BSD
> License
> + which accompanies this distribution.  The full text of the license may be
> found at
> + http://opensource.org/licenses/bsd-license.php
> +
> + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef __HTTP_LIB_UTIL_H__
> +#define __HTTP_LIB_UTIL_H__
> +
> +#include <Uefi.h>
> +#include <IndustryStandard/Http11.h>
> +#include <Protocol/Http.h>
> +#include <Protocol/HttpUtilities.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/BaseLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/HttpLib.h>
> +#include <Library/HttpUtilLib.h>
> +
> +#define EMPTY_SPACE     " "
> +
> +#endif
> diff --git a/MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.inf
> b/MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.inf
> new file mode 100644
> index 0000000..409e107
> --- /dev/null
> +++ b/MdeModulePkg/Library/DxeHttpUtilLib/DxeHttpUtilLib.inf
> @@ -0,0 +1,48 @@
> +## @file
> +#  HTTP Util Library
> +#
> +# (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
> +#
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the
> BSD License
> +#  which accompanies this distribution.  The full text of the license may be
> found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +#
> +##
> +
> +
> +[Defines]
> +  INF_VERSION                    = 0x00010005
> +  BASE_NAME                      = DxeHttpUtilLib
> +  FILE_GUID                      = bfbed1d6-db9b-35c0-ac68-72927052e35d
> +  MODULE_TYPE                    = DXE_DRIVER
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = HttpUtilLib|DXE_DRIVER UEFI_APPLICATION
> +
> +[Sources]
> +  DxeHttpUtilLib.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> +  UefiLib
> +  UefiBootServicesTableLib
> +  BaseLib
> +  DebugLib
> +  MemoryAllocationLib
> +  BaseMemoryLib
> +  HpDxeLib
> +  HpStrVarArgUtilLib
> +  HttpLib
> +
> +
> +[Protocols]
> +  gEfiHttpUtilitiesProtocolGuid
> +
> +[Depex]
> +  gEfiHttpUtilitiesProtocolGuid
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 5c5a9ee..3861a5a 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -4,6 +4,8 @@
>  # and libraries instances, which are used for those modules.
>  #
>  # Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
> +# (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
> +#
>  # This program and the accompanying materials are licensed and made
> available under
>  # the terms and conditions of the BSD License that accompanies this
> distribution.
>  # The full text of the license may be found at
> @@ -151,6 +153,10 @@
>    #
>    PciHostBridgeLib|Include/Library/PciHostBridgeLib.h
> 
> +  ## @libraryclass  Provides functions to manipulate Http Request/response
> messages fields.
> +  #
> +  HttpUtilLib|Include/Library/HttpUtilLib.h
> +
>  [Guids]
>    ## MdeModule package token space guid
>    # Include/Guid/MdeModulePkgTokenSpace.h
> --
> 2.6.3.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to