2 This file defines the EFI HTTP Protocol interface. It is split into
3 the following two main sections:
4 HTTP Service Binding Protocol (HTTPSB)
7 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
8 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
9 This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 @par Revision Reference:
18 This Protocol is introduced in UEFI Specification 2.5
25 typedef struct _EFI_HTTP_PROTOCOL EFI_HTTP_PROTOCOL
;
33 HttpVersionUnsupported
53 /// EFI_HTTP_STATUS_CODE
56 HTTP_STATUS_UNSUPPORTED_STATUS
= 0,
57 HTTP_STATUS_100_CONTINUE
,
58 HTTP_STATUS_101_SWITCHING_PROTOCOLS
,
60 HTTP_STATUS_201_CREATED
,
61 HTTP_STATUS_202_ACCEPTED
,
62 HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION
,
63 HTTP_STATUS_204_NO_CONTENT
,
64 HTTP_STATUS_205_RESET_CONTENT
,
65 HTTP_STATUS_206_PARTIAL_CONTENT
,
66 HTTP_STATUS_300_MULTIPLE_CHIOCES
,
67 HTTP_STATUS_301_MOVED_PERMANENTLY
,
68 HTTP_STATUS_302_FOUND
,
69 HTTP_STATUS_303_SEE_OTHER
,
70 HTTP_STATUS_304_NOT_MODIFIED
,
71 HTTP_STATUS_305_USE_PROXY
,
72 HTTP_STATUS_307_TEMPORARY_REDIRECT
,
73 HTTP_STATUS_400_BAD_REQUEST
,
74 HTTP_STATUS_401_UNAUTHORIZED
,
75 HTTP_STATUS_402_PAYMENT_REQUIRED
,
76 HTTP_STATUS_403_FORBIDDEN
,
77 HTTP_STATUS_404_NOT_FOUND
,
78 HTTP_STATUS_405_METHOD_NOT_ALLOWED
,
79 HTTP_STATUS_406_NOT_ACCEPTABLE
,
80 HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED
,
81 HTTP_STATUS_408_REQUEST_TIME_OUT
,
82 HTTP_STATUS_409_CONFLICT
,
84 HTTP_STATUS_411_LENGTH_REQUIRED
,
85 HTTP_STATUS_412_PRECONDITION_FAILED
,
86 HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE
,
87 HTTP_STATUS_414_REQUEST_URI_TOO_LARGE
,
88 HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE
,
89 HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED
,
90 HTTP_STATUS_417_EXPECTATION_FAILED
,
91 HTTP_STATUS_500_INTERNAL_SERVER_ERROR
,
92 HTTP_STATUS_501_NOT_IMPLEMENTED
,
93 HTTP_STATUS_502_BAD_GATEWAY
,
94 HTTP_STATUS_503_SERVICE_UNAVAILABLE
,
95 HTTP_STATUS_504_GATEWAY_TIME_OUT
,
96 HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED
97 } EFI_HTTP_STATUS_CODE
;
100 /// EFI_HTTPv4_ACCESS_POINT
104 /// Set to TRUE to instruct the EFI HTTP instance to use the default address
105 /// information in every TCP connection made by this instance. In addition, when set
106 /// to TRUE, LocalAddress and LocalSubnet are ignored.
108 BOOLEAN UseDefaultAddress
;
110 /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be
111 /// used in every TCP connection opened by this instance.
113 EFI_IPv4_ADDRESS LocalAddress
;
115 /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used
116 /// in every TCP connection opened by this instance.
118 EFI_IPv4_ADDRESS LocalSubnet
;
120 /// This defines the local port to be used in
121 /// every TCP connection opened by this instance.
124 } EFI_HTTPv4_ACCESS_POINT
;
127 /// EFI_HTTPv6_ACCESS_POINT
131 /// Local IP address to be used in every TCP connection opened by this instance.
133 EFI_IPv6_ADDRESS LocalAddress
;
135 /// Local port to be used in every TCP connection opened by this instance.
138 } EFI_HTTPv6_ACCESS_POINT
;
141 /// EFI_HTTP_CONFIG_DATA_ACCESS_POINT
147 /// HTTP version that this instance will support.
149 EFI_HTTP_VERSION HttpVersion
;
151 /// Time out (in milliseconds) when blocking for requests.
153 UINT32 TimeOutMillisec
;
155 /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If
156 /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE,
157 /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL.
159 BOOLEAN LocalAddressIsIPv6
;
163 /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and
164 /// port used by the underlying TCP protocol.
166 EFI_HTTPv4_ACCESS_POINT
*IPv4Node
;
168 /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port
169 /// used by the underlying TCP protocol.
171 EFI_HTTPv6_ACCESS_POINT
*IPv6Node
;
173 } EFI_HTTP_CONFIG_DATA
;
176 /// EFI_HTTP_REQUEST_DATA
180 /// The HTTP method (e.g. GET, POST) for this HTTP Request.
182 EFI_HTTP_METHOD Method
;
184 /// The URI of a remote host. From the information in this field, the HTTP instance
185 /// will be able to determine whether to use HTTP or HTTPS and will also be able to
186 /// determine the port number to use. If no port number is specified, port 80 (HTTP)
187 /// is assumed. See RFC 3986 for more details on URI syntax.
190 } EFI_HTTP_REQUEST_DATA
;
193 /// EFI_HTTP_RESPONSE_DATA
197 /// Response status code returned by the remote host.
199 EFI_HTTP_STATUS_CODE StatusCode
;
200 } EFI_HTTP_RESPONSE_DATA
;
207 /// Null terminated string which describes a field name. See RFC 2616 Section 14 for
208 /// detailed information about field names.
212 /// Null terminated string which describes the corresponding field value. See RFC 2616
213 /// Section 14 for detailed information about field values.
223 /// HTTP message data.
227 /// When the token is used to send a HTTP request, Request is a pointer to storage that
228 /// contains such data as URL and HTTP method.
230 EFI_HTTP_REQUEST_DATA
*Request
;
232 /// When used to await a response, Response points to storage containing HTTP response
235 EFI_HTTP_RESPONSE_DATA
*Response
;
238 /// Number of HTTP header structures in Headers list. On request, this count is
239 /// provided by the caller. On response, this count is provided by the HTTP driver.
243 /// Array containing list of HTTP headers. On request, this array is populated by the
244 /// caller. On response, this array is allocated and populated by the HTTP driver. It
245 /// is the responsibility of the caller to free this memory on both request and
248 EFI_HTTP_HEADER
*Headers
;
250 /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type.
254 /// Body associated with the HTTP request or response. This can be NULL depending on
255 /// the HttpMethod type.
266 /// This Event will be signaled after the Status field is updated by the EFI HTTP
267 /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority
268 /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK.
272 /// Status will be set to one of the following value if the HTTP request is
273 /// successfully sent or if an unexpected error occurs:
274 /// EFI_SUCCESS: The HTTP request was successfully sent to the remote host.
275 /// EFI_HTTP_ERROR: The response message was successfully received but contains a
276 /// HTTP error. The response status code is returned in token.
277 /// EFI_ABORTED: The HTTP request was cancelled by the caller and removed from
278 /// the transmit queue.
279 /// EFI_TIMEOUT: The HTTP request timed out before reaching the remote host.
280 /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.
284 /// Pointer to storage containing HTTP message data.
286 EFI_HTTP_MESSAGE
*Message
;
290 Returns the operational parameters for the current HTTP child instance.
292 The GetModeData() function is used to read the current mode data (operational
293 parameters) for this HTTP protocol instance.
295 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
296 @param[out] HttpConfigData Point to buffer for operational parameters of this
299 @retval EFI_SUCCESS Operation succeeded.
300 @retval EFI_INVALID_PARAMETER This is NULL.
301 HttpConfigData is NULL.
302 HttpInstance->LocalAddressIsIPv6 is FALSE and
303 HttpConfigData->IPv4Node is NULL.
304 HttpInstance->LocalAddressIsIPv6 is TRUE and
305 HttpConfigData->IPv6Node is NULL.
306 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
310 (EFIAPI
* EFI_HTTP_GET_MODE_DATA
)(
311 IN EFI_HTTP_PROTOCOL
*This
,
312 OUT EFI_HTTP_CONFIG_DATA
*HttpConfigData
316 Initialize or brutally reset the operational parameters for this EFI HTTP instance.
318 The Configure() function does the following:
319 When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring
320 timeout, local address, port, etc.
321 When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active
322 connections with remote hosts, canceling all asynchronous tokens, and flush request
323 and response buffers without informing the appropriate hosts.
325 No other EFI HTTP function can be executed by this instance until the Configure()
326 function is executed and returns successfully.
328 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
329 @param[in] HttpConfigData Pointer to the configure data to configure the instance.
331 @retval EFI_SUCCESS Operation succeeded.
332 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
334 HttpConfigData is NULL.
335 HttpConfigData->LocalAddressIsIPv6 is FALSE and
336 HttpConfigData->IPv4Node is NULL.
337 HttpConfigData->LocalAddressIsIPv6 is TRUE and
338 HttpConfigData->IPv6Node is NULL.
339 @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling
340 Configure() with NULL to reset it.
341 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
342 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
343 executing Configure().
344 @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported
345 in the implementation.
349 (EFIAPI
* EFI_HTTP_CONFIGURE
)(
350 IN EFI_HTTP_PROTOCOL
*This
,
351 IN EFI_HTTP_CONFIG_DATA
*HttpConfigData
355 The Request() function queues an HTTP request to this HTTP instance,
356 similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent
357 successfully, or if there is an error, Status in token will be updated and Event will
360 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
361 @param[in] Token Pointer to storage containing HTTP request token.
363 @retval EFI_SUCCESS Outgoing data was processed.
364 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
365 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
366 @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.
367 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
370 Token->Message is NULL.
371 Token->Message->Body is not NULL,
372 Token->Message->BodyLength is non-zero, and
373 Token->Message->Data is NULL, but a previous call to
374 Request()has not been completed successfully.
375 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
376 @retval EFI_UNSUPPORTED The HTTP method is not supported in current implementation.
380 (EFIAPI
*EFI_HTTP_REQUEST
) (
381 IN EFI_HTTP_PROTOCOL
*This
,
382 IN EFI_HTTP_TOKEN
*Token
386 Abort an asynchronous HTTP request or response token.
388 The Cancel() function aborts a pending HTTP request or response transaction. If
389 Token is not NULL and the token is in transmit or receive queues when it is being
390 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will
391 be signaled. If the token is not in one of the queues, which usually means that the
392 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,
393 all asynchronous tokens issued by Request() or Response() will be aborted.
395 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
396 @param[in] Token Point to storage containing HTTP request or response
399 @retval EFI_SUCCESS Request and Response queues are successfully flushed.
400 @retval EFI_INVALID_PARAMETER This is NULL.
401 @retval EFI_NOT_STARTED This instance hasn't been configured.
402 @retval EFI_NOT_FOUND The asynchronous request or response token is not
404 @retval EFI_UNSUPPORTED The implementation does not support this function.
408 (EFIAPI
*EFI_HTTP_CANCEL
)(
409 IN EFI_HTTP_PROTOCOL
*This
,
410 IN EFI_HTTP_TOKEN
*Token
414 The Response() function queues an HTTP response to this HTTP instance, similar to
415 Receive() function in the EFI TCP driver. When the HTTP Response is received successfully,
416 or if there is an error, Status in token will be updated and Event will be signaled.
418 The HTTP driver will queue a receive token to the underlying TCP instance. When data
419 is received in the underlying TCP instance, the data will be parsed and Token will
420 be populated with the response data. If the data received from the remote host
421 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting
422 (asynchronously) for more data to be sent from the remote host before signaling
425 It is the responsibility of the caller to allocate a buffer for Body and specify the
426 size in BodyLength. If the remote host provides a response that contains a content
427 body, up to BodyLength bytes will be copied from the receive buffer into Body and
428 BodyLength will be updated with the amount of bytes received and copied to Body. This
429 allows the client to download a large file in chunks instead of into one contiguous
430 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is
431 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive
432 token to underlying TCP instance. If data arrives in the receive buffer, up to
433 BodyLength bytes of data will be copied to Body. The HTTP driver will then update
434 BodyLength with the amount of bytes received and copied to Body.
436 If the HTTP driver does not have an open underlying TCP connection with the host
437 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is
438 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain
439 an open TCP connection between client and host.
441 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
442 @param[in] Token Pointer to storage containing HTTP response token.
444 @retval EFI_SUCCESS Allocation succeeded.
445 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been
447 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
450 Token->Message->Headers is NULL.
451 Token->Message is NULL.
452 Token->Message->Body is not NULL,
453 Token->Message->BodyLength is non-zero, and
454 Token->Message->Data is NULL, but a previous call to
455 Response() has not been completed successfully.
456 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
457 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host
458 specified by response URL.
462 (EFIAPI
*EFI_HTTP_RESPONSE
) (
463 IN EFI_HTTP_PROTOCOL
*This
,
464 IN EFI_HTTP_TOKEN
*Token
468 The Poll() function can be used by network drivers and applications to increase the
469 rate that data packets are moved between the communication devices and the transmit
472 In some systems, the periodic timer event in the managed network driver may not poll
473 the underlying communications device fast enough to transmit and/or receive all data
474 packets without missing incoming packets or dropping outgoing packets. Drivers and
475 applications that are experiencing packet loss should try calling the Poll() function
478 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
480 @retval EFI_SUCCESS Incoming or outgoing data was processed..
481 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred
482 @retval EFI_INVALID_PARAMETER This is NULL.
483 @retval EFI_NOT_READY No incoming or outgoing data is processed.
484 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
488 (EFIAPI
*EFI_HTTP_POLL
) (
489 IN EFI_HTTP_PROTOCOL
*This
493 /// The EFI HTTP protocol is designed to be used by EFI drivers and applications to
494 /// create and transmit HTTP Requests, as well as handle HTTP responses that are
495 /// returned by a remote host. This EFI protocol uses and relies on an underlying EFI
498 struct _EFI_HTTP_PROTOCOL
{
499 EFI_HTTP_GET_MODE_DATA GetModeData
;
500 EFI_HTTP_CONFIGURE Configure
;
501 EFI_HTTP_REQUEST Request
;
502 EFI_HTTP_CANCEL Cancel
;
503 EFI_HTTP_RESPONSE Response
;
507 #endif /* SHIM_HTTP_H */