1 /** @file 2 The header files of implementation of EFI_HTTP_PROTOCOL protocol interfaces. 3 4 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR> 5 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR> 6 7 This program and the accompanying materials 8 are licensed and made available under the terms and conditions of the BSD License 9 which accompanies this distribution. The full text of the license may be found at 10 http://opensource.org/licenses/bsd-license.php. 11 12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 14 15 **/ 16 17 #ifndef __EFI_HTTP_IMPL_H__ 18 #define __EFI_HTTP_IMPL_H__ 19 20 #define HTTP_DEFAULT_PORT 80 21 #define HTTP_END_OF_HDR_STR "\r\n\r\n" 22 #define HTTP_CRLF_STR "\r\n" 23 #define HTTP_VERSION_STR HTTP_VERSION 24 #define HTTP_VERSION_CRLF_STR " HTTP/1.1\r\n" 25 #define HTTP_ERROR_OR_NOT_SUPPORT_STATUS_CODE 300 26 27 28 /** 29 Returns the operational parameters for the current HTTP child instance. 30 31 The GetModeData() function is used to read the current mode data (operational 32 parameters) for this HTTP protocol instance. 33 34 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. 35 @param[out] HttpConfigData Point to buffer for operational parameters of this 36 HTTP instance. 37 38 @retval EFI_SUCCESS Operation succeeded. 39 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 40 This is NULL. 41 HttpConfigData is NULL. 42 HttpInstance->LocalAddressIsIPv6 is FALSE and 43 HttpConfigData->IPv4Node is NULL. 44 HttpInstance->LocalAddressIsIPv6 is TRUE and 45 HttpConfigData->IPv6Node is NULL. 46 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. 47 48 **/ 49 EFI_STATUS 50 EFIAPI 51 EfiHttpGetModeData ( 52 IN EFI_HTTP_PROTOCOL *This, 53 OUT EFI_HTTP_CONFIG_DATA *HttpConfigData 54 ); 55 56 /** 57 Initialize or brutally reset the operational parameters for this EFI HTTP instance. 58 59 The Configure() function does the following: 60 When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring 61 timeout, local address, port, etc. 62 When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active 63 connections with remote hosts, canceling all asynchronous tokens, and flush request 64 and response buffers without informing the appropriate hosts. 65 66 No other EFI HTTP function can be executed by this instance until the Configure() 67 function is executed and returns successfully. 68 69 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. 70 @param[in] HttpConfigData Pointer to the configure data to configure the instance. 71 72 @retval EFI_SUCCESS Operation succeeded. 73 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 74 This is NULL. 75 HttpConfigData->LocalAddressIsIPv6 is FALSE and 76 HttpConfigData->IPv4Node is NULL. 77 HttpConfigData->LocalAddressIsIPv6 is TRUE and 78 HttpConfigData->IPv6Node is NULL. 79 @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling 80 Configure() with NULL to reset it. 81 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 82 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when 83 executing Configure(). 84 @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported 85 in the implementation. 86 **/ 87 EFI_STATUS 88 EFIAPI 89 EfiHttpConfigure ( 90 IN EFI_HTTP_PROTOCOL *This, 91 IN EFI_HTTP_CONFIG_DATA *HttpConfigData 92 ); 93 94 /** 95 The Request() function queues an HTTP request to this HTTP instance. 96 97 Similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent 98 successfully, or if there is an error, Status in token will be updated and Event will 99 be signaled. 100 101 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. 102 @param[in] Token Pointer to storage containing HTTP request token. 103 104 @retval EFI_SUCCESS Outgoing data was processed. 105 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. 106 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 107 @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue. 108 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources. 109 @retval EFI_UNSUPPORTED The HTTP method is not supported in current 110 implementation. 111 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 112 This is NULL. 113 Token is NULL. 114 Token->Message is NULL. 115 Token->Message->Body is not NULL, 116 Token->Message->BodyLength is non-zero, and 117 Token->Message->Data is NULL, but a previous call to 118 Request()has not been completed successfully. 119 **/ 120 EFI_STATUS 121 EFIAPI 122 EfiHttpRequest ( 123 IN EFI_HTTP_PROTOCOL *This, 124 IN EFI_HTTP_TOKEN *Token 125 ); 126 127 /** 128 Abort an asynchronous HTTP request or response token. 129 130 The Cancel() function aborts a pending HTTP request or response transaction. If 131 Token is not NULL and the token is in transmit or receive queues when it is being 132 cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will 133 be signaled. If the token is not in one of the queues, which usually means that the 134 asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL, 135 all asynchronous tokens issued by Request() or Response() will be aborted. 136 137 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. 138 @param[in] Token Point to storage containing HTTP request or response 139 token. 140 141 @retval EFI_SUCCESS Request and Response queues are successfully flushed. 142 @retval EFI_INVALID_PARAMETER This is NULL. 143 @retval EFI_NOT_STARTED This instance hasn't been configured. 144 @retval EFI_NOT_FOUND The asynchronous request or response token is not 145 found. 146 @retval EFI_UNSUPPORTED The implementation does not support this function. 147 **/ 148 EFI_STATUS 149 EFIAPI 150 EfiHttpCancel ( 151 IN EFI_HTTP_PROTOCOL *This, 152 IN EFI_HTTP_TOKEN *Token 153 ); 154 155 /** 156 The Response() function queues an HTTP response to this HTTP instance, similar to 157 Receive() function in the EFI TCP driver. When the HTTP response is received successfully, 158 or if there is an error, Status in token will be updated and Event will be signaled. 159 160 The HTTP driver will queue a receive token to the underlying TCP instance. When data 161 is received in the underlying TCP instance, the data will be parsed and Token will 162 be populated with the response data. If the data received from the remote host 163 contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting 164 (asynchronously) for more data to be sent from the remote host before signaling 165 Event in Token. 166 167 It is the responsibility of the caller to allocate a buffer for Body and specify the 168 size in BodyLength. If the remote host provides a response that contains a content 169 body, up to BodyLength bytes will be copied from the receive buffer into Body and 170 BodyLength will be updated with the amount of bytes received and copied to Body. This 171 allows the client to download a large file in chunks instead of into one contiguous 172 block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is 173 non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive 174 token to underlying TCP instance. If data arrives in the receive buffer, up to 175 BodyLength bytes of data will be copied to Body. The HTTP driver will then update 176 BodyLength with the amount of bytes received and copied to Body. 177 178 If the HTTP driver does not have an open underlying TCP connection with the host 179 specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is 180 consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain 181 an open TCP connection between client and host. 182 183 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. 184 @param[in] Token Pointer to storage containing HTTP response token. 185 186 @retval EFI_SUCCESS Allocation succeeded. 187 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been 188 initialized. 189 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: 190 This is NULL. 191 Token is NULL. 192 Token->Message->Headers is NULL. 193 Token->Message is NULL. 194 Token->Message->Body is not NULL, 195 Token->Message->BodyLength is non-zero, and 196 Token->Message->Data is NULL, but a previous call to 197 Response() has not been completed successfully. 198 @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources. 199 @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host 200 specified by response URL. 201 **/ 202 EFI_STATUS 203 EFIAPI 204 EfiHttpResponse ( 205 IN EFI_HTTP_PROTOCOL *This, 206 IN EFI_HTTP_TOKEN *Token 207 ); 208 209 /** 210 The Poll() function can be used by network drivers and applications to increase the 211 rate that data packets are moved between the communication devices and the transmit 212 and receive queues. 213 214 In some systems, the periodic timer event in the managed network driver may not poll 215 the underlying communications device fast enough to transmit and/or receive all data 216 packets without missing incoming packets or dropping outgoing packets. Drivers and 217 applications that are experiencing packet loss should try calling the Poll() function 218 more often. 219 220 @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. 221 222 @retval EFI_SUCCESS Incoming or outgoing data was processed. 223 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. 224 @retval EFI_INVALID_PARAMETER This is NULL. 225 @retval EFI_NOT_READY No incoming or outgoing data is processed. 226 @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. 227 228 **/ 229 EFI_STATUS 230 EFIAPI 231 EfiHttpPoll ( 232 IN EFI_HTTP_PROTOCOL *This 233 ); 234 235 extern EFI_HTTP_PROTOCOL mEfiHttpTemplate; 236 237 #endif 238