]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/HttpLib.h
NetworkPkg: Move Network library header file from MdeModulePkg to NetworkPkg
[mirror_edk2.git] / MdeModulePkg / Include / Library / HttpLib.h
diff --git a/MdeModulePkg/Include/Library/HttpLib.h b/MdeModulePkg/Include/Library/HttpLib.h
deleted file mode 100644 (file)
index 93100eb..0000000
+++ /dev/null
@@ -1,481 +0,0 @@
-/** @file\r
-  This library is used to share code between UEFI network stack modules.\r
-  It provides the helper routines to parse the HTTP message byte stream.\r
-\r
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
-(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
-SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef _HTTP_LIB_H_\r
-#define _HTTP_LIB_H_\r
-\r
-#include <Protocol/Http.h>\r
-\r
-\r
-/**\r
-  Decode a percent-encoded URI component to the ASCII character.\r
-\r
-  Decode the input component in Buffer according to RFC 3986. The caller is responsible to make\r
-  sure ResultBuffer points to a buffer with size equal or greater than ((AsciiStrSize (Buffer))\r
-  in bytes.\r
-\r
-  @param[in]    Buffer           The pointer to a percent-encoded URI component.\r
-  @param[in]    BufferLength     Length of Buffer in bytes.\r
-  @param[out]   ResultBuffer     Point to the buffer to store the decode result.\r
-  @param[out]   ResultLength     Length of decoded string in ResultBuffer in bytes.\r
-\r
-  @retval EFI_SUCCESS            Successfully decoded the URI.\r
-  @retval EFI_INVALID_PARAMETER  Buffer is not a valid percent-encoded string.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UriPercentDecode (\r
-  IN      CHAR8            *Buffer,\r
-  IN      UINT32            BufferLength,\r
-     OUT  CHAR8            *ResultBuffer,\r
-     OUT  UINT32           *ResultLength\r
-  );\r
-\r
-/**\r
-  Create a URL parser for the input URL string.\r
-\r
-  This function will parse and dereference the input HTTP URL into it components. The original\r
-  content of the URL won't be modified and the result will be returned in UrlParser, which can\r
-  be used in other functions like NetHttpUrlGetHostName(). It is the caller's responsibility to\r
-  free the buffer returned in *UrlParser by HttpUrlFreeParser().\r
-\r
-  @param[in]    Url                The pointer to a HTTP URL string.\r
-  @param[in]    Length             Length of Url in bytes.\r
-  @param[in]    IsConnectMethod    Whether the Url is used in HTTP CONNECT method or not.\r
-  @param[out]   UrlParser          Pointer to the returned buffer to store the parse result.\r
-\r
-  @retval EFI_SUCCESS              Successfully dereferenced the HTTP URL.\r
-  @retval EFI_INVALID_PARAMETER    UrlParser is NULL or Url is not a valid HTTP URL.\r
-  @retval EFI_OUT_OF_RESOURCES     Could not allocate needed resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HttpParseUrl (\r
-  IN      CHAR8              *Url,\r
-  IN      UINT32             Length,\r
-  IN      BOOLEAN            IsConnectMethod,\r
-     OUT  VOID               **UrlParser\r
-  );\r
-\r
-/**\r
-  Get the Hostname from a HTTP URL.\r
-\r
-  This function will return the HostName according to the Url and previous parse result ,and\r
-  it is the caller's responsibility to free the buffer returned in *HostName.\r
-\r
-  @param[in]    Url                The pointer to a HTTP URL string.\r
-  @param[in]    UrlParser          URL Parse result returned by NetHttpParseUrl().\r
-  @param[out]   HostName           Pointer to a buffer to store the HostName.\r
-\r
-  @retval EFI_SUCCESS              Successfully get the required component.\r
-  @retval EFI_INVALID_PARAMETER    Uri is NULL or HostName is NULL or UrlParser is invalid.\r
-  @retval EFI_NOT_FOUND            No hostName component in the URL.\r
-  @retval EFI_OUT_OF_RESOURCES     Could not allocate needed resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HttpUrlGetHostName (\r
-  IN      CHAR8              *Url,\r
-  IN      VOID               *UrlParser,\r
-     OUT  CHAR8              **HostName\r
-  );\r
-\r
-/**\r
-  Get the IPv4 address from a HTTP URL.\r
-\r
-  This function will return the IPv4 address according to the Url and previous parse result.\r
-\r
-  @param[in]    Url                The pointer to a HTTP URL string.\r
-  @param[in]    UrlParser          URL Parse result returned by NetHttpParseUrl().\r
-  @param[out]   Ip4Address         Pointer to a buffer to store the IP address.\r
-\r
-  @retval EFI_SUCCESS              Successfully get the required component.\r
-  @retval EFI_INVALID_PARAMETER    Uri is NULL or Ip4Address is NULL or UrlParser is invalid.\r
-  @retval EFI_NOT_FOUND            No IPv4 address component in the URL.\r
-  @retval EFI_OUT_OF_RESOURCES     Could not allocate needed resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HttpUrlGetIp4 (\r
-  IN      CHAR8              *Url,\r
-  IN      VOID               *UrlParser,\r
-     OUT  EFI_IPv4_ADDRESS   *Ip4Address\r
-  );\r
-\r
-/**\r
-  Get the IPv6 address from a HTTP URL.\r
-\r
-  This function will return the IPv6 address according to the Url and previous parse result.\r
-\r
-  @param[in]    Url                The pointer to a HTTP URL string.\r
-  @param[in]    UrlParser          URL Parse result returned by NetHttpParseUrl().\r
-  @param[out]   Ip6Address         Pointer to a buffer to store the IP address.\r
-\r
-  @retval EFI_SUCCESS              Successfully get the required component.\r
-  @retval EFI_INVALID_PARAMETER    Uri is NULL or Ip6Address is NULL or UrlParser is invalid.\r
-  @retval EFI_NOT_FOUND            No IPv6 address component in the URL.\r
-  @retval EFI_OUT_OF_RESOURCES     Could not allocate needed resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HttpUrlGetIp6 (\r
-  IN      CHAR8              *Url,\r
-  IN      VOID               *UrlParser,\r
-     OUT  EFI_IPv6_ADDRESS   *Ip6Address\r
-  );\r
-\r
-/**\r
-  Get the port number from a HTTP URL.\r
-\r
-  This function will return the port number according to the Url and previous parse result.\r
-\r
-  @param[in]    Url                The pointer to a HTTP URL string.\r
-  @param[in]    UrlParser          URL Parse result returned by NetHttpParseUrl().\r
-  @param[out]   Port               Pointer to a buffer to store the port number.\r
-\r
-  @retval EFI_SUCCESS              Successfully get the required component.\r
-  @retval EFI_INVALID_PARAMETER    Uri is NULL or Port is NULL or UrlParser is invalid.\r
-  @retval EFI_NOT_FOUND            No port number in the URL.\r
-  @retval EFI_OUT_OF_RESOURCES     Could not allocate needed resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HttpUrlGetPort (\r
-  IN      CHAR8              *Url,\r
-  IN      VOID               *UrlParser,\r
-     OUT  UINT16             *Port\r
-  );\r
-\r
-/**\r
-  Get the Path from a HTTP URL.\r
-\r
-  This function will return the Path according to the Url and previous parse result,and\r
-  it is the caller's responsibility to free the buffer returned in *Path.\r
-\r
-  @param[in]    Url                The pointer to a HTTP URL string.\r
-  @param[in]    UrlParser          URL Parse result returned by NetHttpParseUrl().\r
-  @param[out]   Path               Pointer to a buffer to store the Path.\r
-\r
-  @retval EFI_SUCCESS              Successfully get the required component.\r
-  @retval EFI_INVALID_PARAMETER    Uri is NULL or HostName is NULL or UrlParser is invalid.\r
-  @retval EFI_NOT_FOUND            No hostName component in the URL.\r
-  @retval EFI_OUT_OF_RESOURCES     Could not allocate needed resources.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HttpUrlGetPath (\r
-  IN      CHAR8              *Url,\r
-  IN      VOID               *UrlParser,\r
-     OUT  CHAR8              **Path\r
-  );\r
-\r
-/**\r
-  Release the resource of the URL parser.\r
-\r
-  @param[in]    UrlParser            Pointer to the parser.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-HttpUrlFreeParser (\r
-  IN      VOID               *UrlParser\r
-  );\r
-\r
-//\r
-// HTTP body parser interface.\r
-//\r
-\r
-typedef enum {\r
-  //\r
-  // Part of entity data.\r
-  // Length of entity body in Data.\r
-  //\r
-  BodyParseEventOnData,\r
-  //\r
-  // End of message body.\r
-  // Length is 0 and Data points to next byte after the end of the message.\r
-  //\r
-  BodyParseEventOnComplete\r
-} HTTP_BODY_PARSE_EVENT;\r
-\r
-/**\r
-  A callback function to intercept events during message parser.\r
-\r
-  This function will be invoked during HttpParseMessageBody() with various events type. An error\r
-  return status of the callback function will cause the HttpParseMessageBody() aborted.\r
-\r
-  @param[in]    EventType          Event type of this callback call.\r
-  @param[in]    Data               A pointer to data buffer.\r
-  @param[in]    Length             Length in bytes of the Data.\r
-  @param[in]    Context            Callback context set by HttpInitMsgParser().\r
-\r
-  @retval EFI_SUCCESS              Continue to parser the message body.\r
-  @retval Others                   Abort the parse.\r
-\r
-**/\r
-typedef\r
-EFI_STATUS\r
-(EFIAPI *HTTP_BODY_PARSER_CALLBACK) (\r
-  IN HTTP_BODY_PARSE_EVENT      EventType,\r
-  IN CHAR8                      *Data,\r
-  IN UINTN                      Length,\r
-  IN VOID                       *Context\r
-);\r
-\r
-/**\r
-  Initialize a HTTP message-body parser.\r
-\r
-  This function will create and initialize a HTTP message parser according to caller provided HTTP message\r
-  header information. It is the caller's responsibility to free the buffer returned in *UrlParser by HttpFreeMsgParser().\r
-\r
-  @param[in]    Method             The HTTP method (e.g. GET, POST) for this HTTP message.\r
-  @param[in]    StatusCode         Response status code returned by the remote host.\r
-  @param[in]    HeaderCount        Number of HTTP header structures in Headers.\r
-  @param[in]    Headers            Array containing list of HTTP headers.\r
-  @param[in]    Callback           Callback function that is invoked when parsing the HTTP message-body,\r
-                                   set to NULL to ignore all events.\r
-  @param[in]    Context            Pointer to the context that will be passed to Callback.\r
-  @param[out]   MsgParser          Pointer to the returned buffer to store the message parser.\r
-\r
-  @retval EFI_SUCCESS              Successfully initialized the parser.\r
-  @retval EFI_OUT_OF_RESOURCES     Could not allocate needed resources.\r
-  @retval EFI_INVALID_PARAMETER    MsgParser is NULL or HeaderCount is not NULL but Headers is NULL.\r
-  @retval Others                   Failed to initialize the parser.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HttpInitMsgParser (\r
-  IN     EFI_HTTP_METHOD               Method,\r
-  IN     EFI_HTTP_STATUS_CODE          StatusCode,\r
-  IN     UINTN                         HeaderCount,\r
-  IN     EFI_HTTP_HEADER               *Headers,\r
-  IN     HTTP_BODY_PARSER_CALLBACK     Callback,\r
-  IN     VOID                          *Context,\r
-    OUT  VOID                          **MsgParser\r
-  );\r
-\r
-/**\r
-  Parse message body.\r
-\r
-  Parse BodyLength of message-body. This function can be called repeatedly to parse the message-body partially.\r
-\r
-  @param[in, out]    MsgParser            Pointer to the message parser.\r
-  @param[in]         BodyLength           Length in bytes of the Body.\r
-  @param[in]         Body                 Pointer to the buffer of the message-body to be parsed.\r
-\r
-  @retval EFI_SUCCESS                Successfully parse the message-body.\r
-  @retval EFI_INVALID_PARAMETER      MsgParser is NULL or Body is NULL or BodyLength is 0.\r
-  @retval EFI_ABORTED                Operation aborted.\r
-  @retval Other                      Error happened while parsing message body.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HttpParseMessageBody (\r
-  IN OUT VOID              *MsgParser,\r
-  IN     UINTN             BodyLength,\r
-  IN     CHAR8             *Body\r
-  );\r
-\r
-/**\r
-  Check whether the message-body is complete or not.\r
-\r
-  @param[in]    MsgParser            Pointer to the message parser.\r
-\r
-  @retval TRUE                       Message-body is complete.\r
-  @retval FALSE                      Message-body is not complete.\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-HttpIsMessageComplete (\r
-  IN VOID           *MsgParser\r
-  );\r
-\r
-/**\r
-  Get the content length of the entity.\r
-\r
-  Note that in trunk transfer, the entity length is not valid until the whole message body is received.\r
-\r
-  @param[in]    MsgParser            Pointer to the message parser.\r
-  @param[out]   ContentLength        Pointer to store the length of the entity.\r
-\r
-  @retval EFI_SUCCESS                Successfully to get the entity length.\r
-  @retval EFI_NOT_READY              Entity length is not valid yet.\r
-  @retval EFI_INVALID_PARAMETER      MsgParser is NULL or ContentLength is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-HttpGetEntityLength (\r
-  IN  VOID           *MsgParser,\r
-  OUT UINTN          *ContentLength\r
-  );\r
-\r
-/**\r
-  Release the resource of the message parser.\r
-\r
-  @param[in]    MsgParser            Pointer to the message parser.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-HttpFreeMsgParser (\r
-  IN  VOID           *MsgParser\r
-  );\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_INVALID_PARAMETER   The parameter is invalid.\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 message.\r
-\r
-  This function will allocate memory for the whole HTTP message and generate a\r
-  well formatted HTTP Request message in it, include the Request-Line, header\r
-  fields and also the message body. It is the caller's responsibility to free\r
-  the buffer returned in *RequestMsg.\r
-\r
-  @param[in]   Message            Pointer to the EFI_HTTP_MESSAGE structure which\r
-                                  contains the required information to generate\r
-                                  the HTTP request message.\r
-  @param[in]   Url                The URL of a remote host.\r
-  @param[out]  RequestMsg         Pointer to the created HTTP request message.\r
-                                  NULL if any error occured.\r
-  @param[out]  RequestMsgSize     Size of the RequestMsg (in bytes).\r
-\r
-  @retval 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
-HttpGenRequestMessage (\r
-  IN     CONST EFI_HTTP_MESSAGE        *Message,\r
-  IN     CONST CHAR8                   *Url,\r
-     OUT CHAR8                         **RequestMsg,\r
-     OUT UINTN                         *RequestMsgSize\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