]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/Http.h
MdePkg: Http.h - Add HttpMethodMax to EFI_HTTP_METHOD.
[mirror_edk2.git] / MdePkg / Include / Protocol / Http.h
CommitLineData
cff298f4 1/** @file\r
2 This file defines the EFI HTTP Protocol interface. It is split into\r
3 the following two main sections:\r
4 HTTP Service Binding Protocol (HTTPSB)\r
5 HTTP Protocol (HTTP)\r
6\r
7 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
cfc46163 8 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
cff298f4 9 This program and the accompanying materials\r
10 are licensed and made available under the terms and conditions of the BSD License\r
11 which accompanies this distribution. The full text of the license may be found at\r
12 http://opensource.org/licenses/bsd-license.php\r
13\r
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
16\r
17 @par Revision Reference:\r
18 This Protocol is introduced in UEFI Specification 2.5\r
19\r
20**/\r
21\r
22#ifndef __EFI_HTTP_PROTOCOL_H__\r
23#define __EFI_HTTP_PROTOCOL_H__\r
24\r
25#define EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID \\r
26 { \\r
27 0xbdc8e6af, 0xd9bc, 0x4379, {0xa7, 0x2a, 0xe0, 0xc4, 0xe7, 0x5d, 0xae, 0x1c } \\r
28 }\r
29\r
30#define EFI_HTTP_PROTOCOL_GUID \\r
31 { \\r
32 0x7a59b29b, 0x910b, 0x4171, {0x82, 0x42, 0xa8, 0x5a, 0x0d, 0xf2, 0x5b, 0x5b } \\r
33 }\r
34\r
35typedef struct _EFI_HTTP_PROTOCOL EFI_HTTP_PROTOCOL;\r
36\r
37///\r
38/// EFI_HTTP_VERSION\r
39///\r
40typedef enum {\r
41 HttpVersion10,\r
42 HttpVersion11,\r
43 HttpVersionUnsupported\r
44} EFI_HTTP_VERSION;\r
45\r
46///\r
47/// EFI_HTTP_METHOD\r
48///\r
49typedef enum {\r
50 HttpMethodGet,\r
51 HttpMethodPost,\r
52 HttpMethodPatch,\r
53 HttpMethodOptions,\r
54 HttpMethodConnect,\r
55 HttpMethodHead,\r
56 HttpMethodPut,\r
57 HttpMethodDelete,\r
cfc46163
SEHM
58 HttpMethodTrace,\r
59 HttpMethodMax\r
cff298f4 60} EFI_HTTP_METHOD;\r
61\r
62///\r
63/// EFI_HTTP_STATUS_CODE\r
64///\r
65typedef enum {\r
66 HTTP_STATUS_UNSUPPORTED_STATUS = 0,\r
67 HTTP_STATUS_100_CONTINUE,\r
68 HTTP_STATUS_101_SWITCHING_PROTOCOLS,\r
69 HTTP_STATUS_200_OK,\r
70 HTTP_STATUS_201_CREATED,\r
71 HTTP_STATUS_202_ACCEPTED,\r
72 HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION,\r
73 HTTP_STATUS_204_NO_CONTENT,\r
74 HTTP_STATUS_205_RESET_CONTENT,\r
75 HTTP_STATUS_206_PARTIAL_CONTENT,\r
76 HTTP_STATUS_300_MULTIPLE_CHIOCES,\r
77 HTTP_STATUS_301_MOVED_PERMANENTLY,\r
78 HTTP_STATUS_302_FOUND,\r
79 HTTP_STATUS_303_SEE_OTHER,\r
80 HTTP_STATUS_304_NOT_MODIFIED,\r
81 HTTP_STATUS_305_USE_PROXY,\r
82 HTTP_STATUS_307_TEMPORARY_REDIRECT,\r
83 HTTP_STATUS_400_BAD_REQUEST,\r
84 HTTP_STATUS_401_UNAUTHORIZED,\r
85 HTTP_STATUS_402_PAYMENT_REQUIRED,\r
86 HTTP_STATUS_403_FORBIDDEN,\r
87 HTTP_STATUS_404_NOT_FOUND,\r
88 HTTP_STATUS_405_METHOD_NOT_ALLOWED,\r
89 HTTP_STATUS_406_NOT_ACCEPTABLE,\r
90 HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED,\r
91 HTTP_STATUS_408_REQUEST_TIME_OUT,\r
92 HTTP_STATUS_409_CONFLICT,\r
93 HTTP_STATUS_410_GONE,\r
94 HTTP_STATUS_411_LENGTH_REQUIRED,\r
95 HTTP_STATUS_412_PRECONDITION_FAILED,\r
96 HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE,\r
97 HTTP_STATUS_414_REQUEST_URI_TOO_LARGE,\r
98 HTTP_STATUS_415_UNSUPPORETD_MEDIA_TYPE,\r
99 HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED,\r
100 HTTP_STATUS_417_EXPECTATION_FAILED,\r
101 HTTP_STATUS_500_INTERNAL_SERVER_ERROR,\r
102 HTTP_STATUS_501_NOT_IMIPLEMENTED,\r
103 HTTP_STATUS_502_BAD_GATEWAY,\r
104 HTTP_STATUS_503_SERVICE_UNAVAILABLE,\r
105 HTTP_STATUS_504_GATEWAY_TIME_OUT,\r
106 HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED\r
107} EFI_HTTP_STATUS_CODE;\r
108\r
109///\r
110/// EFI_HTTPv4_ACCESS_POINT\r
111///\r
112typedef struct {\r
113 ///\r
114 /// Set to TRUE to instruct the EFI HTTP instance to use the default address\r
115 /// information in every TCP connection made by this instance. In addition, when set\r
116 /// to TRUE, LocalAddress, LocalSubnet, and LocalPort are ignored.\r
117 ///\r
118 BOOLEAN UseDefaultAddress;\r
119 ///\r
120 /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be\r
121 /// used in every TCP connection opened by this instance.\r
122 ///\r
123 EFI_IPv4_ADDRESS LocalAddress;\r
124 ///\r
125 /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used\r
126 /// in every TCP connection opened by this instance.\r
127 ///\r
128 EFI_IPv4_ADDRESS LocalSubnet;\r
129 ///\r
130 /// If UseDefaultAddress is set to FALSE, this defines the local port to be used in\r
131 /// every TCP connection opened by this instance.\r
132 ///\r
133 UINT16 LocalPort;\r
134} EFI_HTTPv4_ACCESS_POINT;\r
135\r
136///\r
137/// EFI_HTTPv6_ACCESS_POINT\r
138///\r
139typedef struct {\r
140 ///\r
141 /// Local IP address to be used in every TCP connection opened by this instance.\r
142 ///\r
143 EFI_IPv6_ADDRESS LocalAddress;\r
144 ///\r
145 /// Local port to be used in every TCP connection opened by this instance.\r
146 ///\r
147 UINT16 LocalPort;\r
148} EFI_HTTPv6_ACCESS_POINT;\r
149\r
150///\r
151/// EFI_HTTP_CONFIG_DATA_ACCESS_POINT\r
152///\r
153\r
154\r
155typedef struct {\r
156 ///\r
157 /// HTTP version that this instance will support.\r
158 ///\r
159 EFI_HTTP_VERSION HttpVersion;\r
160 ///\r
161 /// Time out (in milliseconds) when blocking for requests.\r
162 ///\r
163 UINT32 TimeOutMillisec;\r
164 ///\r
165 /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If\r
166 /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE,\r
167 /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL.\r
168 ///\r
169 BOOLEAN LocalAddressIsIPv6;\r
170\r
171 union {\r
172 ///\r
173 /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and\r
174 /// port used by the underlying TCP protocol.\r
175 ///\r
176 EFI_HTTPv4_ACCESS_POINT *IPv4Node;\r
177 ///\r
178 /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port\r
179 /// used by the underlying TCP protocol.\r
180 ///\r
181 EFI_HTTPv6_ACCESS_POINT *IPv6Node;\r
182 } AccessPoint;\r
183} EFI_HTTP_CONFIG_DATA;\r
184\r
185///\r
186/// EFI_HTTP_REQUEST_DATA\r
187///\r
188typedef struct {\r
189 ///\r
190 /// The HTTP method (e.g. GET, POST) for this HTTP Request.\r
191 ///\r
192 EFI_HTTP_METHOD Method;\r
193 ///\r
194 /// The URI of a remote host. From the information in this field, the HTTP instance\r
195 /// will be able to determine whether to use HTTP or HTTPS and will also be able to\r
196 /// determine the port number to use. If no port number is specified, port 80 (HTTP)\r
197 /// is assumed. See RFC 3986 for more details on URI syntax.\r
198 ///\r
199 CHAR16 *Url;\r
200} EFI_HTTP_REQUEST_DATA;\r
201\r
202///\r
203/// EFI_HTTP_RESPONSE_DATA\r
204///\r
205typedef struct {\r
206 ///\r
207 /// Response status code returned by the remote host.\r
208 ///\r
209 EFI_HTTP_STATUS_CODE StatusCode;\r
210} EFI_HTTP_RESPONSE_DATA;\r
211\r
212///\r
213/// EFI_HTTP_HEADER\r
214///\r
215typedef struct {\r
216 ///\r
217 /// Null terminated string which describes a field name. See RFC 2616 Section 14 for\r
218 /// detailed information about field names.\r
219 ///\r
220 CHAR8 *FieldName;\r
221 ///\r
222 /// Null terminated string which describes the corresponding field value. See RFC 2616\r
223 /// Section 14 for detailed information about field values.\r
224 ///\r
225 CHAR8 *FieldValue;\r
226} EFI_HTTP_HEADER;\r
227\r
228///\r
229/// EFI_HTTP_MESSAGE\r
230///\r
231typedef struct {\r
232 ///\r
233 /// HTTP message data.\r
234 ///\r
235 union {\r
236 ///\r
237 /// When the token is used to send a HTTP request, Request is a pointer to storage that\r
238 /// contains such data as URL and HTTP method.\r
239 ///\r
240 EFI_HTTP_REQUEST_DATA *Request;\r
241 ///\r
242 /// When used to await a response, Response points to storage containing HTTP response\r
243 /// status code.\r
244 ///\r
245 EFI_HTTP_RESPONSE_DATA *Response;\r
246 } Data;\r
247 ///\r
248 /// Number of HTTP header structures in Headers list. On request, this count is\r
249 /// provided by the caller. On response, this count is provided by the HTTP driver.\r
250 ///\r
251 UINTN HeaderCount;\r
252 ///\r
253 /// Array containing list of HTTP headers. On request, this array is populated by the\r
254 /// caller. On response, this array is allocated and populated by the HTTP driver. It\r
255 /// is the responsibility of the caller to free this memory on both request and\r
256 /// response.\r
257 ///\r
258 EFI_HTTP_HEADER *Headers;\r
259 ///\r
260 /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type.\r
261 ///\r
262 UINTN BodyLength;\r
263 ///\r
264 /// Body associated with the HTTP request or response. This can be NULL depending on\r
265 /// the HttpMethod type.\r
266 ///\r
267 VOID *Body;\r
268} EFI_HTTP_MESSAGE;\r
269\r
270\r
271///\r
272/// EFI_HTTP_TOKEN\r
273///\r
274typedef struct {\r
275 ///\r
276 /// This Event will be signaled after the Status field is updated by the EFI HTTP\r
277 /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority\r
278 /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK.\r
279 ///\r
280 EFI_EVENT Event;\r
281 ///\r
282 /// Status will be set to one of the following value if the HTTP request is\r
283 /// successfully sent or if an unexpected error occurs:\r
284 /// EFI_SUCCESS: The HTTP request was successfully sent to the remote host.\r
285 /// EFI_ABORTED: The HTTP request was cancelled by the caller and removed from\r
286 /// the transmit queue.\r
287 /// EFI_TIMEOUT: The HTTP request timed out before reaching the remote host.\r
288 /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.\r
289 ///\r
290 EFI_STATUS Status;\r
291 ///\r
292 /// Pointer to storage containing HTTP message data.\r
293 ///\r
294 EFI_HTTP_MESSAGE *Message;\r
295} EFI_HTTP_TOKEN;\r
296\r
297/**\r
298 Returns the operational parameters for the current HTTP child instance.\r
299\r
300 The GetModeData() function is used to read the current mode data (operational\r
301 parameters) for this HTTP protocol instance.\r
302\r
303 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
304 @param[out] HttpConfigData Point to buffer for operational parameters of this\r
305 HTTP instance.\r
306\r
307 @retval EFI_SUCCESS Operation succeeded.\r
308 @retval EFI_INVALID_PARAMETER This is NULL.\r
309**/\r
310typedef\r
311EFI_STATUS\r
312(EFIAPI * EFI_HTTP_GET_MODE_DATA)(\r
313 IN EFI_HTTP_PROTOCOL *This,\r
314 OUT EFI_HTTP_CONFIG_DATA *HttpConfigData\r
315 );\r
316\r
317/**\r
318 Initialize or brutally reset the operational parameters for this EFI HTTP instance.\r
319\r
320 The Configure() function does the following:\r
321 When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring\r
322 timeout, local address, port, etc.\r
323 When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active\r
324 connections with remote hosts, canceling all asynchronous tokens, and flush request\r
325 and response buffers without informing the appropriate hosts.\r
326\r
327 Except for GetModeData() and Configure(), No other EFI HTTP function can be executed\r
328 by this instance until the Configure() function is executed and returns successfully.\r
329\r
330 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
331 @param[in] HttpConfigData Pointer to the configure data to configure the instance.\r
332\r
333 @retval EFI_SUCCESS Operation succeeded.\r
334 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
335 This is NULL.\r
336 HttpConfigData->LocalAddressIsIPv6 is FALSE and\r
337 HttpConfigData->IPv4Node is NULL.\r
338 HttpConfigData->LocalAddressIsIPv6 is TRUE and\r
339 HttpConfigData->IPv6Node is NULL.\r
340 @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling\r
341 Configure() with NULL to reset it.\r
342 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
343 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when\r
344 executing Configure().\r
345 @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported\r
346 in the implementation.\r
347**/\r
348typedef\r
349EFI_STATUS\r
350(EFIAPI * EFI_HTTP_CONFIGURE)(\r
351 IN EFI_HTTP_PROTOCOL *This,\r
352 IN EFI_HTTP_CONFIG_DATA *HttpConfigData\r
353 );\r
354\r
355/**\r
356 The Request() function queues an HTTP request to this HTTP instance, \r
357 similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent\r
358 successfully, or if there is an error, Status in token will be updated and Event will\r
359 be signaled.\r
360\r
361 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
362 @param[in] Token Pointer to storage containing HTTP request token.\r
363\r
364 @retval EFI_SUCCESS Outgoing data was processed.\r
365 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.\r
366 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
367 @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.\r
368 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
369 This is NULL.\r
370 Token->Message is NULL.\r
371 Token->Message->Body is not NULL,\r
372 Token->Message->BodyLength is non-zero, and\r
373 Token->Message->Data is NULL, but a previous call to\r
374 Request()has not been completed successfully.\r
375**/\r
376typedef\r
377EFI_STATUS\r
378(EFIAPI *EFI_HTTP_REQUEST) (\r
379 IN EFI_HTTP_PROTOCOL *This,\r
380 IN EFI_HTTP_TOKEN *Token\r
381 );\r
382\r
383/**\r
384 Abort an asynchronous HTTP request or response token.\r
385\r
386 The Cancel() function aborts a pending HTTP request or response transaction. If\r
387 Token is not NULL and the token is in transmit or receive queues when it is being\r
388 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will\r
389 be signaled. If the token is not in one of the queues, which usually means that the\r
390 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,\r
391 all asynchronous tokens issued by Request() or Response() will be aborted.\r
392\r
393 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
394 @param[in] Token Point to storage containing HTTP request or response\r
395 token.\r
396\r
397 @retval EFI_SUCCESS Request and Response queues are successfully flushed.\r
398 @retval EFI_INVALID_PARAMETER This is NULL.\r
399 @retval EFI_NOT_STARTED This instance hasn't been configured.\r
400 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP,\r
401 BOOTP, RARP, etc.) hasn't finished yet.\r
402 @retval EFI_NOT_FOUND The asynchronous request or response token is not\r
403 found.\r
404 @retval EFI_UNSUPPORTED The implementation does not support this function.\r
405**/\r
406typedef\r
407EFI_STATUS\r
408(EFIAPI *EFI_HTTP_CANCEL)(\r
409 IN EFI_HTTP_PROTOCOL *This,\r
410 IN EFI_HTTP_TOKEN *Token\r
411 );\r
412\r
413/**\r
414 The Response() function queues an HTTP response to this HTTP instance, similar to\r
415 Receive() function in the EFI TCP driver. When the HTTP request is sent successfully,\r
416 or if there is an error, Status in token will be updated and Event will be signaled.\r
417\r
418 The HTTP driver will queue a receive token to the underlying TCP instance. When data\r
419 is received in the underlying TCP instance, the data will be parsed and Token will\r
420 be populated with the response data. If the data received from the remote host\r
421 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting\r
422 (asynchronously) for more data to be sent from the remote host before signaling\r
423 Event in Token.\r
424\r
425 It is the responsibility of the caller to allocate a buffer for Body and specify the\r
426 size in BodyLength. If the remote host provides a response that contains a content\r
427 body, up to BodyLength bytes will be copied from the receive buffer into Body and\r
428 BodyLength will be updated with the amount of bytes received and copied to Body. This\r
429 allows the client to download a large file in chunks instead of into one contiguous\r
430 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is\r
431 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive\r
432 token to underlying TCP instance. If data arrives in the receive buffer, up to\r
433 BodyLength bytes of data will be copied to Body. The HTTP driver will then update\r
434 BodyLength with the amount of bytes received and copied to Body.\r
435\r
436 If the HTTP driver does not have an open underlying TCP connection with the host\r
437 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is\r
438 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain\r
439 an open TCP connection between client and host.\r
440\r
441 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
442 @param[in] Token Pointer to storage containing HTTP response token.\r
443\r
444 @retval EFI_SUCCESS Allocation succeeded.\r
445 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been\r
446 initialized.\r
447 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
448 This is NULL.\r
449 Token->Message->Headers is NULL.\r
450 Token->Message is NULL.\r
451 Token->Message->Body is not NULL,\r
452 Token->Message->BodyLength is non-zero, and\r
453 Token->Message->Data is NULL, but a previous call to\r
454 Response() has not been completed successfully.\r
455 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host\r
456 specified by response URL.\r
457**/\r
458typedef\r
459EFI_STATUS\r
460(EFIAPI *EFI_HTTP_RESPONSE) (\r
461 IN EFI_HTTP_PROTOCOL *This,\r
462 IN EFI_HTTP_TOKEN *Token\r
463 );\r
464\r
465/**\r
466 The Poll() function can be used by network drivers and applications to increase the\r
467 rate that data packets are moved between the communication devices and the transmit\r
468 and receive queues.\r
469\r
470 In some systems, the periodic timer event in the managed network driver may not poll\r
471 the underlying communications device fast enough to transmit and/or receive all data\r
472 packets without missing incoming packets or dropping outgoing packets. Drivers and\r
473 applications that are experiencing packet loss should try calling the Poll() function\r
474 more often.\r
475\r
476 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.\r
477\r
478 @retval EFI_SUCCESS Incoming or outgoing data was processed..\r
479 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred\r
480 @retval EFI_INVALID_PARAMETER This is NULL.\r
481 @retval EFI_NOT_READY No incoming or outgoing data is processed.\r
482**/\r
483typedef\r
484EFI_STATUS\r
485(EFIAPI *EFI_HTTP_POLL) (\r
486 IN EFI_HTTP_PROTOCOL *This\r
487 );\r
488\r
489///\r
490/// The EFI HTTP protocol is designed to be used by EFI drivers and applications to\r
491/// create and transmit HTTP Requests, as well as handle HTTP responses that are\r
492/// returned by a remote host. This EFI protocol uses and relies on an underlying EFI\r
493/// TCP protocol.\r
494///\r
495struct _EFI_HTTP_PROTOCOL {\r
496 EFI_HTTP_GET_MODE_DATA GetModeData;\r
497 EFI_HTTP_CONFIGURE Configure;\r
498 EFI_HTTP_REQUEST Request;\r
499 EFI_HTTP_CANCEL Cancel;\r
500 EFI_HTTP_RESPONSE Response;\r
501 EFI_HTTP_POLL Poll;\r
502};\r
503\r
504extern EFI_GUID gEfiHttpServiceBindingProtocolGuid;\r
505extern EFI_GUID gEfiHttpProtocolGuid;\r
506\r
507#endif\r