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