NetworkPkg[all]
0.98
|
Data Structures | |
struct | HTTP_IO_HEADER |
Typedefs | |
typedef IN CHAR8 * | Data |
typedef IN CHAR8 IN UINTN | Length |
typedef IN CHAR8 IN UINTN IN VOID * | Context |
Enumerations | |
enum | HTTP_BODY_PARSE_EVENT { BodyParseEventOnData, BodyParseEventOnComplete } |
Functions | |
EFI_STATUS EFIAPI | UriPercentDecode (IN CHAR8 *Buffer, IN UINT32 BufferLength, OUT CHAR8 *ResultBuffer, OUT UINT32 *ResultLength) |
EFI_STATUS EFIAPI | HttpParseUrl (IN CHAR8 *Url, IN UINT32 Length, IN BOOLEAN IsConnectMethod, OUT VOID **UrlParser) |
EFI_STATUS EFIAPI | HttpUrlGetHostName (IN CHAR8 *Url, IN VOID *UrlParser, OUT CHAR8 **HostName) |
EFI_STATUS EFIAPI | HttpUrlGetIp4 (IN CHAR8 *Url, IN VOID *UrlParser, OUT EFI_IPv4_ADDRESS *Ip4Address) |
EFI_STATUS EFIAPI | HttpUrlGetIp6 (IN CHAR8 *Url, IN VOID *UrlParser, OUT EFI_IPv6_ADDRESS *Ip6Address) |
EFI_STATUS EFIAPI | HttpUrlGetPort (IN CHAR8 *Url, IN VOID *UrlParser, OUT UINT16 *Port) |
EFI_STATUS EFIAPI | HttpUrlGetPath (IN CHAR8 *Url, IN VOID *UrlParser, OUT CHAR8 **Path) |
VOID EFIAPI | HttpUrlFreeParser (IN VOID *UrlParser) |
typedef | EFI_STATUS (EFIAPI *HTTP_BODY_PARSER_CALLBACK)(IN HTTP_BODY_PARSE_EVENT EventType |
EFI_STATUS EFIAPI | HttpInitMsgParser (IN EFI_HTTP_METHOD Method, IN EFI_HTTP_STATUS_CODE StatusCode, IN UINTN HeaderCount, IN EFI_HTTP_HEADER *Headers, IN HTTP_BODY_PARSER_CALLBACK Callback, IN VOID *Context, OUT VOID **MsgParser) |
EFI_STATUS EFIAPI | HttpParseMessageBody (IN OUT VOID *MsgParser, IN UINTN BodyLength, IN CHAR8 *Body) |
BOOLEAN EFIAPI | HttpIsMessageComplete (IN VOID *MsgParser) |
EFI_STATUS EFIAPI | HttpGetEntityLength (IN VOID *MsgParser, OUT UINTN *ContentLength) |
VOID EFIAPI | HttpFreeMsgParser (IN VOID *MsgParser) |
EFI_HTTP_HEADER *EFIAPI | HttpFindHeader (IN UINTN HeaderCount, IN EFI_HTTP_HEADER *Headers, IN CHAR8 *FieldName) |
EFI_STATUS EFIAPI | HttpSetFieldNameAndValue (IN OUT EFI_HTTP_HEADER *HttpHeader, IN CONST CHAR8 *FieldName, IN CONST CHAR8 *FieldValue) |
CHAR8 *EFIAPI | HttpGetFieldNameAndValue (IN CHAR8 *String, OUT CHAR8 **FieldName, OUT CHAR8 **FieldValue) |
VOID EFIAPI | HttpFreeHeaderFields (IN EFI_HTTP_HEADER *HeaderFields, IN UINTN FieldCount) |
EFI_STATUS EFIAPI | HttpGenRequestMessage (IN CONST EFI_HTTP_MESSAGE *Message, IN CONST CHAR8 *Url, OUT CHAR8 **RequestMsg, OUT UINTN *RequestMsgSize) |
EFI_HTTP_STATUS_CODE EFIAPI | HttpMappingToStatusCode (IN UINTN StatusCode) |
BOOLEAN EFIAPI | HttpIsValidHttpHeader (IN CHAR8 *DeleteList[], IN UINTN DeleteCount, IN CHAR8 *FieldName) |
HTTP_IO_HEADER * | HttpIoCreateHeader (UINTN MaxHeaderCount) |
VOID | HttpIoFreeHeader (IN HTTP_IO_HEADER *HttpIoHeader) |
EFI_STATUS | HttpIoSetHeader (IN HTTP_IO_HEADER *HttpIoHeader, IN CHAR8 *FieldName, IN CHAR8 *FieldValue) |
This library is used to share code between UEFI network stack modules. It provides the helper routines to parse the HTTP message byte stream.
Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent
typedef IN CHAR8* Data |
typedef IN CHAR8 IN UINTN Length |
typedef EFI_STATUS | ( | EFIAPI * | HTTP_BODY_PARSER_CALLBACK | ) |
A callback function to intercept events during message parser.
This function will be invoked during HttpParseMessageBody() with various events type. An error return status of the callback function will cause the HttpParseMessageBody() aborted.
[in] | EventType | Event type of this callback call. |
[in] | Data | A pointer to data buffer. |
[in] | Length | Length in bytes of the Data. |
[in] | Context | Callback context set by HttpInitMsgParser(). |
EFI_SUCCESS | Continue to parser the message body. |
Others | Abort the parse. |
EFI_HTTP_HEADER* EFIAPI HttpFindHeader | ( | IN UINTN | HeaderCount, |
IN EFI_HTTP_HEADER * | Headers, | ||
IN CHAR8 * | FieldName | ||
) |
Find a specified header field according to the field name.
[in] | HeaderCount | Number of HTTP header structures in Headers list. |
[in] | Headers | Array containing list of HTTP headers. |
[in] | FieldName | Null terminated string which describes a field name. |
VOID EFIAPI HttpFreeHeaderFields | ( | IN EFI_HTTP_HEADER * | HeaderFields, |
IN UINTN | FieldCount | ||
) |
Free existing HeaderFields.
[in] | HeaderFields | Pointer to array of key/value header pairs waiting for free. |
[in] | FieldCount | The number of header pairs in HeaderFields. |
Release the resource of the message parser.
[in] | MsgParser | Pointer to the message parser. |
EFI_STATUS EFIAPI HttpGenRequestMessage | ( | IN CONST EFI_HTTP_MESSAGE * | Message, |
IN CONST CHAR8 * | Url, | ||
OUT CHAR8 ** | RequestMsg, | ||
OUT UINTN * | RequestMsgSize | ||
) |
Generate HTTP request message.
This function will allocate memory for the whole HTTP message and generate a well formatted HTTP Request message in it, include the Request-Line, header fields and also the message body. It is the caller's responsibility to free the buffer returned in *RequestMsg.
[in] | Message | Pointer to the EFI_HTTP_MESSAGE structure which contains the required information to generate the HTTP request message. |
[in] | Url | The URL of a remote host. |
[out] | RequestMsg | Pointer to the created HTTP request message. NULL if any error occurred. |
[out] | RequestMsgSize | Size of the RequestMsg (in bytes). |
EFI_SUCCESS | If HTTP request string was created successfully. |
EFI_OUT_OF_RESOURCES | Failed to allocate resources. |
EFI_INVALID_PARAMETER | The input arguments are invalid. |
EFI_STATUS EFIAPI HttpGetEntityLength | ( | IN VOID * | MsgParser, |
OUT UINTN * | ContentLength | ||
) |
Get the content length of the entity.
Note that in trunk transfer, the entity length is not valid until the whole message body is received.
[in] | MsgParser | Pointer to the message parser. |
[out] | ContentLength | Pointer to store the length of the entity. |
EFI_SUCCESS | Successfully to get the entity length. |
EFI_NOT_READY | Entity length is not valid yet. |
EFI_INVALID_PARAMETER | MsgParser is NULL or ContentLength is NULL. |
CHAR8* EFIAPI HttpGetFieldNameAndValue | ( | IN CHAR8 * | String, |
OUT CHAR8 ** | FieldName, | ||
OUT CHAR8 ** | FieldValue | ||
) |
Get one key/value header pair from the raw string.
[in] | String | Pointer to the raw string. |
[out] | FieldName | Points directly to field name within 'HttpHeader'. |
[out] | FieldValue | Points directly to field value within 'HttpHeader'. |
EFI_STATUS EFIAPI HttpInitMsgParser | ( | IN EFI_HTTP_METHOD | Method, |
IN EFI_HTTP_STATUS_CODE | StatusCode, | ||
IN UINTN | HeaderCount, | ||
IN EFI_HTTP_HEADER * | Headers, | ||
IN HTTP_BODY_PARSER_CALLBACK | Callback, | ||
IN VOID * | Context, | ||
OUT VOID ** | MsgParser | ||
) |
Initialize a HTTP message-body parser.
This function will create and initialize a HTTP message parser according to caller provided HTTP message header information. It is the caller's responsibility to free the buffer returned in *UrlParser by HttpFreeMsgParser().
[in] | Method | The HTTP method (e.g. GET, POST) for this HTTP message. |
[in] | StatusCode | Response status code returned by the remote host. |
[in] | HeaderCount | Number of HTTP header structures in Headers. |
[in] | Headers | Array containing list of HTTP headers. |
[in] | Callback | Callback function that is invoked when parsing the HTTP message-body, set to NULL to ignore all events. |
[in] | Context | Pointer to the context that will be passed to Callback. |
[out] | MsgParser | Pointer to the returned buffer to store the message parser. |
EFI_SUCCESS | Successfully initialized the parser. |
EFI_OUT_OF_RESOURCES | Could not allocate needed resources. |
EFI_INVALID_PARAMETER | MsgParser is NULL or HeaderCount is not NULL but Headers is NULL. |
Others | Failed to initialize the parser. |
HTTP_IO_HEADER* HttpIoCreateHeader | ( | UINTN | MaxHeaderCount | ) |
Create a HTTP_IO_HEADER to hold the HTTP header items.
[in] | MaxHeaderCount | The maximun number of HTTP header in this holder. |
VOID HttpIoFreeHeader | ( | IN HTTP_IO_HEADER * | HttpIoHeader | ) |
Destroy the HTTP_IO_HEADER and release the resources.
[in] | HttpIoHeader | Point to the HTTP header holder to be destroyed. |
EFI_STATUS HttpIoSetHeader | ( | IN HTTP_IO_HEADER * | HttpIoHeader, |
IN CHAR8 * | FieldName, | ||
IN CHAR8 * | FieldValue | ||
) |
Set or update a HTTP header with the field name and corresponding value.
[in] | HttpIoHeader | Point to the HTTP header holder. |
[in] | FieldName | Null terminated string which describes a field name. |
[in] | FieldValue | Null terminated string which describes the corresponding field value. |
EFI_SUCCESS | The HTTP header has been set or updated. |
EFI_INVALID_PARAMETER | Any input parameter is invalid. |
EFI_OUT_OF_RESOURCES | Insufficient resource to complete the operation. |
Other | Unexpected error happened. |
Check whether the message-body is complete or not.
[in] | MsgParser | Pointer to the message parser. |
TRUE | Message-body is complete. |
FALSE | Message-body is not complete. |
BOOLEAN EFIAPI HttpIsValidHttpHeader | ( | IN CHAR8 * | DeleteList[], |
IN UINTN | DeleteCount, | ||
IN CHAR8 * | FieldName | ||
) |
Check whether header field called FieldName is in DeleteList.
[in] | DeleteList | Pointer to array of key/value header pairs. |
[in] | DeleteCount | The number of header pairs. |
[in] | FieldName | Pointer to header field's name. |
EFI_HTTP_STATUS_CODE EFIAPI HttpMappingToStatusCode | ( | IN UINTN | StatusCode | ) |
Translate the status code in HTTP message to EFI_HTTP_STATUS_CODE defined in UEFI 2.5 specification.
[in] | StatusCode | The status code value in HTTP message. |
EFI_STATUS EFIAPI HttpParseMessageBody | ( | IN OUT VOID * | MsgParser, |
IN UINTN | BodyLength, | ||
IN CHAR8 * | Body | ||
) |
Parse message body.
Parse BodyLength of message-body. This function can be called repeatedly to parse the message-body partially.
[in,out] | MsgParser | Pointer to the message parser. |
[in] | BodyLength | Length in bytes of the Body. |
[in] | Body | Pointer to the buffer of the message-body to be parsed. |
EFI_SUCCESS | Successfully parse the message-body. |
EFI_INVALID_PARAMETER | MsgParser is NULL or Body is NULL or BodyLength is 0. |
EFI_ABORTED | Operation aborted. |
Other | Error happened while parsing message body. |
EFI_STATUS EFIAPI HttpParseUrl | ( | IN CHAR8 * | Url, |
IN UINT32 | Length, | ||
IN BOOLEAN | IsConnectMethod, | ||
OUT VOID ** | UrlParser | ||
) |
Create a URL parser for the input URL string.
This function will parse and dereference the input HTTP URL into it components. The original content of the URL won't be modified and the result will be returned in UrlParser, which can be used in other functions like NetHttpUrlGetHostName(). It is the caller's responsibility to free the buffer returned in *UrlParser by HttpUrlFreeParser().
[in] | Url | The pointer to a HTTP URL string. |
[in] | Length | Length of Url in bytes. |
[in] | IsConnectMethod | Whether the Url is used in HTTP CONNECT method or not. |
[out] | UrlParser | Pointer to the returned buffer to store the parse result. |
EFI_SUCCESS | Successfully dereferenced the HTTP URL. |
EFI_INVALID_PARAMETER | UrlParser is NULL or Url is not a valid HTTP URL. |
EFI_OUT_OF_RESOURCES | Could not allocate needed resources. |
EFI_STATUS EFIAPI HttpSetFieldNameAndValue | ( | IN OUT EFI_HTTP_HEADER * | HttpHeader, |
IN CONST CHAR8 * | FieldName, | ||
IN CONST CHAR8 * | FieldValue | ||
) |
Set FieldName and FieldValue into specified HttpHeader.
[in,out] | HttpHeader | Specified HttpHeader. |
[in] | FieldName | FieldName of this HttpHeader, a NULL terminated ASCII string. |
[in] | FieldValue | FieldValue of this HttpHeader, a NULL terminated ASCII string. |
EFI_SUCCESS | The FieldName and FieldValue are set into HttpHeader successfully. |
EFI_INVALID_PARAMETER | The parameter is invalid. |
EFI_OUT_OF_RESOURCES | Failed to allocate resources. |
Release the resource of the URL parser.
[in] | UrlParser | Pointer to the parser. |
EFI_STATUS EFIAPI HttpUrlGetHostName | ( | IN CHAR8 * | Url, |
IN VOID * | UrlParser, | ||
OUT CHAR8 ** | HostName | ||
) |
Get the Hostname from a HTTP URL.
This function will return the HostName according to the Url and previous parse result ,and it is the caller's responsibility to free the buffer returned in *HostName.
[in] | Url | The pointer to a HTTP URL string. |
[in] | UrlParser | URL Parse result returned by NetHttpParseUrl(). |
[out] | HostName | Pointer to a buffer to store the HostName. |
EFI_SUCCESS | Successfully get the required component. |
EFI_INVALID_PARAMETER | Uri is NULL or HostName is NULL or UrlParser is invalid. |
EFI_NOT_FOUND | No hostName component in the URL. |
EFI_OUT_OF_RESOURCES | Could not allocate needed resources. |
EFI_STATUS EFIAPI HttpUrlGetIp4 | ( | IN CHAR8 * | Url, |
IN VOID * | UrlParser, | ||
OUT EFI_IPv4_ADDRESS * | Ip4Address | ||
) |
Get the IPv4 address from a HTTP URL.
This function will return the IPv4 address according to the Url and previous parse result.
[in] | Url | The pointer to a HTTP URL string. |
[in] | UrlParser | URL Parse result returned by NetHttpParseUrl(). |
[out] | Ip4Address | Pointer to a buffer to store the IP address. |
EFI_SUCCESS | Successfully get the required component. |
EFI_INVALID_PARAMETER | Uri is NULL or Ip4Address is NULL or UrlParser is invalid. |
EFI_NOT_FOUND | No IPv4 address component in the URL. |
EFI_OUT_OF_RESOURCES | Could not allocate needed resources. |
EFI_STATUS EFIAPI HttpUrlGetIp6 | ( | IN CHAR8 * | Url, |
IN VOID * | UrlParser, | ||
OUT EFI_IPv6_ADDRESS * | Ip6Address | ||
) |
Get the IPv6 address from a HTTP URL.
This function will return the IPv6 address according to the Url and previous parse result.
[in] | Url | The pointer to a HTTP URL string. |
[in] | UrlParser | URL Parse result returned by NetHttpParseUrl(). |
[out] | Ip6Address | Pointer to a buffer to store the IP address. |
EFI_SUCCESS | Successfully get the required component. |
EFI_INVALID_PARAMETER | Uri is NULL or Ip6Address is NULL or UrlParser is invalid. |
EFI_NOT_FOUND | No IPv6 address component in the URL. |
EFI_OUT_OF_RESOURCES | Could not allocate needed resources. |
EFI_STATUS EFIAPI HttpUrlGetPath | ( | IN CHAR8 * | Url, |
IN VOID * | UrlParser, | ||
OUT CHAR8 ** | Path | ||
) |
Get the Path from a HTTP URL.
This function will return the Path according to the Url and previous parse result,and it is the caller's responsibility to free the buffer returned in *Path.
[in] | Url | The pointer to a HTTP URL string. |
[in] | UrlParser | URL Parse result returned by NetHttpParseUrl(). |
[out] | Path | Pointer to a buffer to store the Path. |
EFI_SUCCESS | Successfully get the required component. |
EFI_INVALID_PARAMETER | Uri is NULL or HostName is NULL or UrlParser is invalid. |
EFI_NOT_FOUND | No hostName component in the URL. |
EFI_OUT_OF_RESOURCES | Could not allocate needed resources. |
EFI_STATUS EFIAPI HttpUrlGetPort | ( | IN CHAR8 * | Url, |
IN VOID * | UrlParser, | ||
OUT UINT16 * | Port | ||
) |
Get the port number from a HTTP URL.
This function will return the port number according to the Url and previous parse result.
[in] | Url | The pointer to a HTTP URL string. |
[in] | UrlParser | URL Parse result returned by NetHttpParseUrl(). |
[out] | Port | Pointer to a buffer to store the port number. |
EFI_SUCCESS | Successfully get the required component. |
EFI_INVALID_PARAMETER | Uri is NULL or Port is NULL or UrlParser is invalid. |
EFI_NOT_FOUND | No port number in the URL. |
EFI_OUT_OF_RESOURCES | Could not allocate needed resources. |
EFI_STATUS EFIAPI UriPercentDecode | ( | IN CHAR8 * | Buffer, |
IN UINT32 | BufferLength, | ||
OUT CHAR8 * | ResultBuffer, | ||
OUT UINT32 * | ResultLength | ||
) |
Decode a percent-encoded URI component to the ASCII character.
Decode the input component in Buffer according to RFC 3986. The caller is responsible to make sure ResultBuffer points to a buffer with size equal or greater than ((AsciiStrSize (Buffer)) in bytes.
[in] | Buffer | The pointer to a percent-encoded URI component. |
[in] | BufferLength | Length of Buffer in bytes. |
[out] | ResultBuffer | Point to the buffer to store the decode result. |
[out] | ResultLength | Length of decoded string in ResultBuffer in bytes. |
EFI_SUCCESS | Successfully decoded the URI. |
EFI_INVALID_PARAMETER | Buffer is not a valid percent-encoded string. |