]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/HttpDxe/HttpUtilities.h
bd4ef0b1108d1dd6b567dd8a3c1535c7c947ca9e
[mirror_edk2.git] / NetworkPkg / HttpDxe / HttpUtilities.h
1 /** @file
2 The header files of HTTP helper functions for HttpDxe driver.
3
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __EFI_HTTP_UTILITIES_H__
16 #define __EFI_HTTP_UTILITIES_H__
17
18 /**
19 This function is used to manage the headers portion of an HTTP message by providing
20 the ability to add, remove, or replace HTTP headers.
21
22 @param[in] SeedMessageSize Size in bytes of the initial HTTP header. This can be zero.
23 @param[in] SeedMessage Initial raw unformatted HTTP header to be used as a base for
24 building a new unformatted HTTP header. If NULL, SeedMessageSize
25 is ignored. The buffer containing this message will be allocated
26 and released by the caller.
27 @param[in] DeleteCount Number of null-terminated HTTP header field names in DeleteList.
28 @param[in] DeleteList List of null-terminated HTTP header field names to remove from SeedMessage.
29 Only the field names are in this list because the field values are irrelevant
30 to this operation. If NULL, DeleteCount is ignored. The buffer containing the
31 list will be allocated and released by the caller.
32 @param[in] AppendCount Number of header fields in AppendList.
33 @param[in] AppendList List of HTTP headers to populate NewMessage with. If SeedMessage is not NULL,
34 AppendList will be appended to the existing list from SeedMessage in NewMessage.
35 @param[out] NewMessageSize Pointer to the size in bytes of the new unformatted HTTP header in NewMessage.
36 @param[out] NewMessage Pointer to a new unformatted HTTP header. The storage for this NewMessage is
37 allocated by the driver publishing this protocol, and must be freed by the caller.
38
39 @retval EFI_SUCCESS Add, remove, and replace operations succeeded.
40 @retval EFI_OUT_OF_RESOURCES Could not allocate memory for NewMessage.
41
42 **/
43 EFI_STATUS
44 HttpUtilitiesBuild(
45 IN UINTN SeedMessageSize,
46 IN VOID *SeedMessage, OPTIONAL
47 IN UINTN DeleteCount,
48 IN CHAR8 *DeleteList[], OPTIONAL
49 IN UINTN AppendCount,
50 IN EFI_HTTP_HEADER *AppendList[], OPTIONAL
51 OUT UINTN *NewMessageSize,
52 OUT VOID **NewMessage
53 );
54
55 /**
56 This function is used to transform data stored in HttpMessage into a list of fields
57 paired with their corresponding values.
58
59 @param[in] HttpMessage Contains raw unformatted HTTP header string. The buffer for this string will
60 be allocated and released by the caller.
61 @param[in] HttpMessageSize Size in bytes of raw unformatted HTTP header.
62 @param[out] HeaderFields Array of key/value header pairs. The storage for all header pairs is allocated
63 by the driver publishing this protocol, and must be freed by the caller.
64 @param[out] FieldCount Number of headers in HeaderFields.
65
66 @retval EFI_SUCCESS Parse HTTP header into array of key/value pairs succeeded.
67 @retval EFI_OUT_OF_RESOURCES Could not allocate memory for NewMessage.
68 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
69 HttpMessage is NULL.
70 HeaderFields is NULL.
71 FieldCount is NULL.
72
73 **/
74 EFI_STATUS
75 HttpUtilitiesParse(
76 IN CHAR8 *HttpMessage,
77 IN UINTN HttpMessageSize,
78 OUT EFI_HTTP_HEADER **HeaderFields,
79 OUT UINTN *FieldCount
80 );
81
82 #endif