1 /**
2 Low-level hyper-text transfer protocol client.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.httpclient;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.reference;
25 import godot.streampeer;
26 /**
27 Low-level hyper-text transfer protocol client.
28 
29 Hyper-text transfer protocol client (sometimes called "User Agent"). Used to make HTTP requests to download web content, upload files and other data or to communicate with various services, among other use cases. $(B See the $(D HTTPRequest) node for a higher-level alternative.)
30 $(B Note:) This client only needs to connect to a host once (see $(D connectToHost)) to send multiple requests. Because of this, methods that take URLs usually take just the part after the host instead of the full URL, as the client is already connected to a host. See $(D request) for a full example and to get started.
31 A $(D HTTPClient) should be reused between multiple requests or to connect to different hosts instead of creating one client per request. Supports SSL and SSL server certificate verification. HTTP status codes in the 2xx range indicate success, 3xx redirection (i.e. "try again, but over here"), 4xx something was wrong with the request, and 5xx something went wrong on the server's side.
32 For more information on HTTP, see https://developer.mozilla.org/en-US/docs/Web/HTTP (or read RFC 2616 to get it straight from the source: https://tools.ietf.org/html/rfc2616).
33 $(B Note:) When performing HTTP requests from a project exported to HTML5, keep in mind the remote server may not allow requests from foreign origins due to $(D url=https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)CORS$(D /url). If you host the server in question, you should modify its backend to allow requests from foreign origins by adding the `Access-Control-Allow-Origin: *` HTTP header.
34 $(B Note:) SSL/TLS support is currently limited to TLS 1.0, TLS 1.1, and TLS 1.2. Attempting to connect to a TLS 1.3-only server will return an error.
35 $(B Warning:) SSL/TLS certificate revocation and certificate pinning are currently not supported. Revoked certificates are accepted as long as they are otherwise valid. If this is a concern, you may want to use automatically managed certificates with a short validity period.
36 */
37 @GodotBaseClass struct HTTPClient
38 {
39 	package(godot) enum string _GODOT_internal_name = "HTTPClient";
40 public:
41 @nogc nothrow:
42 	union { /** */ godot_object _godot_object; /** */ Reference _GODOT_base; }
43 	alias _GODOT_base this;
44 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
45 	package(godot) __gshared bool _classBindingInitialized = false;
46 	package(godot) static struct GDNativeClassBinding
47 	{
48 		__gshared:
49 		@GodotName("close") GodotMethod!(void) close;
50 		@GodotName("connect_to_host") GodotMethod!(GodotError, String, long, bool, bool) connectToHost;
51 		@GodotName("get_connection") GodotMethod!(StreamPeer) getConnection;
52 		@GodotName("get_read_chunk_size") GodotMethod!(long) getReadChunkSize;
53 		@GodotName("get_response_body_length") GodotMethod!(long) getResponseBodyLength;
54 		@GodotName("get_response_code") GodotMethod!(long) getResponseCode;
55 		@GodotName("get_response_headers") GodotMethod!(PoolStringArray) getResponseHeaders;
56 		@GodotName("get_response_headers_as_dictionary") GodotMethod!(Dictionary) getResponseHeadersAsDictionary;
57 		@GodotName("get_status") GodotMethod!(HTTPClient.Status) getStatus;
58 		@GodotName("has_response") GodotMethod!(bool) hasResponse;
59 		@GodotName("is_blocking_mode_enabled") GodotMethod!(bool) isBlockingModeEnabled;
60 		@GodotName("is_response_chunked") GodotMethod!(bool) isResponseChunked;
61 		@GodotName("poll") GodotMethod!(GodotError) poll;
62 		@GodotName("query_string_from_dict") GodotMethod!(String, Dictionary) queryStringFromDict;
63 		@GodotName("read_response_body_chunk") GodotMethod!(PoolByteArray) readResponseBodyChunk;
64 		@GodotName("request") GodotMethod!(GodotError, long, String, PoolStringArray, String) request;
65 		@GodotName("request_raw") GodotMethod!(GodotError, long, String, PoolStringArray, PoolByteArray) requestRaw;
66 		@GodotName("set_blocking_mode") GodotMethod!(void, bool) setBlockingMode;
67 		@GodotName("set_connection") GodotMethod!(void, StreamPeer) setConnection;
68 		@GodotName("set_read_chunk_size") GodotMethod!(void, long) setReadChunkSize;
69 	}
70 	/// 
71 	pragma(inline, true) bool opEquals(in HTTPClient other) const
72 	{ return _godot_object.ptr is other._godot_object.ptr; }
73 	/// 
74 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
75 	{ _godot_object.ptr = n; return null; }
76 	/// 
77 	pragma(inline, true) bool opEquals(typeof(null) n) const
78 	{ return _godot_object.ptr is n; }
79 	/// 
80 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
81 	mixin baseCasts;
82 	/// Construct a new instance of HTTPClient.
83 	/// Note: use `memnew!HTTPClient` instead.
84 	static HTTPClient _new()
85 	{
86 		static godot_class_constructor constructor;
87 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("HTTPClient");
88 		if(constructor is null) return typeof(this).init;
89 		return cast(HTTPClient)(constructor());
90 	}
91 	@disable new(size_t s);
92 	/// 
93 	enum Status : int
94 	{
95 		/**
96 		Status: Disconnected from the server.
97 		*/
98 		statusDisconnected = 0,
99 		/**
100 		Status: Currently resolving the hostname for the given URL into an IP.
101 		*/
102 		statusResolving = 1,
103 		/**
104 		Status: DNS failure: Can't resolve the hostname for the given URL.
105 		*/
106 		statusCantResolve = 2,
107 		/**
108 		Status: Currently connecting to server.
109 		*/
110 		statusConnecting = 3,
111 		/**
112 		Status: Can't connect to the server.
113 		*/
114 		statusCantConnect = 4,
115 		/**
116 		Status: Connection established.
117 		*/
118 		statusConnected = 5,
119 		/**
120 		Status: Currently sending request.
121 		*/
122 		statusRequesting = 6,
123 		/**
124 		Status: HTTP body received.
125 		*/
126 		statusBody = 7,
127 		/**
128 		Status: Error in HTTP connection.
129 		*/
130 		statusConnectionError = 8,
131 		/**
132 		Status: Error in SSL handshake.
133 		*/
134 		statusSslHandshakeError = 9,
135 	}
136 	/// 
137 	enum Method : int
138 	{
139 		/**
140 		HTTP GET method. The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
141 		*/
142 		methodGet = 0,
143 		/**
144 		HTTP HEAD method. The HEAD method asks for a response identical to that of a GET request, but without the response body. This is useful to request metadata like HTTP headers or to check if a resource exists.
145 		*/
146 		methodHead = 1,
147 		/**
148 		HTTP POST method. The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server. This is often used for forms and submitting data or uploading files.
149 		*/
150 		methodPost = 2,
151 		/**
152 		HTTP PUT method. The PUT method asks to replace all current representations of the target resource with the request payload. (You can think of POST as "create or update" and PUT as "update", although many services tend to not make a clear distinction or change their meaning).
153 		*/
154 		methodPut = 3,
155 		/**
156 		HTTP DELETE method. The DELETE method requests to delete the specified resource.
157 		*/
158 		methodDelete = 4,
159 		/**
160 		HTTP OPTIONS method. The OPTIONS method asks for a description of the communication options for the target resource. Rarely used.
161 		*/
162 		methodOptions = 5,
163 		/**
164 		HTTP TRACE method. The TRACE method performs a message loop-back test along the path to the target resource. Returns the entire HTTP request received in the response body. Rarely used.
165 		*/
166 		methodTrace = 6,
167 		/**
168 		HTTP CONNECT method. The CONNECT method establishes a tunnel to the server identified by the target resource. Rarely used.
169 		*/
170 		methodConnect = 7,
171 		/**
172 		HTTP PATCH method. The PATCH method is used to apply partial modifications to a resource.
173 		*/
174 		methodPatch = 8,
175 		/**
176 		Represents the size of the $(D method) enum.
177 		*/
178 		methodMax = 9,
179 	}
180 	/// 
181 	enum ResponseCode : int
182 	{
183 		/**
184 		HTTP status code `100 Continue`. Interim response that indicates everything so far is OK and that the client should continue with the request (or ignore this status if already finished).
185 		*/
186 		responseContinue = 100,
187 		/**
188 		HTTP status code `101 Switching Protocol`. Sent in response to an `Upgrade` request header by the client. Indicates the protocol the server is switching to.
189 		*/
190 		responseSwitchingProtocols = 101,
191 		/**
192 		HTTP status code `102 Processing` (WebDAV). Indicates that the server has received and is processing the request, but no response is available yet.
193 		*/
194 		responseProcessing = 102,
195 		/**
196 		HTTP status code `200 OK`. The request has succeeded. Default response for successful requests. Meaning varies depending on the request. GET: The resource has been fetched and is transmitted in the message body. HEAD: The entity headers are in the message body. POST: The resource describing the result of the action is transmitted in the message body. TRACE: The message body contains the request message as received by the server.
197 		*/
198 		responseOk = 200,
199 		/**
200 		HTTP status code `201 Created`. The request has succeeded and a new resource has been created as a result of it. This is typically the response sent after a PUT request.
201 		*/
202 		responseCreated = 201,
203 		/**
204 		HTTP status code `202 Accepted`. The request has been received but not yet acted upon. It is non-committal, meaning that there is no way in HTTP to later send an asynchronous response indicating the outcome of processing the request. It is intended for cases where another process or server handles the request, or for batch processing.
205 		*/
206 		responseAccepted = 202,
207 		/**
208 		HTTP status code `203 Non-Authoritative Information`. This response code means returned meta-information set is not exact set as available from the origin server, but collected from a local or a third party copy. Except this condition, 200 OK response should be preferred instead of this response.
209 		*/
210 		responseNonAuthoritativeInformation = 203,
211 		/**
212 		HTTP status code `204 No Content`. There is no content to send for this request, but the headers may be useful. The user-agent may update its cached headers for this resource with the new ones.
213 		*/
214 		responseNoContent = 204,
215 		/**
216 		HTTP status code `205 Reset Content`. The server has fulfilled the request and desires that the client resets the "document view" that caused the request to be sent to its original state as received from the origin server.
217 		*/
218 		responseResetContent = 205,
219 		/**
220 		HTTP status code `206 Partial Content`. This response code is used because of a range header sent by the client to separate download into multiple streams.
221 		*/
222 		responsePartialContent = 206,
223 		/**
224 		HTTP status code `207 Multi-Status` (WebDAV). A Multi-Status response conveys information about multiple resources in situations where multiple status codes might be appropriate.
225 		*/
226 		responseMultiStatus = 207,
227 		/**
228 		HTTP status code `208 Already Reported` (WebDAV). Used inside a DAV: propstat response element to avoid enumerating the internal members of multiple bindings to the same collection repeatedly.
229 		*/
230 		responseAlreadyReported = 208,
231 		/**
232 		HTTP status code `226 IM Used` (WebDAV). The server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
233 		*/
234 		responseImUsed = 226,
235 		/**
236 		HTTP status code `300 Multiple Choice`. The request has more than one possible responses and there is no standardized way to choose one of the responses. User-agent or user should choose one of them.
237 		*/
238 		responseMultipleChoices = 300,
239 		/**
240 		HTTP status code `301 Moved Permanently`. Redirection. This response code means the URI of requested resource has been changed. The new URI is usually included in the response.
241 		*/
242 		responseMovedPermanently = 301,
243 		/**
244 		HTTP status code `302 Found`. Temporary redirection. This response code means the URI of requested resource has been changed temporarily. New changes in the URI might be made in the future. Therefore, this same URI should be used by the client in future requests.
245 		*/
246 		responseFound = 302,
247 		/**
248 		HTTP status code `303 See Other`. The server is redirecting the user agent to a different resource, as indicated by a URI in the Location header field, which is intended to provide an indirect response to the original request.
249 		*/
250 		responseSeeOther = 303,
251 		/**
252 		HTTP status code `304 Not Modified`. A conditional GET or HEAD request has been received and would have resulted in a 200 OK response if it were not for the fact that the condition evaluated to `false`.
253 		*/
254 		responseNotModified = 304,
255 		/**
256 		HTTP status code `305 Use Proxy`. $(I Deprecated. Do not use.)
257 		*/
258 		responseUseProxy = 305,
259 		/**
260 		HTTP status code `306 Switch Proxy`. $(I Deprecated. Do not use.)
261 		*/
262 		responseSwitchProxy = 306,
263 		/**
264 		HTTP status code `307 Temporary Redirect`. The target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI.
265 		*/
266 		responseTemporaryRedirect = 307,
267 		/**
268 		HTTP status code `308 Permanent Redirect`. The target resource has been assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs.
269 		*/
270 		responsePermanentRedirect = 308,
271 		/**
272 		HTTP status code `400 Bad Request`. The request was invalid. The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, invalid request contents, or deceptive request routing).
273 		*/
274 		responseBadRequest = 400,
275 		/**
276 		HTTP status code `401 Unauthorized`. Credentials required. The request has not been applied because it lacks valid authentication credentials for the target resource.
277 		*/
278 		responseUnauthorized = 401,
279 		/**
280 		HTTP status code `402 Payment Required`. This response code is reserved for future use. Initial aim for creating this code was using it for digital payment systems, however this is not currently used.
281 		*/
282 		responsePaymentRequired = 402,
283 		/**
284 		HTTP status code `403 Forbidden`. The client does not have access rights to the content, i.e. they are unauthorized, so server is rejecting to give proper response. Unlike `401`, the client's identity is known to the server.
285 		*/
286 		responseForbidden = 403,
287 		/**
288 		HTTP status code `404 Not Found`. The server can not find requested resource. Either the URL is not recognized or the endpoint is valid but the resource itself does not exist. May also be sent instead of 403 to hide existence of a resource if the client is not authorized.
289 		*/
290 		responseNotFound = 404,
291 		/**
292 		HTTP status code `405 Method Not Allowed`. The request's HTTP method is known by the server but has been disabled and cannot be used. For example, an API may forbid DELETE-ing a resource. The two mandatory methods, GET and HEAD, must never be disabled and should not return this error code.
293 		*/
294 		responseMethodNotAllowed = 405,
295 		/**
296 		HTTP status code `406 Not Acceptable`. The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request. Used when negotiation content.
297 		*/
298 		responseNotAcceptable = 406,
299 		/**
300 		HTTP status code `407 Proxy Authentication Required`. Similar to 401 Unauthorized, but it indicates that the client needs to authenticate itself in order to use a proxy.
301 		*/
302 		responseProxyAuthenticationRequired = 407,
303 		/**
304 		HTTP status code `408 Request Timeout`. The server did not receive a complete request message within the time that it was prepared to wait.
305 		*/
306 		responseRequestTimeout = 408,
307 		/**
308 		HTTP status code `409 Conflict`. The request could not be completed due to a conflict with the current state of the target resource. This code is used in situations where the user might be able to resolve the conflict and resubmit the request.
309 		*/
310 		responseConflict = 409,
311 		/**
312 		HTTP status code `410 Gone`. The target resource is no longer available at the origin server and this condition is likely permanent.
313 		*/
314 		responseGone = 410,
315 		/**
316 		HTTP status code `411 Length Required`. The server refuses to accept the request without a defined Content-Length header.
317 		*/
318 		responseLengthRequired = 411,
319 		/**
320 		HTTP status code `412 Precondition Failed`. One or more conditions given in the request header fields evaluated to `false` when tested on the server.
321 		*/
322 		responsePreconditionFailed = 412,
323 		/**
324 		HTTP status code `413 Entity Too Large`. The server is refusing to process a request because the request payload is larger than the server is willing or able to process.
325 		*/
326 		responseRequestEntityTooLarge = 413,
327 		/**
328 		HTTP status code `414 Request-URI Too Long`. The server is refusing to service the request because the request-target is longer than the server is willing to interpret.
329 		*/
330 		responseRequestUriTooLong = 414,
331 		/**
332 		HTTP status code `415 Unsupported Media Type`. The origin server is refusing to service the request because the payload is in a format not supported by this method on the target resource.
333 		*/
334 		responseUnsupportedMediaType = 415,
335 		/**
336 		HTTP status code `416 Requested Range Not Satisfiable`. None of the ranges in the request's Range header field overlap the current extent of the selected resource or the set of ranges requested has been rejected due to invalid ranges or an excessive request of small or overlapping ranges.
337 		*/
338 		responseRequestedRangeNotSatisfiable = 416,
339 		/**
340 		HTTP status code `417 Expectation Failed`. The expectation given in the request's Expect header field could not be met by at least one of the inbound servers.
341 		*/
342 		responseExpectationFailed = 417,
343 		/**
344 		HTTP status code `418 I'm A Teapot`. Any attempt to brew coffee with a teapot should result in the error code "418 I'm a teapot". The resulting entity body MAY be short and stout.
345 		*/
346 		responseImATeapot = 418,
347 		/**
348 		HTTP status code `421 Misdirected Request`. The request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI.
349 		*/
350 		responseMisdirectedRequest = 421,
351 		/**
352 		HTTP status code `422 Unprocessable Entity` (WebDAV). The server understands the content type of the request entity (hence a 415 Unsupported Media Type status code is inappropriate), and the syntax of the request entity is correct (thus a 400 Bad Request status code is inappropriate) but was unable to process the contained instructions.
353 		*/
354 		responseUnprocessableEntity = 422,
355 		/**
356 		HTTP status code `423 Locked` (WebDAV). The source or destination resource of a method is locked.
357 		*/
358 		responseLocked = 423,
359 		/**
360 		HTTP status code `424 Failed Dependency` (WebDAV). The method could not be performed on the resource because the requested action depended on another action and that action failed.
361 		*/
362 		responseFailedDependency = 424,
363 		/**
364 		HTTP status code `426 Upgrade Required`. The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.
365 		*/
366 		responseUpgradeRequired = 426,
367 		/**
368 		HTTP status code `428 Precondition Required`. The origin server requires the request to be conditional.
369 		*/
370 		responsePreconditionRequired = 428,
371 		/**
372 		HTTP status code `429 Too Many Requests`. The user has sent too many requests in a given amount of time (see "rate limiting"). Back off and increase time between requests or try again later.
373 		*/
374 		responseTooManyRequests = 429,
375 		/**
376 		HTTP status code `431 Request Header Fields Too Large`. The server is unwilling to process the request because its header fields are too large. The request MAY be resubmitted after reducing the size of the request header fields.
377 		*/
378 		responseRequestHeaderFieldsTooLarge = 431,
379 		/**
380 		HTTP status code `451 Response Unavailable For Legal Reasons`. The server is denying access to the resource as a consequence of a legal demand.
381 		*/
382 		responseUnavailableForLegalReasons = 451,
383 		/**
384 		HTTP status code `500 Internal Server Error`. The server encountered an unexpected condition that prevented it from fulfilling the request.
385 		*/
386 		responseInternalServerError = 500,
387 		/**
388 		HTTP status code `501 Not Implemented`. The server does not support the functionality required to fulfill the request.
389 		*/
390 		responseNotImplemented = 501,
391 		/**
392 		HTTP status code `502 Bad Gateway`. The server, while acting as a gateway or proxy, received an invalid response from an inbound server it accessed while attempting to fulfill the request. Usually returned by load balancers or proxies.
393 		*/
394 		responseBadGateway = 502,
395 		/**
396 		HTTP status code `503 Service Unavailable`. The server is currently unable to handle the request due to a temporary overload or scheduled maintenance, which will likely be alleviated after some delay. Try again later.
397 		*/
398 		responseServiceUnavailable = 503,
399 		/**
400 		HTTP status code `504 Gateway Timeout`. The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request. Usually returned by load balancers or proxies.
401 		*/
402 		responseGatewayTimeout = 504,
403 		/**
404 		HTTP status code `505 HTTP Version Not Supported`. The server does not support, or refuses to support, the major version of HTTP that was used in the request message.
405 		*/
406 		responseHttpVersionNotSupported = 505,
407 		/**
408 		HTTP status code `506 Variant Also Negotiates`. The server has an internal configuration error: the chosen variant resource is configured to engage in transparent content negotiation itself, and is therefore not a proper end point in the negotiation process.
409 		*/
410 		responseVariantAlsoNegotiates = 506,
411 		/**
412 		HTTP status code `507 Insufficient Storage`. The method could not be performed on the resource because the server is unable to store the representation needed to successfully complete the request.
413 		*/
414 		responseInsufficientStorage = 507,
415 		/**
416 		HTTP status code `508 Loop Detected`. The server terminated an operation because it encountered an infinite loop while processing a request with "Depth: infinity". This status indicates that the entire operation failed.
417 		*/
418 		responseLoopDetected = 508,
419 		/**
420 		HTTP status code `510 Not Extended`. The policy for accessing the resource has not been met in the request. The server should send back all the information necessary for the client to issue an extended request.
421 		*/
422 		responseNotExtended = 510,
423 		/**
424 		HTTP status code `511 Network Authentication Required`. The client needs to authenticate to gain network access.
425 		*/
426 		responseNetworkAuthRequired = 511,
427 	}
428 	/// 
429 	enum Constants : int
430 	{
431 		methodGet = 0,
432 		statusDisconnected = 0,
433 		methodHead = 1,
434 		statusResolving = 1,
435 		methodPost = 2,
436 		statusCantResolve = 2,
437 		methodPut = 3,
438 		statusConnecting = 3,
439 		statusCantConnect = 4,
440 		methodDelete = 4,
441 		statusConnected = 5,
442 		methodOptions = 5,
443 		statusRequesting = 6,
444 		methodTrace = 6,
445 		methodConnect = 7,
446 		statusBody = 7,
447 		methodPatch = 8,
448 		statusConnectionError = 8,
449 		methodMax = 9,
450 		statusSslHandshakeError = 9,
451 		responseContinue = 100,
452 		responseSwitchingProtocols = 101,
453 		responseProcessing = 102,
454 		responseOk = 200,
455 		responseCreated = 201,
456 		responseAccepted = 202,
457 		responseNonAuthoritativeInformation = 203,
458 		responseNoContent = 204,
459 		responseResetContent = 205,
460 		responsePartialContent = 206,
461 		responseMultiStatus = 207,
462 		responseAlreadyReported = 208,
463 		responseImUsed = 226,
464 		responseMultipleChoices = 300,
465 		responseMovedPermanently = 301,
466 		responseFound = 302,
467 		responseSeeOther = 303,
468 		responseNotModified = 304,
469 		responseUseProxy = 305,
470 		responseSwitchProxy = 306,
471 		responseTemporaryRedirect = 307,
472 		responsePermanentRedirect = 308,
473 		responseBadRequest = 400,
474 		responseUnauthorized = 401,
475 		responsePaymentRequired = 402,
476 		responseForbidden = 403,
477 		responseNotFound = 404,
478 		responseMethodNotAllowed = 405,
479 		responseNotAcceptable = 406,
480 		responseProxyAuthenticationRequired = 407,
481 		responseRequestTimeout = 408,
482 		responseConflict = 409,
483 		responseGone = 410,
484 		responseLengthRequired = 411,
485 		responsePreconditionFailed = 412,
486 		responseRequestEntityTooLarge = 413,
487 		responseRequestUriTooLong = 414,
488 		responseUnsupportedMediaType = 415,
489 		responseRequestedRangeNotSatisfiable = 416,
490 		responseExpectationFailed = 417,
491 		responseImATeapot = 418,
492 		responseMisdirectedRequest = 421,
493 		responseUnprocessableEntity = 422,
494 		responseLocked = 423,
495 		responseFailedDependency = 424,
496 		responseUpgradeRequired = 426,
497 		responsePreconditionRequired = 428,
498 		responseTooManyRequests = 429,
499 		responseRequestHeaderFieldsTooLarge = 431,
500 		responseUnavailableForLegalReasons = 451,
501 		responseInternalServerError = 500,
502 		responseNotImplemented = 501,
503 		responseBadGateway = 502,
504 		responseServiceUnavailable = 503,
505 		responseGatewayTimeout = 504,
506 		responseHttpVersionNotSupported = 505,
507 		responseVariantAlsoNegotiates = 506,
508 		responseInsufficientStorage = 507,
509 		responseLoopDetected = 508,
510 		responseNotExtended = 510,
511 		responseNetworkAuthRequired = 511,
512 	}
513 	/**
514 	Closes the current connection, allowing reuse of this $(D HTTPClient).
515 	*/
516 	void close()
517 	{
518 		checkClassBinding!(typeof(this))();
519 		ptrcall!(void)(GDNativeClassBinding.close, _godot_object);
520 	}
521 	/**
522 	Connects to a host. This needs to be done before any requests are sent.
523 	The host should not have http:// prepended but will strip the protocol identifier if provided.
524 	If no `port` is specified (or `-1` is used), it is automatically set to 80 for HTTP and 443 for HTTPS (if `use_ssl` is enabled).
525 	`verify_host` will check the SSL identity of the host if set to `true`.
526 	*/
527 	GodotError connectToHost(in String host, in long port = -1, in bool use_ssl = false, in bool verify_host = true)
528 	{
529 		checkClassBinding!(typeof(this))();
530 		return ptrcall!(GodotError)(GDNativeClassBinding.connectToHost, _godot_object, host, port, use_ssl, verify_host);
531 	}
532 	/**
533 	
534 	*/
535 	Ref!StreamPeer getConnection() const
536 	{
537 		checkClassBinding!(typeof(this))();
538 		return ptrcall!(StreamPeer)(GDNativeClassBinding.getConnection, _godot_object);
539 	}
540 	/**
541 	
542 	*/
543 	long getReadChunkSize() const
544 	{
545 		checkClassBinding!(typeof(this))();
546 		return ptrcall!(long)(GDNativeClassBinding.getReadChunkSize, _godot_object);
547 	}
548 	/**
549 	Returns the response's body length.
550 	$(B Note:) Some Web servers may not send a body length. In this case, the value returned will be `-1`. If using chunked transfer encoding, the body length will also be `-1`.
551 	*/
552 	long getResponseBodyLength() const
553 	{
554 		checkClassBinding!(typeof(this))();
555 		return ptrcall!(long)(GDNativeClassBinding.getResponseBodyLength, _godot_object);
556 	}
557 	/**
558 	Returns the response's HTTP status code.
559 	*/
560 	long getResponseCode() const
561 	{
562 		checkClassBinding!(typeof(this))();
563 		return ptrcall!(long)(GDNativeClassBinding.getResponseCode, _godot_object);
564 	}
565 	/**
566 	Returns the response headers.
567 	*/
568 	PoolStringArray getResponseHeaders()
569 	{
570 		checkClassBinding!(typeof(this))();
571 		return ptrcall!(PoolStringArray)(GDNativeClassBinding.getResponseHeaders, _godot_object);
572 	}
573 	/**
574 	Returns all response headers as a Dictionary of structure `{ "key": "value1; value2" }` where the case-sensitivity of the keys and values is kept like the server delivers it. A value is a simple String, this string can have more than one value where "; " is used as separator.
575 	$(B Example:)
576 	
577 	
578 	{
579 	    "content-length": 12,
580 	    "Content-Type": "application/json; charset=UTF-8",
581 	}
582 	
583 	
584 	*/
585 	Dictionary getResponseHeadersAsDictionary()
586 	{
587 		checkClassBinding!(typeof(this))();
588 		return ptrcall!(Dictionary)(GDNativeClassBinding.getResponseHeadersAsDictionary, _godot_object);
589 	}
590 	/**
591 	Returns a $(D status) constant. Need to call $(D poll) in order to get status updates.
592 	*/
593 	HTTPClient.Status getStatus() const
594 	{
595 		checkClassBinding!(typeof(this))();
596 		return ptrcall!(HTTPClient.Status)(GDNativeClassBinding.getStatus, _godot_object);
597 	}
598 	/**
599 	If `true`, this $(D HTTPClient) has a response available.
600 	*/
601 	bool hasResponse() const
602 	{
603 		checkClassBinding!(typeof(this))();
604 		return ptrcall!(bool)(GDNativeClassBinding.hasResponse, _godot_object);
605 	}
606 	/**
607 	
608 	*/
609 	bool isBlockingModeEnabled() const
610 	{
611 		checkClassBinding!(typeof(this))();
612 		return ptrcall!(bool)(GDNativeClassBinding.isBlockingModeEnabled, _godot_object);
613 	}
614 	/**
615 	If `true`, this $(D HTTPClient) has a response that is chunked.
616 	*/
617 	bool isResponseChunked() const
618 	{
619 		checkClassBinding!(typeof(this))();
620 		return ptrcall!(bool)(GDNativeClassBinding.isResponseChunked, _godot_object);
621 	}
622 	/**
623 	This needs to be called in order to have any request processed. Check results with $(D getStatus).
624 	*/
625 	GodotError poll()
626 	{
627 		checkClassBinding!(typeof(this))();
628 		return ptrcall!(GodotError)(GDNativeClassBinding.poll, _godot_object);
629 	}
630 	/**
631 	Generates a GET/POST application/x-www-form-urlencoded style query string from a provided dictionary, e.g.:
632 	
633 	
634 	var fields = {"username": "user", "password": "pass"}
635 	var query_string = http_client.query_string_from_dict(fields)
636 	# Returns "username=user&password=pass"
637 	
638 	
639 	Furthermore, if a key has a `null` value, only the key itself is added, without equal sign and value. If the value is an array, for each value in it a pair with the same key is added.
640 	
641 	
642 	var fields = {"single": 123, "not_valued": null, "multiple": $(D 22, 33, 44)}
643 	var query_string = http_client.query_string_from_dict(fields)
644 	# Returns "single=123&not_valued&multiple=22&multiple=33&multiple=44"
645 	
646 	
647 	*/
648 	String queryStringFromDict(in Dictionary fields)
649 	{
650 		checkClassBinding!(typeof(this))();
651 		return ptrcall!(String)(GDNativeClassBinding.queryStringFromDict, _godot_object, fields);
652 	}
653 	/**
654 	Reads one chunk from the response.
655 	*/
656 	PoolByteArray readResponseBodyChunk()
657 	{
658 		checkClassBinding!(typeof(this))();
659 		return ptrcall!(PoolByteArray)(GDNativeClassBinding.readResponseBodyChunk, _godot_object);
660 	}
661 	/**
662 	Sends a request to the connected host.
663 	The URL parameter is usually just the part after the host, so for `http://somehost.com/index.php`, it is `/index.php`. When sending requests to an HTTP proxy server, it should be an absolute URL. For $(D constant HTTPClient.METHOD_OPTIONS) requests, `*` is also allowed. For $(D constant HTTPClient.METHOD_CONNECT) requests, it should be the authority component (`host:port`).
664 	Headers are HTTP request headers. For available HTTP methods, see $(D method).
665 	To create a POST request with query strings to push to the server, do:
666 	
667 	
668 	var fields = {"username" : "user", "password" : "pass"}
669 	var query_string = http_client.query_string_from_dict(fields)
670 	var headers = $(D "Content-Type: application/x-www-form-urlencoded", "Content-Length: " + str(query_string.length()))
671 	var result = http_client.request(http_client.METHOD_POST, "/index.php", headers, query_string)
672 	
673 	
674 	$(B Note:) The `request_data` parameter is ignored if `method` is $(D constant HTTPClient.METHOD_GET). This is because GET methods can't contain request data. As a workaround, you can pass request data as a query string in the URL. See $(D String.httpEscape) for an example.
675 	*/
676 	GodotError request(in long method, in String url, in PoolStringArray headers, in String _body = gs!"")
677 	{
678 		checkClassBinding!(typeof(this))();
679 		return ptrcall!(GodotError)(GDNativeClassBinding.request, _godot_object, method, url, headers, _body);
680 	}
681 	/**
682 	Sends a raw request to the connected host.
683 	The URL parameter is usually just the part after the host, so for `http://somehost.com/index.php`, it is `/index.php`. When sending requests to an HTTP proxy server, it should be an absolute URL. For $(D constant HTTPClient.METHOD_OPTIONS) requests, `*` is also allowed. For $(D constant HTTPClient.METHOD_CONNECT) requests, it should be the authority component (`host:port`).
684 	Headers are HTTP request headers. For available HTTP methods, see $(D method).
685 	Sends the body data raw, as a byte array and does not encode it in any way.
686 	*/
687 	GodotError requestRaw(in long method, in String url, in PoolStringArray headers, in PoolByteArray _body)
688 	{
689 		checkClassBinding!(typeof(this))();
690 		return ptrcall!(GodotError)(GDNativeClassBinding.requestRaw, _godot_object, method, url, headers, _body);
691 	}
692 	/**
693 	
694 	*/
695 	void setBlockingMode(in bool enabled)
696 	{
697 		checkClassBinding!(typeof(this))();
698 		ptrcall!(void)(GDNativeClassBinding.setBlockingMode, _godot_object, enabled);
699 	}
700 	/**
701 	
702 	*/
703 	void setConnection(StreamPeer connection)
704 	{
705 		checkClassBinding!(typeof(this))();
706 		ptrcall!(void)(GDNativeClassBinding.setConnection, _godot_object, connection);
707 	}
708 	/**
709 	
710 	*/
711 	void setReadChunkSize(in long bytes)
712 	{
713 		checkClassBinding!(typeof(this))();
714 		ptrcall!(void)(GDNativeClassBinding.setReadChunkSize, _godot_object, bytes);
715 	}
716 	/**
717 	If `true`, execution will block until all data is read from the response.
718 	*/
719 	@property bool blockingModeEnabled()
720 	{
721 		return isBlockingModeEnabled();
722 	}
723 	/// ditto
724 	@property void blockingModeEnabled(bool v)
725 	{
726 		setBlockingMode(v);
727 	}
728 	/**
729 	The connection to use for this client.
730 	*/
731 	@property StreamPeer connection()
732 	{
733 		return getConnection();
734 	}
735 	/// ditto
736 	@property void connection(StreamPeer v)
737 	{
738 		setConnection(v);
739 	}
740 	/**
741 	The size of the buffer used and maximum bytes to read per iteration. See $(D readResponseBodyChunk).
742 	*/
743 	@property long readChunkSize()
744 	{
745 		return getReadChunkSize();
746 	}
747 	/// ditto
748 	@property void readChunkSize(long v)
749 	{
750 		setReadChunkSize(v);
751 	}
752 }