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