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 - 2018, Intel Corporation. All rights reserved.<BR>
8 (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP<BR>
9 SPDX-License-Identifier: BSD-2-Clause-Patent
11 @par Revision Reference:
12 This Protocol is introduced in UEFI Specification 2.5
16 #ifndef __EFI_HTTP_PROTOCOL_H__
17 #define __EFI_HTTP_PROTOCOL_H__
19 #define EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID \
21 0xbdc8e6af, 0xd9bc, 0x4379, {0xa7, 0x2a, 0xe0, 0xc4, 0xe7, 0x5d, 0xae, 0x1c } \
24 #define EFI_HTTP_PROTOCOL_GUID \
26 0x7a59b29b, 0x910b, 0x4171, {0x82, 0x42, 0xa8, 0x5a, 0x0d, 0xf2, 0x5b, 0x5b } \
29 typedef struct _EFI_HTTP_PROTOCOL EFI_HTTP_PROTOCOL
;
37 HttpVersionUnsupported
57 /// EFI_HTTP_STATUS_CODE
60 HTTP_STATUS_UNSUPPORTED_STATUS
= 0,
61 HTTP_STATUS_100_CONTINUE
,
62 HTTP_STATUS_101_SWITCHING_PROTOCOLS
,
64 HTTP_STATUS_201_CREATED
,
65 HTTP_STATUS_202_ACCEPTED
,
66 HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION
,
67 HTTP_STATUS_204_NO_CONTENT
,
68 HTTP_STATUS_205_RESET_CONTENT
,
69 HTTP_STATUS_206_PARTIAL_CONTENT
,
70 HTTP_STATUS_300_MULTIPLE_CHOICES
,
71 HTTP_STATUS_301_MOVED_PERMANENTLY
,
72 HTTP_STATUS_302_FOUND
,
73 HTTP_STATUS_303_SEE_OTHER
,
74 HTTP_STATUS_304_NOT_MODIFIED
,
75 HTTP_STATUS_305_USE_PROXY
,
76 HTTP_STATUS_307_TEMPORARY_REDIRECT
,
77 HTTP_STATUS_400_BAD_REQUEST
,
78 HTTP_STATUS_401_UNAUTHORIZED
,
79 HTTP_STATUS_402_PAYMENT_REQUIRED
,
80 HTTP_STATUS_403_FORBIDDEN
,
81 HTTP_STATUS_404_NOT_FOUND
,
82 HTTP_STATUS_405_METHOD_NOT_ALLOWED
,
83 HTTP_STATUS_406_NOT_ACCEPTABLE
,
84 HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED
,
85 HTTP_STATUS_408_REQUEST_TIME_OUT
,
86 HTTP_STATUS_409_CONFLICT
,
88 HTTP_STATUS_411_LENGTH_REQUIRED
,
89 HTTP_STATUS_412_PRECONDITION_FAILED
,
90 HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE
,
91 HTTP_STATUS_414_REQUEST_URI_TOO_LARGE
,
92 HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE
,
93 HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED
,
94 HTTP_STATUS_417_EXPECTATION_FAILED
,
95 HTTP_STATUS_500_INTERNAL_SERVER_ERROR
,
96 HTTP_STATUS_501_NOT_IMPLEMENTED
,
97 HTTP_STATUS_502_BAD_GATEWAY
,
98 HTTP_STATUS_503_SERVICE_UNAVAILABLE
,
99 HTTP_STATUS_504_GATEWAY_TIME_OUT
,
100 HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED
,
101 HTTP_STATUS_308_PERMANENT_REDIRECT
102 } EFI_HTTP_STATUS_CODE
;
105 /// EFI_HTTPv4_ACCESS_POINT
109 /// Set to TRUE to instruct the EFI HTTP instance to use the default address
110 /// information in every TCP connection made by this instance. In addition, when set
111 /// to TRUE, LocalAddress and LocalSubnet are ignored.
113 BOOLEAN UseDefaultAddress
;
115 /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be
116 /// used in every TCP connection opened by this instance.
118 EFI_IPv4_ADDRESS LocalAddress
;
120 /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used
121 /// in every TCP connection opened by this instance.
123 EFI_IPv4_ADDRESS LocalSubnet
;
125 /// This defines the local port to be used in
126 /// every TCP connection opened by this instance.
129 } EFI_HTTPv4_ACCESS_POINT
;
132 /// EFI_HTTPv6_ACCESS_POINT
136 /// Local IP address to be used in every TCP connection opened by this instance.
138 EFI_IPv6_ADDRESS LocalAddress
;
140 /// Local port to be used in every TCP connection opened by this instance.
143 } EFI_HTTPv6_ACCESS_POINT
;
146 /// EFI_HTTP_CONFIG_DATA_ACCESS_POINT
151 /// HTTP version that this instance will support.
153 EFI_HTTP_VERSION HttpVersion
;
155 /// Time out (in milliseconds) when blocking for requests.
157 UINT32 TimeOutMillisec
;
159 /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If
160 /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE,
161 /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL.
163 BOOLEAN LocalAddressIsIPv6
;
167 /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and
168 /// port used by the underlying TCP protocol.
170 EFI_HTTPv4_ACCESS_POINT
*IPv4Node
;
172 /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port
173 /// used by the underlying TCP protocol.
175 EFI_HTTPv6_ACCESS_POINT
*IPv6Node
;
177 } EFI_HTTP_CONFIG_DATA
;
180 /// EFI_HTTP_REQUEST_DATA
184 /// The HTTP method (e.g. GET, POST) for this HTTP Request.
186 EFI_HTTP_METHOD Method
;
188 /// The URI of a remote host. From the information in this field, the HTTP instance
189 /// will be able to determine whether to use HTTP or HTTPS and will also be able to
190 /// determine the port number to use. If no port number is specified, port 80 (HTTP)
191 /// is assumed. See RFC 3986 for more details on URI syntax.
194 } EFI_HTTP_REQUEST_DATA
;
197 /// EFI_HTTP_RESPONSE_DATA
201 /// Response status code returned by the remote host.
203 EFI_HTTP_STATUS_CODE StatusCode
;
204 } EFI_HTTP_RESPONSE_DATA
;
211 /// Null terminated string which describes a field name. See RFC 2616 Section 14 for
212 /// detailed information about field names.
216 /// Null terminated string which describes the corresponding field value. See RFC 2616
217 /// Section 14 for detailed information about field values.
227 /// HTTP message data.
231 /// When the token is used to send a HTTP request, Request is a pointer to storage that
232 /// contains such data as URL and HTTP method.
234 EFI_HTTP_REQUEST_DATA
*Request
;
236 /// When used to await a response, Response points to storage containing HTTP response
239 EFI_HTTP_RESPONSE_DATA
*Response
;
242 /// Number of HTTP header structures in Headers list. On request, this count is
243 /// provided by the caller. On response, this count is provided by the HTTP driver.
247 /// Array containing list of HTTP headers. On request, this array is populated by the
248 /// caller. On response, this array is allocated and populated by the HTTP driver. It
249 /// is the responsibility of the caller to free this memory on both request and
252 EFI_HTTP_HEADER
*Headers
;
254 /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type.
258 /// Body associated with the HTTP request or response. This can be NULL depending on
259 /// the HttpMethod type.
269 /// This Event will be signaled after the Status field is updated by the EFI HTTP
270 /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority
271 /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK.
275 /// Status will be set to one of the following value if the HTTP request is
276 /// successfully sent or if an unexpected error occurs:
277 /// EFI_SUCCESS: The HTTP request was successfully sent to the remote host.
278 /// EFI_HTTP_ERROR: The response message was successfully received but contains a
279 /// HTTP error. The response status code is returned in token.
280 /// EFI_ABORTED: The HTTP request was cancelled by the caller and removed from
281 /// the transmit queue.
282 /// EFI_TIMEOUT: The HTTP request timed out before reaching the remote host.
283 /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.
287 /// Pointer to storage containing HTTP message data.
289 EFI_HTTP_MESSAGE
*Message
;
293 Returns the operational parameters for the current HTTP child instance.
295 The GetModeData() function is used to read the current mode data (operational
296 parameters) for this HTTP protocol instance.
298 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
299 @param[out] HttpConfigData Point to buffer for operational parameters of this
300 HTTP instance. It is the responsibility of the caller
301 to allocate the memory for HttpConfigData and
302 HttpConfigData->AccessPoint.IPv6Node/IPv4Node. In fact,
303 it is recommended to allocate sufficient memory to record
304 IPv6Node since it is big enough for all possibilities.
306 @retval EFI_SUCCESS Operation succeeded.
307 @retval EFI_INVALID_PARAMETER This is NULL.
308 HttpConfigData is NULL.
309 HttpConfigData->AccessPoint.IPv4Node or
310 HttpConfigData->AccessPoint.IPv6Node is NULL.
311 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
315 (EFIAPI
*EFI_HTTP_GET_MODE_DATA
)(
316 IN EFI_HTTP_PROTOCOL
*This
,
317 OUT EFI_HTTP_CONFIG_DATA
*HttpConfigData
321 Initialize or brutally reset the operational parameters for this EFI HTTP instance.
323 The Configure() function does the following:
324 When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring
325 timeout, local address, port, etc.
326 When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active
327 connections with remote hosts, canceling all asynchronous tokens, and flush request
328 and response buffers without informing the appropriate hosts.
330 No other EFI HTTP function can be executed by this instance until the Configure()
331 function is executed and returns successfully.
333 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
334 @param[in] HttpConfigData Pointer to the configure data to configure the instance.
336 @retval EFI_SUCCESS Operation succeeded.
337 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
339 HttpConfigData->LocalAddressIsIPv6 is FALSE and
340 HttpConfigData->AccessPoint.IPv4Node is NULL.
341 HttpConfigData->LocalAddressIsIPv6 is TRUE and
342 HttpConfigData->AccessPoint.IPv6Node is NULL.
343 @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling
344 Configure() with NULL to reset it.
345 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
346 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
347 executing Configure().
348 @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported
349 in the implementation.
353 (EFIAPI
*EFI_HTTP_CONFIGURE
)(
354 IN EFI_HTTP_PROTOCOL
*This
,
355 IN EFI_HTTP_CONFIG_DATA
*HttpConfigData OPTIONAL
359 The Request() function queues an HTTP request to this HTTP instance,
360 similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent
361 successfully, or if there is an error, Status in token will be updated and Event will
364 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
365 @param[in] Token Pointer to storage containing HTTP request token.
367 @retval EFI_SUCCESS Outgoing data was processed.
368 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
369 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
370 @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.
371 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
374 Token->Message is NULL.
375 Token->Message->Body is not NULL,
376 Token->Message->BodyLength is non-zero, and
377 Token->Message->Data is NULL, but a previous call to
378 Request()has not been completed successfully.
379 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
380 @retval EFI_UNSUPPORTED The HTTP method is not supported in current implementation.
384 (EFIAPI
*EFI_HTTP_REQUEST
)(
385 IN EFI_HTTP_PROTOCOL
*This
,
386 IN EFI_HTTP_TOKEN
*Token
390 Abort an asynchronous HTTP request or response token.
392 The Cancel() function aborts a pending HTTP request or response transaction. If
393 Token is not NULL and the token is in transmit or receive queues when it is being
394 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will
395 be signaled. If the token is not in one of the queues, which usually means that the
396 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,
397 all asynchronous tokens issued by Request() or Response() will be aborted.
399 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
400 @param[in] Token Point to storage containing HTTP request or response
403 @retval EFI_SUCCESS Request and Response queues are successfully flushed.
404 @retval EFI_INVALID_PARAMETER This is NULL.
405 @retval EFI_NOT_STARTED This instance hasn't been configured.
406 @retval EFI_NOT_FOUND The asynchronous request or response token is not
408 @retval EFI_UNSUPPORTED The implementation does not support this function.
412 (EFIAPI
*EFI_HTTP_CANCEL
)(
413 IN EFI_HTTP_PROTOCOL
*This
,
414 IN EFI_HTTP_TOKEN
*Token
418 The Response() function queues an HTTP response to this HTTP instance, similar to
419 Receive() function in the EFI TCP driver. When the HTTP Response is received successfully,
420 or if there is an error, Status in token will be updated and Event will be signaled.
422 The HTTP driver will queue a receive token to the underlying TCP instance. When data
423 is received in the underlying TCP instance, the data will be parsed and Token will
424 be populated with the response data. If the data received from the remote host
425 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting
426 (asynchronously) for more data to be sent from the remote host before signaling
429 It is the responsibility of the caller to allocate a buffer for Body and specify the
430 size in BodyLength. If the remote host provides a response that contains a content
431 body, up to BodyLength bytes will be copied from the receive buffer into Body and
432 BodyLength will be updated with the amount of bytes received and copied to Body. This
433 allows the client to download a large file in chunks instead of into one contiguous
434 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is
435 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive
436 token to underlying TCP instance. If data arrives in the receive buffer, up to
437 BodyLength bytes of data will be copied to Body. The HTTP driver will then update
438 BodyLength with the amount of bytes received and copied to Body.
440 If the HTTP driver does not have an open underlying TCP connection with the host
441 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is
442 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain
443 an open TCP connection between client and host.
445 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
446 @param[in] Token Pointer to storage containing HTTP response token.
448 @retval EFI_SUCCESS Allocation succeeded.
449 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been
451 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
454 Token->Message->Headers is NULL.
455 Token->Message is NULL.
456 Token->Message->Body is not NULL,
457 Token->Message->BodyLength is non-zero, and
458 Token->Message->Data is NULL, but a previous call to
459 Response() has not been completed successfully.
460 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
461 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host
462 specified by response URL.
466 (EFIAPI
*EFI_HTTP_RESPONSE
)(
467 IN EFI_HTTP_PROTOCOL
*This
,
468 IN EFI_HTTP_TOKEN
*Token
472 The Poll() function can be used by network drivers and applications to increase the
473 rate that data packets are moved between the communication devices and the transmit
476 In some systems, the periodic timer event in the managed network driver may not poll
477 the underlying communications device fast enough to transmit and/or receive all data
478 packets without missing incoming packets or dropping outgoing packets. Drivers and
479 applications that are experiencing packet loss should try calling the Poll() function
482 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
484 @retval EFI_SUCCESS Incoming or outgoing data was processed..
485 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred
486 @retval EFI_INVALID_PARAMETER This is NULL.
487 @retval EFI_NOT_READY No incoming or outgoing data is processed.
488 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
492 (EFIAPI
*EFI_HTTP_POLL
)(
493 IN EFI_HTTP_PROTOCOL
*This
497 /// The EFI HTTP protocol is designed to be used by EFI drivers and applications to
498 /// create and transmit HTTP Requests, as well as handle HTTP responses that are
499 /// returned by a remote host. This EFI protocol uses and relies on an underlying EFI
502 struct _EFI_HTTP_PROTOCOL
{
503 EFI_HTTP_GET_MODE_DATA GetModeData
;
504 EFI_HTTP_CONFIGURE Configure
;
505 EFI_HTTP_REQUEST Request
;
506 EFI_HTTP_CANCEL Cancel
;
507 EFI_HTTP_RESPONSE Response
;
511 extern EFI_GUID gEfiHttpServiceBindingProtocolGuid
;
512 extern EFI_GUID gEfiHttpProtocolGuid
;