]>
Commit | Line | Data |
---|---|---|
f9a14916 JW |
1 | /** @file\r |
2 | This library is used to share code between UEFI network stack modules.\r | |
3 | It provides the helper routines to parse the HTTP message byte stream.\r | |
4 | \r | |
d1102dba | 5 | Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r |
558b99a6 | 6 | (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r |
9d510e61 | 7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
f9a14916 JW |
8 | \r |
9 | **/\r | |
10 | \r | |
11 | #ifndef _HTTP_LIB_H_\r | |
12 | #define _HTTP_LIB_H_\r | |
13 | \r | |
14 | #include <Protocol/Http.h>\r | |
15 | \r | |
16 | /**\r | |
17 | Decode a percent-encoded URI component to the ASCII character.\r | |
d1102dba LG |
18 | \r |
19 | Decode the input component in Buffer according to RFC 3986. The caller is responsible to make\r | |
f9a14916 | 20 | sure ResultBuffer points to a buffer with size equal or greater than ((AsciiStrSize (Buffer))\r |
d1102dba | 21 | in bytes.\r |
f9a14916 JW |
22 | \r |
23 | @param[in] Buffer The pointer to a percent-encoded URI component.\r | |
24 | @param[in] BufferLength Length of Buffer in bytes.\r | |
25 | @param[out] ResultBuffer Point to the buffer to store the decode result.\r | |
26 | @param[out] ResultLength Length of decoded string in ResultBuffer in bytes.\r | |
27 | \r | |
28 | @retval EFI_SUCCESS Successfully decoded the URI.\r | |
29 | @retval EFI_INVALID_PARAMETER Buffer is not a valid percent-encoded string.\r | |
d1102dba | 30 | \r |
f9a14916 JW |
31 | **/\r |
32 | EFI_STATUS\r | |
33 | EFIAPI\r | |
34 | UriPercentDecode (\r | |
d1050b9d MK |
35 | IN CHAR8 *Buffer,\r |
36 | IN UINT32 BufferLength,\r | |
37 | OUT CHAR8 *ResultBuffer,\r | |
38 | OUT UINT32 *ResultLength\r | |
f9a14916 JW |
39 | );\r |
40 | \r | |
41 | /**\r | |
42 | Create a URL parser for the input URL string.\r | |
43 | \r | |
44 | This function will parse and dereference the input HTTP URL into it components. The original\r | |
45 | content of the URL won't be modified and the result will be returned in UrlParser, which can\r | |
46 | be used in other functions like NetHttpUrlGetHostName(). It is the caller's responsibility to\r | |
47 | free the buffer returned in *UrlParser by HttpUrlFreeParser().\r | |
48 | \r | |
49 | @param[in] Url The pointer to a HTTP URL string.\r | |
50 | @param[in] Length Length of Url in bytes.\r | |
51 | @param[in] IsConnectMethod Whether the Url is used in HTTP CONNECT method or not.\r | |
52 | @param[out] UrlParser Pointer to the returned buffer to store the parse result.\r | |
53 | \r | |
54 | @retval EFI_SUCCESS Successfully dereferenced the HTTP URL.\r | |
55 | @retval EFI_INVALID_PARAMETER UrlParser is NULL or Url is not a valid HTTP URL.\r | |
56 | @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources.\r | |
d1102dba | 57 | \r |
f9a14916 JW |
58 | **/\r |
59 | EFI_STATUS\r | |
60 | EFIAPI\r | |
61 | HttpParseUrl (\r | |
d1050b9d MK |
62 | IN CHAR8 *Url,\r |
63 | IN UINT32 Length,\r | |
64 | IN BOOLEAN IsConnectMethod,\r | |
65 | OUT VOID **UrlParser\r | |
f9a14916 JW |
66 | );\r |
67 | \r | |
68 | /**\r | |
69 | Get the Hostname from a HTTP URL.\r | |
70 | \r | |
71 | This function will return the HostName according to the Url and previous parse result ,and\r | |
72 | it is the caller's responsibility to free the buffer returned in *HostName.\r | |
73 | \r | |
74 | @param[in] Url The pointer to a HTTP URL string.\r | |
75 | @param[in] UrlParser URL Parse result returned by NetHttpParseUrl().\r | |
76 | @param[out] HostName Pointer to a buffer to store the HostName.\r | |
77 | \r | |
78 | @retval EFI_SUCCESS Successfully get the required component.\r | |
79 | @retval EFI_INVALID_PARAMETER Uri is NULL or HostName is NULL or UrlParser is invalid.\r | |
80 | @retval EFI_NOT_FOUND No hostName component in the URL.\r | |
81 | @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources.\r | |
d1102dba | 82 | \r |
f9a14916 JW |
83 | **/\r |
84 | EFI_STATUS\r | |
85 | EFIAPI\r | |
86 | HttpUrlGetHostName (\r | |
d1050b9d MK |
87 | IN CHAR8 *Url,\r |
88 | IN VOID *UrlParser,\r | |
89 | OUT CHAR8 **HostName\r | |
f9a14916 JW |
90 | );\r |
91 | \r | |
92 | /**\r | |
93 | Get the IPv4 address from a HTTP URL.\r | |
94 | \r | |
95 | This function will return the IPv4 address according to the Url and previous parse result.\r | |
96 | \r | |
97 | @param[in] Url The pointer to a HTTP URL string.\r | |
98 | @param[in] UrlParser URL Parse result returned by NetHttpParseUrl().\r | |
99 | @param[out] Ip4Address Pointer to a buffer to store the IP address.\r | |
100 | \r | |
101 | @retval EFI_SUCCESS Successfully get the required component.\r | |
102 | @retval EFI_INVALID_PARAMETER Uri is NULL or Ip4Address is NULL or UrlParser is invalid.\r | |
103 | @retval EFI_NOT_FOUND No IPv4 address component in the URL.\r | |
104 | @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources.\r | |
d1102dba | 105 | \r |
f9a14916 JW |
106 | **/\r |
107 | EFI_STATUS\r | |
108 | EFIAPI\r | |
109 | HttpUrlGetIp4 (\r | |
d1050b9d MK |
110 | IN CHAR8 *Url,\r |
111 | IN VOID *UrlParser,\r | |
112 | OUT EFI_IPv4_ADDRESS *Ip4Address\r | |
f9a14916 JW |
113 | );\r |
114 | \r | |
115 | /**\r | |
116 | Get the IPv6 address from a HTTP URL.\r | |
117 | \r | |
118 | This function will return the IPv6 address according to the Url and previous parse result.\r | |
119 | \r | |
120 | @param[in] Url The pointer to a HTTP URL string.\r | |
121 | @param[in] UrlParser URL Parse result returned by NetHttpParseUrl().\r | |
122 | @param[out] Ip6Address Pointer to a buffer to store the IP address.\r | |
123 | \r | |
124 | @retval EFI_SUCCESS Successfully get the required component.\r | |
125 | @retval EFI_INVALID_PARAMETER Uri is NULL or Ip6Address is NULL or UrlParser is invalid.\r | |
126 | @retval EFI_NOT_FOUND No IPv6 address component in the URL.\r | |
127 | @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources.\r | |
d1102dba | 128 | \r |
f9a14916 JW |
129 | **/\r |
130 | EFI_STATUS\r | |
131 | EFIAPI\r | |
132 | HttpUrlGetIp6 (\r | |
d1050b9d MK |
133 | IN CHAR8 *Url,\r |
134 | IN VOID *UrlParser,\r | |
135 | OUT EFI_IPv6_ADDRESS *Ip6Address\r | |
f9a14916 JW |
136 | );\r |
137 | \r | |
138 | /**\r | |
139 | Get the port number from a HTTP URL.\r | |
140 | \r | |
141 | This function will return the port number according to the Url and previous parse result.\r | |
142 | \r | |
143 | @param[in] Url The pointer to a HTTP URL string.\r | |
144 | @param[in] UrlParser URL Parse result returned by NetHttpParseUrl().\r | |
145 | @param[out] Port Pointer to a buffer to store the port number.\r | |
146 | \r | |
147 | @retval EFI_SUCCESS Successfully get the required component.\r | |
148 | @retval EFI_INVALID_PARAMETER Uri is NULL or Port is NULL or UrlParser is invalid.\r | |
149 | @retval EFI_NOT_FOUND No port number in the URL.\r | |
150 | @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources.\r | |
d1102dba | 151 | \r |
f9a14916 JW |
152 | **/\r |
153 | EFI_STATUS\r | |
154 | EFIAPI\r | |
155 | HttpUrlGetPort (\r | |
d1050b9d MK |
156 | IN CHAR8 *Url,\r |
157 | IN VOID *UrlParser,\r | |
158 | OUT UINT16 *Port\r | |
f9a14916 JW |
159 | );\r |
160 | \r | |
6796629d FS |
161 | /**\r |
162 | Get the Path from a HTTP URL.\r | |
163 | \r | |
164 | This function will return the Path according to the Url and previous parse result,and\r | |
165 | it is the caller's responsibility to free the buffer returned in *Path.\r | |
166 | \r | |
167 | @param[in] Url The pointer to a HTTP URL string.\r | |
168 | @param[in] UrlParser URL Parse result returned by NetHttpParseUrl().\r | |
169 | @param[out] Path Pointer to a buffer to store the Path.\r | |
170 | \r | |
171 | @retval EFI_SUCCESS Successfully get the required component.\r | |
172 | @retval EFI_INVALID_PARAMETER Uri is NULL or HostName is NULL or UrlParser is invalid.\r | |
173 | @retval EFI_NOT_FOUND No hostName component in the URL.\r | |
174 | @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources.\r | |
d1102dba | 175 | \r |
6796629d FS |
176 | **/\r |
177 | EFI_STATUS\r | |
178 | EFIAPI\r | |
179 | HttpUrlGetPath (\r | |
d1050b9d MK |
180 | IN CHAR8 *Url,\r |
181 | IN VOID *UrlParser,\r | |
182 | OUT CHAR8 **Path\r | |
6796629d FS |
183 | );\r |
184 | \r | |
f9a14916 JW |
185 | /**\r |
186 | Release the resource of the URL parser.\r | |
187 | \r | |
188 | @param[in] UrlParser Pointer to the parser.\r | |
d1102dba | 189 | \r |
f9a14916 JW |
190 | **/\r |
191 | VOID\r | |
192 | EFIAPI\r | |
193 | HttpUrlFreeParser (\r | |
d1050b9d | 194 | IN VOID *UrlParser\r |
f9a14916 JW |
195 | );\r |
196 | \r | |
197 | //\r | |
198 | // HTTP body parser interface.\r | |
199 | //\r | |
200 | \r | |
201 | typedef enum {\r | |
202 | //\r | |
203 | // Part of entity data.\r | |
204 | // Length of entity body in Data.\r | |
205 | //\r | |
206 | BodyParseEventOnData,\r | |
207 | //\r | |
208 | // End of message body.\r | |
209 | // Length is 0 and Data points to next byte after the end of the message.\r | |
210 | //\r | |
211 | BodyParseEventOnComplete\r | |
212 | } HTTP_BODY_PARSE_EVENT;\r | |
213 | \r | |
214 | /**\r | |
215 | A callback function to intercept events during message parser.\r | |
216 | \r | |
217 | This function will be invoked during HttpParseMessageBody() with various events type. An error\r | |
218 | return status of the callback function will cause the HttpParseMessageBody() aborted.\r | |
219 | \r | |
220 | @param[in] EventType Event type of this callback call.\r | |
221 | @param[in] Data A pointer to data buffer.\r | |
222 | @param[in] Length Length in bytes of the Data.\r | |
223 | @param[in] Context Callback context set by HttpInitMsgParser().\r | |
224 | \r | |
225 | @retval EFI_SUCCESS Continue to parser the message body.\r | |
226 | @retval Others Abort the parse.\r | |
d1102dba | 227 | \r |
f9a14916 JW |
228 | **/\r |
229 | typedef\r | |
230 | EFI_STATUS\r | |
d1050b9d | 231 | (EFIAPI *HTTP_BODY_PARSER_CALLBACK)(\r |
f9a14916 JW |
232 | IN HTTP_BODY_PARSE_EVENT EventType,\r |
233 | IN CHAR8 *Data,\r | |
234 | IN UINTN Length,\r | |
235 | IN VOID *Context\r | |
d1050b9d | 236 | );\r |
f9a14916 JW |
237 | \r |
238 | /**\r | |
239 | Initialize a HTTP message-body parser.\r | |
240 | \r | |
241 | This function will create and initialize a HTTP message parser according to caller provided HTTP message\r | |
242 | header information. It is the caller's responsibility to free the buffer returned in *UrlParser by HttpFreeMsgParser().\r | |
243 | \r | |
244 | @param[in] Method The HTTP method (e.g. GET, POST) for this HTTP message.\r | |
245 | @param[in] StatusCode Response status code returned by the remote host.\r | |
246 | @param[in] HeaderCount Number of HTTP header structures in Headers.\r | |
247 | @param[in] Headers Array containing list of HTTP headers.\r | |
248 | @param[in] Callback Callback function that is invoked when parsing the HTTP message-body,\r | |
249 | set to NULL to ignore all events.\r | |
250 | @param[in] Context Pointer to the context that will be passed to Callback.\r | |
251 | @param[out] MsgParser Pointer to the returned buffer to store the message parser.\r | |
252 | \r | |
253 | @retval EFI_SUCCESS Successfully initialized the parser.\r | |
254 | @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources.\r | |
255 | @retval EFI_INVALID_PARAMETER MsgParser is NULL or HeaderCount is not NULL but Headers is NULL.\r | |
256 | @retval Others Failed to initialize the parser.\r | |
257 | \r | |
258 | **/\r | |
259 | EFI_STATUS\r | |
260 | EFIAPI\r | |
261 | HttpInitMsgParser (\r | |
d1050b9d MK |
262 | IN EFI_HTTP_METHOD Method,\r |
263 | IN EFI_HTTP_STATUS_CODE StatusCode,\r | |
264 | IN UINTN HeaderCount,\r | |
265 | IN EFI_HTTP_HEADER *Headers,\r | |
266 | IN HTTP_BODY_PARSER_CALLBACK Callback,\r | |
267 | IN VOID *Context,\r | |
268 | OUT VOID **MsgParser\r | |
f9a14916 JW |
269 | );\r |
270 | \r | |
271 | /**\r | |
272 | Parse message body.\r | |
273 | \r | |
274 | Parse BodyLength of message-body. This function can be called repeatedly to parse the message-body partially.\r | |
275 | \r | |
276 | @param[in, out] MsgParser Pointer to the message parser.\r | |
277 | @param[in] BodyLength Length in bytes of the Body.\r | |
278 | @param[in] Body Pointer to the buffer of the message-body to be parsed.\r | |
279 | \r | |
280 | @retval EFI_SUCCESS Successfully parse the message-body.\r | |
281 | @retval EFI_INVALID_PARAMETER MsgParser is NULL or Body is NULL or BodyLength is 0.\r | |
4a6f440f JW |
282 | @retval EFI_ABORTED Operation aborted.\r |
283 | @retval Other Error happened while parsing message body.\r | |
d1102dba | 284 | \r |
f9a14916 JW |
285 | **/\r |
286 | EFI_STATUS\r | |
287 | EFIAPI\r | |
288 | HttpParseMessageBody (\r | |
d1050b9d MK |
289 | IN OUT VOID *MsgParser,\r |
290 | IN UINTN BodyLength,\r | |
291 | IN CHAR8 *Body\r | |
f9a14916 JW |
292 | );\r |
293 | \r | |
294 | /**\r | |
295 | Check whether the message-body is complete or not.\r | |
296 | \r | |
297 | @param[in] MsgParser Pointer to the message parser.\r | |
298 | \r | |
299 | @retval TRUE Message-body is complete.\r | |
300 | @retval FALSE Message-body is not complete.\r | |
301 | \r | |
302 | **/\r | |
303 | BOOLEAN\r | |
304 | EFIAPI\r | |
305 | HttpIsMessageComplete (\r | |
d1050b9d | 306 | IN VOID *MsgParser\r |
f9a14916 JW |
307 | );\r |
308 | \r | |
309 | /**\r | |
310 | Get the content length of the entity.\r | |
311 | \r | |
312 | Note that in trunk transfer, the entity length is not valid until the whole message body is received.\r | |
313 | \r | |
314 | @param[in] MsgParser Pointer to the message parser.\r | |
315 | @param[out] ContentLength Pointer to store the length of the entity.\r | |
316 | \r | |
317 | @retval EFI_SUCCESS Successfully to get the entity length.\r | |
318 | @retval EFI_NOT_READY Entity length is not valid yet.\r | |
319 | @retval EFI_INVALID_PARAMETER MsgParser is NULL or ContentLength is NULL.\r | |
d1102dba | 320 | \r |
f9a14916 JW |
321 | **/\r |
322 | EFI_STATUS\r | |
323 | EFIAPI\r | |
324 | HttpGetEntityLength (\r | |
d1050b9d MK |
325 | IN VOID *MsgParser,\r |
326 | OUT UINTN *ContentLength\r | |
f9a14916 JW |
327 | );\r |
328 | \r | |
329 | /**\r | |
330 | Release the resource of the message parser.\r | |
331 | \r | |
332 | @param[in] MsgParser Pointer to the message parser.\r | |
d1102dba | 333 | \r |
f9a14916 JW |
334 | **/\r |
335 | VOID\r | |
336 | EFIAPI\r | |
337 | HttpFreeMsgParser (\r | |
d1050b9d | 338 | IN VOID *MsgParser\r |
f9a14916 JW |
339 | );\r |
340 | \r | |
558b99a6 GB |
341 | /**\r |
342 | Find a specified header field according to the field name.\r | |
343 | \r | |
344 | @param[in] HeaderCount Number of HTTP header structures in Headers list.\r | |
345 | @param[in] Headers Array containing list of HTTP headers.\r | |
346 | @param[in] FieldName Null terminated string which describes a field name.\r | |
347 | \r | |
348 | @return Pointer to the found header or NULL.\r | |
349 | \r | |
350 | **/\r | |
351 | EFI_HTTP_HEADER *\r | |
352 | EFIAPI\r | |
353 | HttpFindHeader (\r | |
d1050b9d MK |
354 | IN UINTN HeaderCount,\r |
355 | IN EFI_HTTP_HEADER *Headers,\r | |
356 | IN CHAR8 *FieldName\r | |
558b99a6 GB |
357 | );\r |
358 | \r | |
359 | /**\r | |
360 | Set FieldName and FieldValue into specified HttpHeader.\r | |
361 | \r | |
362 | @param[in,out] HttpHeader Specified HttpHeader.\r | |
363 | @param[in] FieldName FieldName of this HttpHeader, a NULL terminated ASCII string.\r | |
364 | @param[in] FieldValue FieldValue of this HttpHeader, a NULL terminated ASCII string.\r | |
365 | \r | |
366 | \r | |
367 | @retval EFI_SUCCESS The FieldName and FieldValue are set into HttpHeader successfully.\r | |
0efeec8e | 368 | @retval EFI_INVALID_PARAMETER The parameter is invalid.\r |
558b99a6 GB |
369 | @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.\r |
370 | \r | |
371 | **/\r | |
372 | EFI_STATUS\r | |
373 | EFIAPI\r | |
374 | HttpSetFieldNameAndValue (\r | |
d1050b9d MK |
375 | IN OUT EFI_HTTP_HEADER *HttpHeader,\r |
376 | IN CONST CHAR8 *FieldName,\r | |
377 | IN CONST CHAR8 *FieldValue\r | |
558b99a6 GB |
378 | );\r |
379 | \r | |
380 | /**\r | |
381 | Get one key/value header pair from the raw string.\r | |
382 | \r | |
383 | @param[in] String Pointer to the raw string.\r | |
384 | @param[out] FieldName Points directly to field name within 'HttpHeader'.\r | |
385 | @param[out] FieldValue Points directly to field value within 'HttpHeader'.\r | |
386 | \r | |
387 | @return Pointer to the next raw string.\r | |
388 | @return NULL if no key/value header pair from this raw string.\r | |
389 | \r | |
390 | **/\r | |
391 | CHAR8 *\r | |
392 | EFIAPI\r | |
393 | HttpGetFieldNameAndValue (\r | |
d1050b9d MK |
394 | IN CHAR8 *String,\r |
395 | OUT CHAR8 **FieldName,\r | |
396 | OUT CHAR8 **FieldValue\r | |
558b99a6 GB |
397 | );\r |
398 | \r | |
399 | /**\r | |
400 | Free existing HeaderFields.\r | |
401 | \r | |
402 | @param[in] HeaderFields Pointer to array of key/value header pairs waiting for free.\r | |
403 | @param[in] FieldCount The number of header pairs in HeaderFields.\r | |
404 | \r | |
405 | **/\r | |
406 | VOID\r | |
407 | EFIAPI\r | |
408 | HttpFreeHeaderFields (\r | |
409 | IN EFI_HTTP_HEADER *HeaderFields,\r | |
410 | IN UINTN FieldCount\r | |
411 | );\r | |
412 | \r | |
413 | /**\r | |
e297a0a4 | 414 | Generate HTTP request message.\r |
558b99a6 | 415 | \r |
e297a0a4 NH |
416 | This function will allocate memory for the whole HTTP message and generate a\r |
417 | well formatted HTTP Request message in it, include the Request-Line, header\r | |
418 | fields and also the message body. It is the caller's responsibility to free\r | |
419 | the buffer returned in *RequestMsg.\r | |
420 | \r | |
421 | @param[in] Message Pointer to the EFI_HTTP_MESSAGE structure which\r | |
422 | contains the required information to generate\r | |
423 | the HTTP request message.\r | |
558b99a6 | 424 | @param[in] Url The URL of a remote host.\r |
e297a0a4 | 425 | @param[out] RequestMsg Pointer to the created HTTP request message.\r |
6deb4baa | 426 | NULL if any error occurred.\r |
e297a0a4 | 427 | @param[out] RequestMsgSize Size of the RequestMsg (in bytes).\r |
558b99a6 | 428 | \r |
0d07e6fb | 429 | @retval EFI_SUCCESS If HTTP request string was created successfully.\r |
558b99a6 | 430 | @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.\r |
0d07e6fb | 431 | @retval EFI_INVALID_PARAMETER The input arguments are invalid.\r |
558b99a6 GB |
432 | \r |
433 | **/\r | |
434 | EFI_STATUS\r | |
435 | EFIAPI\r | |
e297a0a4 | 436 | HttpGenRequestMessage (\r |
d1050b9d MK |
437 | IN CONST EFI_HTTP_MESSAGE *Message,\r |
438 | IN CONST CHAR8 *Url,\r | |
439 | OUT CHAR8 **RequestMsg,\r | |
440 | OUT UINTN *RequestMsgSize\r | |
558b99a6 GB |
441 | );\r |
442 | \r | |
443 | /**\r | |
444 | Translate the status code in HTTP message to EFI_HTTP_STATUS_CODE defined\r | |
445 | in UEFI 2.5 specification.\r | |
446 | \r | |
447 | @param[in] StatusCode The status code value in HTTP message.\r | |
448 | \r | |
449 | @return Value defined in EFI_HTTP_STATUS_CODE .\r | |
450 | \r | |
451 | **/\r | |
452 | EFI_HTTP_STATUS_CODE\r | |
453 | EFIAPI\r | |
454 | HttpMappingToStatusCode (\r | |
d1050b9d | 455 | IN UINTN StatusCode\r |
558b99a6 GB |
456 | );\r |
457 | \r | |
458 | /**\r | |
459 | Check whether header field called FieldName is in DeleteList.\r | |
460 | \r | |
461 | @param[in] DeleteList Pointer to array of key/value header pairs.\r | |
462 | @param[in] DeleteCount The number of header pairs.\r | |
463 | @param[in] FieldName Pointer to header field's name.\r | |
464 | \r | |
465 | @return TRUE if FieldName is not in DeleteList, that means this header field is valid.\r | |
466 | @return FALSE if FieldName is in DeleteList, that means this header field is invalid.\r | |
467 | \r | |
468 | **/\r | |
469 | BOOLEAN\r | |
470 | EFIAPI\r | |
471 | HttpIsValidHttpHeader (\r | |
d1050b9d MK |
472 | IN CHAR8 *DeleteList[],\r |
473 | IN UINTN DeleteCount,\r | |
474 | IN CHAR8 *FieldName\r | |
558b99a6 GB |
475 | );\r |
476 | \r | |
40c4cd54 AC |
477 | //\r |
478 | // A wrapper structure to hold the HTTP headers.\r | |
479 | //\r | |
480 | typedef struct {\r | |
d1050b9d MK |
481 | UINTN MaxHeaderCount;\r |
482 | UINTN HeaderCount;\r | |
483 | EFI_HTTP_HEADER *Headers;\r | |
40c4cd54 AC |
484 | } HTTP_IO_HEADER;\r |
485 | \r | |
40c4cd54 AC |
486 | /**\r |
487 | Create a HTTP_IO_HEADER to hold the HTTP header items.\r | |
488 | \r | |
489 | @param[in] MaxHeaderCount The maximun number of HTTP header in this holder.\r | |
490 | \r | |
491 | @return A pointer of the HTTP header holder or NULL if failed.\r | |
492 | \r | |
493 | **/\r | |
494 | HTTP_IO_HEADER *\r | |
495 | HttpIoCreateHeader (\r | |
d1050b9d | 496 | UINTN MaxHeaderCount\r |
40c4cd54 AC |
497 | );\r |
498 | \r | |
499 | /**\r | |
500 | Destroy the HTTP_IO_HEADER and release the resources.\r | |
501 | \r | |
502 | @param[in] HttpIoHeader Point to the HTTP header holder to be destroyed.\r | |
503 | \r | |
504 | **/\r | |
505 | VOID\r | |
506 | HttpIoFreeHeader (\r | |
d1050b9d | 507 | IN HTTP_IO_HEADER *HttpIoHeader\r |
40c4cd54 AC |
508 | );\r |
509 | \r | |
510 | /**\r | |
511 | Set or update a HTTP header with the field name and corresponding value.\r | |
512 | \r | |
513 | @param[in] HttpIoHeader Point to the HTTP header holder.\r | |
514 | @param[in] FieldName Null terminated string which describes a field name.\r | |
515 | @param[in] FieldValue Null terminated string which describes the corresponding field value.\r | |
516 | \r | |
517 | @retval EFI_SUCCESS The HTTP header has been set or updated.\r | |
518 | @retval EFI_INVALID_PARAMETER Any input parameter is invalid.\r | |
519 | @retval EFI_OUT_OF_RESOURCES Insufficient resource to complete the operation.\r | |
520 | @retval Other Unexpected error happened.\r | |
521 | \r | |
522 | **/\r | |
523 | EFI_STATUS\r | |
524 | HttpIoSetHeader (\r | |
d1050b9d MK |
525 | IN HTTP_IO_HEADER *HttpIoHeader,\r |
526 | IN CHAR8 *FieldName,\r | |
527 | IN CHAR8 *FieldValue\r | |
40c4cd54 | 528 | );\r |
558b99a6 | 529 | \r |
f9a14916 | 530 | #endif\r |