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
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_CHIOCES
,
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 } EFI_HTTP_STATUS_CODE
;
110 /// EFI_HTTPv4_ACCESS_POINT
114 /// Set to TRUE to instruct the EFI HTTP instance to use the default address
115 /// information in every TCP connection made by this instance. In addition, when set
116 /// to TRUE, LocalAddress and LocalSubnet are ignored.
118 BOOLEAN UseDefaultAddress
;
120 /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be
121 /// used in every TCP connection opened by this instance.
123 EFI_IPv4_ADDRESS LocalAddress
;
125 /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used
126 /// in every TCP connection opened by this instance.
128 EFI_IPv4_ADDRESS LocalSubnet
;
130 /// This defines the local port to be used in
131 /// every TCP connection opened by this instance.
134 } EFI_HTTPv4_ACCESS_POINT
;
137 /// EFI_HTTPv6_ACCESS_POINT
141 /// Local IP address to be used in every TCP connection opened by this instance.
143 EFI_IPv6_ADDRESS LocalAddress
;
145 /// Local port to be used in every TCP connection opened by this instance.
148 } EFI_HTTPv6_ACCESS_POINT
;
151 /// EFI_HTTP_CONFIG_DATA_ACCESS_POINT
157 /// HTTP version that this instance will support.
159 EFI_HTTP_VERSION HttpVersion
;
161 /// Time out (in milliseconds) when blocking for requests.
163 UINT32 TimeOutMillisec
;
165 /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If
166 /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE,
167 /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL.
169 BOOLEAN LocalAddressIsIPv6
;
173 /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and
174 /// port used by the underlying TCP protocol.
176 EFI_HTTPv4_ACCESS_POINT
*IPv4Node
;
178 /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port
179 /// used by the underlying TCP protocol.
181 EFI_HTTPv6_ACCESS_POINT
*IPv6Node
;
183 } EFI_HTTP_CONFIG_DATA
;
186 /// EFI_HTTP_REQUEST_DATA
190 /// The HTTP method (e.g. GET, POST) for this HTTP Request.
192 EFI_HTTP_METHOD Method
;
194 /// The URI of a remote host. From the information in this field, the HTTP instance
195 /// will be able to determine whether to use HTTP or HTTPS and will also be able to
196 /// determine the port number to use. If no port number is specified, port 80 (HTTP)
197 /// is assumed. See RFC 3986 for more details on URI syntax.
200 } EFI_HTTP_REQUEST_DATA
;
203 /// EFI_HTTP_RESPONSE_DATA
207 /// Response status code returned by the remote host.
209 EFI_HTTP_STATUS_CODE StatusCode
;
210 } EFI_HTTP_RESPONSE_DATA
;
217 /// Null terminated string which describes a field name. See RFC 2616 Section 14 for
218 /// detailed information about field names.
222 /// Null terminated string which describes the corresponding field value. See RFC 2616
223 /// Section 14 for detailed information about field values.
233 /// HTTP message data.
237 /// When the token is used to send a HTTP request, Request is a pointer to storage that
238 /// contains such data as URL and HTTP method.
240 EFI_HTTP_REQUEST_DATA
*Request
;
242 /// When used to await a response, Response points to storage containing HTTP response
245 EFI_HTTP_RESPONSE_DATA
*Response
;
248 /// Number of HTTP header structures in Headers list. On request, this count is
249 /// provided by the caller. On response, this count is provided by the HTTP driver.
253 /// Array containing list of HTTP headers. On request, this array is populated by the
254 /// caller. On response, this array is allocated and populated by the HTTP driver. It
255 /// is the responsibility of the caller to free this memory on both request and
258 EFI_HTTP_HEADER
*Headers
;
260 /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type.
264 /// Body associated with the HTTP request or response. This can be NULL depending on
265 /// the HttpMethod type.
276 /// This Event will be signaled after the Status field is updated by the EFI HTTP
277 /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority
278 /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK.
282 /// Status will be set to one of the following value if the HTTP request is
283 /// successfully sent or if an unexpected error occurs:
284 /// EFI_SUCCESS: The HTTP request was successfully sent to the remote host.
285 /// EFI_HTTP_ERROR: The response message was successfully received but contains a
286 /// HTTP error. The response status code is returned in token.
287 /// EFI_ABORTED: The HTTP request was cancelled by the caller and removed from
288 /// the transmit queue.
289 /// EFI_TIMEOUT: The HTTP request timed out before reaching the remote host.
290 /// EFI_DEVICE_ERROR: An unexpected system or network error occurred.
294 /// Pointer to storage containing HTTP message data.
296 EFI_HTTP_MESSAGE
*Message
;
300 Returns the operational parameters for the current HTTP child instance.
302 The GetModeData() function is used to read the current mode data (operational
303 parameters) for this HTTP protocol instance.
305 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
306 @param[out] HttpConfigData Point to buffer for operational parameters of this
309 @retval EFI_SUCCESS Operation succeeded.
310 @retval EFI_INVALID_PARAMETER This is NULL.
311 HttpConfigData is NULL.
312 HttpInstance->LocalAddressIsIPv6 is FALSE and
313 HttpConfigData->IPv4Node is NULL.
314 HttpInstance->LocalAddressIsIPv6 is TRUE and
315 HttpConfigData->IPv6Node is NULL.
316 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
320 (EFIAPI
* EFI_HTTP_GET_MODE_DATA
)(
321 IN EFI_HTTP_PROTOCOL
*This
,
322 OUT EFI_HTTP_CONFIG_DATA
*HttpConfigData
326 Initialize or brutally reset the operational parameters for this EFI HTTP instance.
328 The Configure() function does the following:
329 When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring
330 timeout, local address, port, etc.
331 When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active
332 connections with remote hosts, canceling all asynchronous tokens, and flush request
333 and response buffers without informing the appropriate hosts.
335 No other EFI HTTP function can be executed by this instance until the Configure()
336 function is executed and returns successfully.
338 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
339 @param[in] HttpConfigData Pointer to the configure data to configure the instance.
341 @retval EFI_SUCCESS Operation succeeded.
342 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
344 HttpConfigData->LocalAddressIsIPv6 is FALSE and
345 HttpConfigData->IPv4Node is NULL.
346 HttpConfigData->LocalAddressIsIPv6 is TRUE and
347 HttpConfigData->IPv6Node is NULL.
348 @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling
349 Configure() with NULL to reset it.
350 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
351 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when
352 executing Configure().
353 @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported
354 in the implementation.
358 (EFIAPI
* EFI_HTTP_CONFIGURE
)(
359 IN EFI_HTTP_PROTOCOL
*This
,
360 IN EFI_HTTP_CONFIG_DATA
*HttpConfigData
364 The Request() function queues an HTTP request to this HTTP instance,
365 similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent
366 successfully, or if there is an error, Status in token will be updated and Event will
369 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
370 @param[in] Token Pointer to storage containing HTTP request token.
372 @retval EFI_SUCCESS Outgoing data was processed.
373 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
374 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
375 @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue.
376 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
379 Token->Message is NULL.
380 Token->Message->Body is not NULL,
381 Token->Message->BodyLength is non-zero, and
382 Token->Message->Data is NULL, but a previous call to
383 Request()has not been completed successfully.
384 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
385 @retval EFI_UNSUPPORTED The HTTP method is not supported in current implementation.
389 (EFIAPI
*EFI_HTTP_REQUEST
) (
390 IN EFI_HTTP_PROTOCOL
*This
,
391 IN EFI_HTTP_TOKEN
*Token
395 Abort an asynchronous HTTP request or response token.
397 The Cancel() function aborts a pending HTTP request or response transaction. If
398 Token is not NULL and the token is in transmit or receive queues when it is being
399 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will
400 be signaled. If the token is not in one of the queues, which usually means that the
401 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL,
402 all asynchronous tokens issued by Request() or Response() will be aborted.
404 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
405 @param[in] Token Point to storage containing HTTP request or response
408 @retval EFI_SUCCESS Request and Response queues are successfully flushed.
409 @retval EFI_INVALID_PARAMETER This is NULL.
410 @retval EFI_NOT_STARTED This instance hasn't been configured.
411 @retval EFI_NOT_FOUND The asynchronous request or response token is not
413 @retval EFI_UNSUPPORTED The implementation does not support this function.
417 (EFIAPI
*EFI_HTTP_CANCEL
)(
418 IN EFI_HTTP_PROTOCOL
*This
,
419 IN EFI_HTTP_TOKEN
*Token
423 The Response() function queues an HTTP response to this HTTP instance, similar to
424 Receive() function in the EFI TCP driver. When the HTTP Response is received successfully,
425 or if there is an error, Status in token will be updated and Event will be signaled.
427 The HTTP driver will queue a receive token to the underlying TCP instance. When data
428 is received in the underlying TCP instance, the data will be parsed and Token will
429 be populated with the response data. If the data received from the remote host
430 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting
431 (asynchronously) for more data to be sent from the remote host before signaling
434 It is the responsibility of the caller to allocate a buffer for Body and specify the
435 size in BodyLength. If the remote host provides a response that contains a content
436 body, up to BodyLength bytes will be copied from the receive buffer into Body and
437 BodyLength will be updated with the amount of bytes received and copied to Body. This
438 allows the client to download a large file in chunks instead of into one contiguous
439 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is
440 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive
441 token to underlying TCP instance. If data arrives in the receive buffer, up to
442 BodyLength bytes of data will be copied to Body. The HTTP driver will then update
443 BodyLength with the amount of bytes received and copied to Body.
445 If the HTTP driver does not have an open underlying TCP connection with the host
446 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is
447 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain
448 an open TCP connection between client and host.
450 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
451 @param[in] Token Pointer to storage containing HTTP response token.
453 @retval EFI_SUCCESS Allocation succeeded.
454 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been
456 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
459 Token->Message->Headers is NULL.
460 Token->Message is NULL.
461 Token->Message->Body is not NULL,
462 Token->Message->BodyLength is non-zero, and
463 Token->Message->Data is NULL, but a previous call to
464 Response() has not been completed successfully.
465 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources.
466 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host
467 specified by response URL.
471 (EFIAPI
*EFI_HTTP_RESPONSE
) (
472 IN EFI_HTTP_PROTOCOL
*This
,
473 IN EFI_HTTP_TOKEN
*Token
477 The Poll() function can be used by network drivers and applications to increase the
478 rate that data packets are moved between the communication devices and the transmit
481 In some systems, the periodic timer event in the managed network driver may not poll
482 the underlying communications device fast enough to transmit and/or receive all data
483 packets without missing incoming packets or dropping outgoing packets. Drivers and
484 applications that are experiencing packet loss should try calling the Poll() function
487 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance.
489 @retval EFI_SUCCESS Incoming or outgoing data was processed..
490 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred
491 @retval EFI_INVALID_PARAMETER This is NULL.
492 @retval EFI_NOT_READY No incoming or outgoing data is processed.
493 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started.
497 (EFIAPI
*EFI_HTTP_POLL
) (
498 IN EFI_HTTP_PROTOCOL
*This
502 /// The EFI HTTP protocol is designed to be used by EFI drivers and applications to
503 /// create and transmit HTTP Requests, as well as handle HTTP responses that are
504 /// returned by a remote host. This EFI protocol uses and relies on an underlying EFI
507 struct _EFI_HTTP_PROTOCOL
{
508 EFI_HTTP_GET_MODE_DATA GetModeData
;
509 EFI_HTTP_CONFIGURE Configure
;
510 EFI_HTTP_REQUEST Request
;
511 EFI_HTTP_CANCEL Cancel
;
512 EFI_HTTP_RESPONSE Response
;
516 extern EFI_GUID gEfiHttpServiceBindingProtocolGuid
;
517 extern EFI_GUID gEfiHttpProtocolGuid
;