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