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 - 2017, Intel Corporation. All rights reserved.<BR>
8 (C) Copyright 2015-2017 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
22 #ifndef __EFI_HTTP_PROTOCOL_H__
23 #define __EFI_HTTP_PROTOCOL_H__
25 #define EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID \
27 0xbdc8e6af, 0xd9bc, 0x4379, {0xa7, 0x2a, 0xe0, 0xc4, 0xe7, 0x5d, 0xae, 0x1c } \
30 #define EFI_HTTP_PROTOCOL_GUID \
32 0x7a59b29b, 0x910b, 0x4171, {0x82, 0x42, 0xa8, 0x5a, 0x0d, 0xf2, 0x5b, 0x5b } \
35 typedef struct _EFI_HTTP_PROTOCOL EFI_HTTP_PROTOCOL
;
43 HttpVersionUnsupported
63 /// EFI_HTTP_STATUS_CODE
66 HTTP_STATUS_UNSUPPORTED_STATUS
= 0,
67 HTTP_STATUS_100_CONTINUE
,
68 HTTP_STATUS_101_SWITCHING_PROTOCOLS
,
70 HTTP_STATUS_201_CREATED
,
71 HTTP_STATUS_202_ACCEPTED
,
72 HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION
,
73 HTTP_STATUS_204_NO_CONTENT
,
74 HTTP_STATUS_205_RESET_CONTENT
,
75 HTTP_STATUS_206_PARTIAL_CONTENT
,
76 HTTP_STATUS_300_MULTIPLE_CHOICES
,
77 HTTP_STATUS_301_MOVED_PERMANENTLY
,
78 HTTP_STATUS_302_FOUND
,
79 HTTP_STATUS_303_SEE_OTHER
,
80 HTTP_STATUS_304_NOT_MODIFIED
,
81 HTTP_STATUS_305_USE_PROXY
,
82 HTTP_STATUS_307_TEMPORARY_REDIRECT
,
83 HTTP_STATUS_400_BAD_REQUEST
,
84 HTTP_STATUS_401_UNAUTHORIZED
,
85 HTTP_STATUS_402_PAYMENT_REQUIRED
,
86 HTTP_STATUS_403_FORBIDDEN
,
87 HTTP_STATUS_404_NOT_FOUND
,
88 HTTP_STATUS_405_METHOD_NOT_ALLOWED
,
89 HTTP_STATUS_406_NOT_ACCEPTABLE
,
90 HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED
,
91 HTTP_STATUS_408_REQUEST_TIME_OUT
,
92 HTTP_STATUS_409_CONFLICT
,
94 HTTP_STATUS_411_LENGTH_REQUIRED
,
95 HTTP_STATUS_412_PRECONDITION_FAILED
,
96 HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE
,
97 HTTP_STATUS_414_REQUEST_URI_TOO_LARGE
,
98 HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE
,
99 HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED
,
100 HTTP_STATUS_417_EXPECTATION_FAILED
,
101 HTTP_STATUS_500_INTERNAL_SERVER_ERROR
,
102 HTTP_STATUS_501_NOT_IMPLEMENTED
,
103 HTTP_STATUS_502_BAD_GATEWAY
,
104 HTTP_STATUS_503_SERVICE_UNAVAILABLE
,
105 HTTP_STATUS_504_GATEWAY_TIME_OUT
,
106 HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED
,
107 HTTP_STATUS_308_PERMANENT_REDIRECT
108 } EFI_HTTP_STATUS_CODE
;
111 /// EFI_HTTPv4_ACCESS_POINT
115 /// Set to TRUE to instruct the EFI HTTP instance to use the default address
116 /// information in every TCP connection made by this instance. In addition, when set
117 /// to TRUE, LocalAddress and LocalSubnet are ignored.
119 BOOLEAN UseDefaultAddress
;
121 /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be
122 /// used in every TCP connection opened by this instance.
124 EFI_IPv4_ADDRESS LocalAddress
;
126 /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used
127 /// in every TCP connection opened by this instance.
129 EFI_IPv4_ADDRESS LocalSubnet
;
131 /// This defines the local port to be used in
132 /// every TCP connection opened by this instance.
135 } EFI_HTTPv4_ACCESS_POINT
;
138 /// EFI_HTTPv6_ACCESS_POINT
142 /// Local IP address to be used in every TCP connection opened by this instance.
144 EFI_IPv6_ADDRESS LocalAddress
;
146 /// Local port to be used in every TCP connection opened by this instance.
149 } EFI_HTTPv6_ACCESS_POINT
;
152 /// EFI_HTTP_CONFIG_DATA_ACCESS_POINT
158 /// HTTP version that this instance will support.
160 EFI_HTTP_VERSION HttpVersion
;
162 /// Time out (in milliseconds) when blocking for requests.
164 UINT32 TimeOutMillisec
;
166 /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If
167 /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE,
168 /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL.
170 BOOLEAN LocalAddressIsIPv6
;
174 /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and
175 /// port used by the underlying TCP protocol.
177 EFI_HTTPv4_ACCESS_POINT
*IPv4Node
;
179 /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port
180 /// used by the underlying TCP protocol.
182 EFI_HTTPv6_ACCESS_POINT
*IPv6Node
;
184 } EFI_HTTP_CONFIG_DATA
;
187 /// EFI_HTTP_REQUEST_DATA
191 /// The HTTP method (e.g. GET, POST) for this HTTP Request.
193 EFI_HTTP_METHOD Method
;
195 /// The URI of a remote host. From the information in this field, the HTTP instance
196 /// will be able to determine whether to use HTTP or HTTPS and will also be able to
197 /// determine the port number to use. If no port number is specified, port 80 (HTTP)
198 /// is assumed. See RFC 3986 for more details on URI syntax.
201 } EFI_HTTP_REQUEST_DATA
;
204 /// EFI_HTTP_RESPONSE_DATA
208 /// Response status code returned by the remote host.
210 EFI_HTTP_STATUS_CODE StatusCode
;
211 } EFI_HTTP_RESPONSE_DATA
;
218 /// Null terminated string which describes a field name. See RFC 2616 Section 14 for
219 /// detailed information about field names.
223 /// Null terminated string which describes the corresponding field value. See RFC 2616
224 /// Section 14 for detailed information about field values.
234 /// HTTP message data.
238 /// When the token is used to send a HTTP request, Request is a pointer to storage that
239 /// contains such data as URL and HTTP method.
241 EFI_HTTP_REQUEST_DATA
*Request
;
243 /// When used to await a response, Response points to storage containing HTTP response
246 EFI_HTTP_RESPONSE_DATA
*Response
;
249 /// Number of HTTP header structures in Headers list. On request, this count is
250 /// provided by the caller. On response, this count is provided by the HTTP driver.
254 /// Array containing list of HTTP headers. On request, this array is populated by the
255 /// caller. On response, this array is allocated and populated by the HTTP driver. It
256 /// is the responsibility of the caller to free this memory on both request and
259 EFI_HTTP_HEADER
*Headers
;
261 /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type.
265 /// Body associated with the HTTP request or response. This can be NULL depending on
266 /// the HttpMethod type.
277 /// This Event will be signaled after the Status field is updated by the EFI HTTP
278 /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority
279 /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK.
283 /// Status will be set to one of the following value if the HTTP request is
284 /// successfully sent or if an unexpected error occurs:
285 /// EFI_SUCCESS: The HTTP request was successfully sent to the remote host.
286 /// EFI_HTTP_ERROR: The response message was successfully received but contains a
287 /// HTTP error. The response status code is returned in token.
288 /// EFI_ABORTED: The HTTP request was cancelled by the caller and removed from
289 /// the transmit queue.
290 /// EFI_TIMEOUT: The HTTP request timed out before reaching the remote host.
291 /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.
295 /// Pointer to storage containing HTTP message data.
297 EFI_HTTP_MESSAGE
*Message
;
301 Returns the operational parameters for the current HTTP child instance.
303 The GetModeData() function is used to read the current mode data (operational
304 parameters) for this HTTP protocol instance.
306 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
307 @param[out] HttpConfigData Point to buffer for operational parameters of this
308 HTTP instance. It is the responsibility of the caller
309 to allocate the memory for HttpConfigData and
310 HttpConfigData->AccessPoint.IPv6Node/IPv4Node. In fact,
311 it is recommended to allocate sufficient memory to record
312 IPv6Node since it is big enough for all possibilities.
314 @retval EFI_SUCCESS Operation succeeded.
315 @retval EFI_INVALID_PARAMETER This is NULL.
316 HttpConfigData is NULL.
317 HttpConfigData->AccessPoint.IPv4Node or
318 HttpConfigData->AccessPoint.IPv6Node is NULL.
319 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
323 (EFIAPI
*EFI_HTTP_GET_MODE_DATA
)(
324 IN EFI_HTTP_PROTOCOL
*This
,
325 OUT EFI_HTTP_CONFIG_DATA
*HttpConfigData
329 Initialize or brutally reset the operational parameters for this EFI HTTP instance.
331 The Configure() function does the following:
332 When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring
333 timeout, local address, port, etc.
334 When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active
335 connections with remote hosts, canceling all asynchronous tokens, and flush request
336 and response buffers without informing the appropriate hosts.
338 No other EFI HTTP function can be executed by this instance until the Configure()
339 function is executed and returns successfully.
341 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
342 @param[in] HttpConfigData Pointer to the configure data to configure the instance.
344 @retval EFI_SUCCESS Operation succeeded.
345 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
347 HttpConfigData->LocalAddressIsIPv6 is FALSE and
348 HttpConfigData->AccessPoint.IPv4Node is NULL.
349 HttpConfigData->LocalAddressIsIPv6 is TRUE and
350 HttpConfigData->AccessPoint.IPv6Node is NULL.
351 @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling
352 Configure() with NULL to reset it.
353 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
354 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
355 executing Configure().
356 @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported
357 in the implementation.
361 (EFIAPI
*EFI_HTTP_CONFIGURE
)(
362 IN EFI_HTTP_PROTOCOL
*This
,
363 IN EFI_HTTP_CONFIG_DATA
*HttpConfigData OPTIONAL
367 The Request() function queues an HTTP request to this HTTP instance,
368 similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent
369 successfully, or if there is an error, Status in token will be updated and Event will
372 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
373 @param[in] Token Pointer to storage containing HTTP request token.
375 @retval EFI_SUCCESS Outgoing data was processed.
376 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
377 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
378 @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.
379 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
382 Token->Message is NULL.
383 Token->Message->Body is not NULL,
384 Token->Message->BodyLength is non-zero, and
385 Token->Message->Data is NULL, but a previous call to
386 Request()has not been completed successfully.
387 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
388 @retval EFI_UNSUPPORTED The HTTP method is not supported in current implementation.
392 (EFIAPI
*EFI_HTTP_REQUEST
) (
393 IN EFI_HTTP_PROTOCOL
*This
,
394 IN EFI_HTTP_TOKEN
*Token
398 Abort an asynchronous HTTP request or response token.
400 The Cancel() function aborts a pending HTTP request or response transaction. If
401 Token is not NULL and the token is in transmit or receive queues when it is being
402 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will
403 be signaled. If the token is not in one of the queues, which usually means that the
404 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,
405 all asynchronous tokens issued by Request() or Response() will be aborted.
407 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
408 @param[in] Token Point to storage containing HTTP request or response
411 @retval EFI_SUCCESS Request and Response queues are successfully flushed.
412 @retval EFI_INVALID_PARAMETER This is NULL.
413 @retval EFI_NOT_STARTED This instance hasn't been configured.
414 @retval EFI_NOT_FOUND The asynchronous request or response token is not
416 @retval EFI_UNSUPPORTED The implementation does not support this function.
420 (EFIAPI
*EFI_HTTP_CANCEL
)(
421 IN EFI_HTTP_PROTOCOL
*This
,
422 IN EFI_HTTP_TOKEN
*Token
426 The Response() function queues an HTTP response to this HTTP instance, similar to
427 Receive() function in the EFI TCP driver. When the HTTP Response is received successfully,
428 or if there is an error, Status in token will be updated and Event will be signaled.
430 The HTTP driver will queue a receive token to the underlying TCP instance. When data
431 is received in the underlying TCP instance, the data will be parsed and Token will
432 be populated with the response data. If the data received from the remote host
433 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting
434 (asynchronously) for more data to be sent from the remote host before signaling
437 It is the responsibility of the caller to allocate a buffer for Body and specify the
438 size in BodyLength. If the remote host provides a response that contains a content
439 body, up to BodyLength bytes will be copied from the receive buffer into Body and
440 BodyLength will be updated with the amount of bytes received and copied to Body. This
441 allows the client to download a large file in chunks instead of into one contiguous
442 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is
443 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive
444 token to underlying TCP instance. If data arrives in the receive buffer, up to
445 BodyLength bytes of data will be copied to Body. The HTTP driver will then update
446 BodyLength with the amount of bytes received and copied to Body.
448 If the HTTP driver does not have an open underlying TCP connection with the host
449 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is
450 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain
451 an open TCP connection between client and host.
453 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
454 @param[in] Token Pointer to storage containing HTTP response token.
456 @retval EFI_SUCCESS Allocation succeeded.
457 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been
459 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
462 Token->Message->Headers is NULL.
463 Token->Message is NULL.
464 Token->Message->Body is not NULL,
465 Token->Message->BodyLength is non-zero, and
466 Token->Message->Data is NULL, but a previous call to
467 Response() has not been completed successfully.
468 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
469 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host
470 specified by response URL.
474 (EFIAPI
*EFI_HTTP_RESPONSE
) (
475 IN EFI_HTTP_PROTOCOL
*This
,
476 IN EFI_HTTP_TOKEN
*Token
480 The Poll() function can be used by network drivers and applications to increase the
481 rate that data packets are moved between the communication devices and the transmit
484 In some systems, the periodic timer event in the managed network driver may not poll
485 the underlying communications device fast enough to transmit and/or receive all data
486 packets without missing incoming packets or dropping outgoing packets. Drivers and
487 applications that are experiencing packet loss should try calling the Poll() function
490 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
492 @retval EFI_SUCCESS Incoming or outgoing data was processed..
493 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred
494 @retval EFI_INVALID_PARAMETER This is NULL.
495 @retval EFI_NOT_READY No incoming or outgoing data is processed.
496 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
500 (EFIAPI
*EFI_HTTP_POLL
) (
501 IN EFI_HTTP_PROTOCOL
*This
505 /// The EFI HTTP protocol is designed to be used by EFI drivers and applications to
506 /// create and transmit HTTP Requests, as well as handle HTTP responses that are
507 /// returned by a remote host. This EFI protocol uses and relies on an underlying EFI
510 struct _EFI_HTTP_PROTOCOL
{
511 EFI_HTTP_GET_MODE_DATA GetModeData
;
512 EFI_HTTP_CONFIGURE Configure
;
513 EFI_HTTP_REQUEST Request
;
514 EFI_HTTP_CANCEL Cancel
;
515 EFI_HTTP_RESPONSE Response
;
519 extern EFI_GUID gEfiHttpServiceBindingProtocolGuid
;
520 extern EFI_GUID gEfiHttpProtocolGuid
;