]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.h
FatBinPkg: Update EBC/IA32/X64/IPF binaries
[mirror_edk2.git] / NetworkPkg / HttpUtilitiesDxe / HttpUtilitiesDxe.h
CommitLineData
d933e70a
JW
1/** @file\r
2 The header files of Http Utilities functions for HttpUtilities driver.\r
3\r
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php.\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef __EFI_HTTP_UTILITIES_DXE_H__\r
17#define __EFI_HTTP_UTILITIES_DXE_H__\r
18\r
19#include <Uefi.h>\r
20\r
21//\r
22// Libraries\r
23//\r
24#include <Library/UefiBootServicesTableLib.h>\r
25#include <Library/MemoryAllocationLib.h>\r
26#include <Library/BaseMemoryLib.h>\r
27#include <Library/BaseLib.h>\r
28#include <Library/UefiLib.h>\r
29#include <Library/DebugLib.h>\r
30\r
31//\r
32// Consumed Protocols\r
33//\r
34#include <Protocol/HttpUtilities.h>\r
35#include <Protocol/Http.h>\r
36\r
37//\r
38// Protocol instances\r
39//\r
40extern EFI_HTTP_UTILITIES_PROTOCOL mHttpUtilitiesProtocol;\r
41\r
42\r
43/**\r
44 Free existing HeaderFields.\r
45\r
46 @param[in] HeaderFields Pointer to array of key/value header pairs waitting for free.\r
47 @param[in] FieldCount The number of header pairs in HeaderFields.\r
48\r
49**/\r
50VOID\r
51FreeHeaderFields (\r
52 IN EFI_HTTP_HEADER *HeaderFields,\r
53 IN UINTN FieldCount\r
54 );\r
55\r
56\r
57/**\r
58 Find required header field in HeaderFields.\r
59\r
60 @param[in] HeaderFields Pointer to array of key/value header pairs.\r
61 @param[in] FieldCount The number of header pairs.\r
62 @param[in] FieldName Pointer to header field's name.\r
63\r
64 @return Pointer to the queried header field.\r
65 @return NULL if not find this required header field.\r
66\r
67**/\r
68EFI_HTTP_HEADER *\r
69FindHttpHeader (\r
70 IN EFI_HTTP_HEADER *HeaderFields,\r
71 IN UINTN FieldCount,\r
72 IN CHAR8 *FieldName\r
73 );\r
74\r
75\r
76/**\r
77 Check whether header field called FieldName is in DeleteList.\r
78\r
79 @param[in] DeleteList Pointer to array of key/value header pairs.\r
80 @param[in] DeleteCount The number of header pairs.\r
81 @param[in] FieldName Pointer to header field's name.\r
82\r
83 @return TRUE if FieldName is not in DeleteList, that means this header field is valid.\r
84 @return FALSE if FieldName is in DeleteList, that means this header field is invalid.\r
85\r
86**/\r
87BOOLEAN\r
88IsValidHttpHeader (\r
89 IN CHAR8 *DeleteList[],\r
90 IN UINTN DeleteCount,\r
91 IN CHAR8 *FieldName\r
92 );\r
93\r
94\r
95/**\r
96 Set FieldName and FieldValue into specified HttpHeader.\r
97\r
98 @param[in] HttpHeader Specified HttpHeader.\r
99 @param[in] FieldName FieldName of this HttpHeader.\r
100 @param[in] FieldValue FieldValue of this HttpHeader.\r
101\r
102\r
103 @retval EFI_SUCCESS The FieldName and FieldValue are set into HttpHeader successfully.\r
104 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.\r
105\r
106**/\r
107EFI_STATUS\r
108SetFieldNameAndValue (\r
109 IN EFI_HTTP_HEADER *HttpHeader,\r
110 IN CHAR8 *FieldName, \r
111 IN CHAR8 *FieldValue\r
112 );\r
113\r
114\r
115/**\r
116 Get one key/value header pair from the raw string.\r
117\r
118 @param[in] String Pointer to the raw string.\r
119 @param[out] FieldName Pointer to header field's name.\r
120 @param[out] FieldValue Pointer to header field's value.\r
121\r
122 @return Pointer to the next raw string.\r
123 @return NULL if no key/value header pair from this raw string.\r
124\r
125**/\r
126CHAR8 *\r
127GetFieldNameAndValue (\r
128 IN CHAR8 *String,\r
129 OUT CHAR8 **FieldName,\r
130 OUT CHAR8 **FieldValue\r
131 );\r
132\r
133\r
134/**\r
135 Create HTTP header based on a combination of seed header, fields\r
136 to delete, and fields to append.\r
137\r
138 The Build() function is used to manage the headers portion of an\r
139 HTTP message by providing the ability to add, remove, or replace\r
140 HTTP headers.\r
141\r
142 @param[in] This Pointer to EFI_HTTP_UTILITIES_PROTOCOL instance.\r
143 @param[in] SeedMessageSize Size of the initial HTTP header. This can be zero.\r
144 @param[in] SeedMessage Initial HTTP header to be used as a base for\r
145 building a new HTTP header. If NULL,\r
146 SeedMessageSize is ignored.\r
147 @param[in] DeleteCount Number of null-terminated HTTP header field names\r
148 in DeleteList.\r
149 @param[in] DeleteList List of null-terminated HTTP header field names to\r
150 remove from SeedMessage. Only the field names are\r
151 in this list because the field values are irrelevant\r
152 to this operation.\r
153 @param[in] AppendCount Number of header fields in AppendList.\r
154 @param[in] AppendList List of HTTP headers to populate NewMessage with.\r
155 If SeedMessage is not NULL, AppendList will be\r
156 appended to the existing list from SeedMessage in\r
157 NewMessage.\r
158 @param[out] NewMessageSize Pointer to number of header fields in NewMessage.\r
159 @param[out] NewMessage Pointer to a new list of HTTP headers based on.\r
160\r
161 @retval EFI_SUCCESS Add, remove, and replace operations succeeded.\r
162 @retval EFI_OUT_OF_RESOURCES Could not allocate memory for NewMessage.\r
163 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
164 This is NULL.\r
165**/\r
166EFI_STATUS\r
167EFIAPI\r
168HttpUtilitiesBuild (\r
169 IN EFI_HTTP_UTILITIES_PROTOCOL *This,\r
170 IN UINTN SeedMessageSize,\r
171 IN VOID *SeedMessage, OPTIONAL\r
172 IN UINTN DeleteCount,\r
173 IN CHAR8 *DeleteList[], OPTIONAL\r
174 IN UINTN AppendCount,\r
175 IN EFI_HTTP_HEADER *AppendList[], OPTIONAL\r
176 OUT UINTN *NewMessageSize,\r
177 OUT VOID **NewMessage\r
178 );\r
179\r
180\r
181/**\r
182 Parses HTTP header and produces an array of key/value pairs.\r
183\r
184 The Parse() function is used to transform data stored in HttpHeader\r
185 into a list of fields paired with their corresponding values.\r
186\r
187 @param[in] This Pointer to EFI_HTTP_UTILITIES_PROTOCOL instance.\r
188 @param[in] HttpMessage Contains raw unformatted HTTP header string.\r
189 @param[in] HttpMessageSize Size of HTTP header.\r
190 @param[out] HeaderFields Array of key/value header pairs.\r
191 @param[out] FieldCount Number of headers in HeaderFields.\r
192\r
193 @retval EFI_SUCCESS Allocation succeeded.\r
194 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been\r
195 initialized.\r
196 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
197 This is NULL.\r
198 HttpMessage is NULL.\r
199 HeaderFields is NULL.\r
200 FieldCount is NULL.\r
201**/\r
202EFI_STATUS\r
203EFIAPI\r
204HttpUtilitiesParse (\r
205 IN EFI_HTTP_UTILITIES_PROTOCOL *This,\r
206 IN CHAR8 *HttpMessage,\r
207 IN UINTN HttpMessageSize,\r
208 OUT EFI_HTTP_HEADER **HeaderFields,\r
209 OUT UINTN *FieldCount\r
210 );\r
211\r
212#endif\r