1 /**
2 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.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 import godot.classdb;
23 import godot.reference;
24 import godot.streampeer;
25 /**
26 Hyper-text transfer protocol client.
27 
28 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.
29 Note that 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.
30 A `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.
31 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).
32 */
33 @GodotBaseClass struct HTTPClient
34 {
35 	enum string _GODOT_internal_name = "HTTPClient";
36 public:
37 @nogc nothrow:
38 	union { godot_object _godot_object; Reference _GODOT_base; }
39 	alias _GODOT_base this;
40 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
41 	package(godot) __gshared bool _classBindingInitialized = false;
42 	package(godot) static struct _classBinding
43 	{
44 		__gshared:
45 		@GodotName("connect_to_host") GodotMethod!(GodotError, String, long, bool, bool) connectToHost;
46 		@GodotName("set_connection") GodotMethod!(void, StreamPeer) setConnection;
47 		@GodotName("get_connection") GodotMethod!(StreamPeer) getConnection;
48 		@GodotName("request_raw") GodotMethod!(GodotError, long, String, PoolStringArray, PoolByteArray) requestRaw;
49 		@GodotName("request") GodotMethod!(GodotError, long, String, PoolStringArray, String) request;
50 		@GodotName("close") GodotMethod!(void) close;
51 		@GodotName("has_response") GodotMethod!(bool) hasResponse;
52 		@GodotName("is_response_chunked") GodotMethod!(bool) isResponseChunked;
53 		@GodotName("get_response_code") GodotMethod!(long) getResponseCode;
54 		@GodotName("get_response_headers") GodotMethod!(PoolStringArray) getResponseHeaders;
55 		@GodotName("get_response_headers_as_dictionary") GodotMethod!(Dictionary) getResponseHeadersAsDictionary;
56 		@GodotName("get_response_body_length") GodotMethod!(long) getResponseBodyLength;
57 		@GodotName("read_response_body_chunk") GodotMethod!(PoolByteArray) readResponseBodyChunk;
58 		@GodotName("set_read_chunk_size") GodotMethod!(void, long) setReadChunkSize;
59 		@GodotName("set_blocking_mode") GodotMethod!(void, bool) setBlockingMode;
60 		@GodotName("is_blocking_mode_enabled") GodotMethod!(bool) isBlockingModeEnabled;
61 		@GodotName("get_status") GodotMethod!(HTTPClient.Status) getStatus;
62 		@GodotName("poll") GodotMethod!(GodotError) poll;
63 		@GodotName("query_string_from_dict") GodotMethod!(String, Dictionary) queryStringFromDict;
64 	}
65 	bool opEquals(in HTTPClient other) const { return _godot_object.ptr is other._godot_object.ptr; }
66 	HTTPClient opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
67 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
68 	mixin baseCasts;
69 	static HTTPClient _new()
70 	{
71 		static godot_class_constructor constructor;
72 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("HTTPClient");
73 		if(constructor is null) return typeof(this).init;
74 		return cast(HTTPClient)(constructor());
75 	}
76 	@disable new(size_t s);
77 	/// 
78 	enum Status : int
79 	{
80 		/**
81 		Status: Disconnected from the server.
82 		*/
83 		statusDisconnected = 0,
84 		/**
85 		Status: Currently resolving the hostname for the given URL into an IP.
86 		*/
87 		statusResolving = 1,
88 		/**
89 		Status: DNS failure: Can't resolve the hostname for the given URL.
90 		*/
91 		statusCantResolve = 2,
92 		/**
93 		Status: Currently connecting to server.
94 		*/
95 		statusConnecting = 3,
96 		/**
97 		Status: Can't connect to the server.
98 		*/
99 		statusCantConnect = 4,
100 		/**
101 		Status: Connection established.
102 		*/
103 		statusConnected = 5,
104 		/**
105 		Status: Currently sending request.
106 		*/
107 		statusRequesting = 6,
108 		/**
109 		Status: HTTP body received.
110 		*/
111 		statusBody = 7,
112 		/**
113 		Status: Error in HTTP connection.
114 		*/
115 		statusConnectionError = 8,
116 		/**
117 		Status: Error in SSL handshake.
118 		*/
119 		statusSslHandshakeError = 9,
120 	}
121 	/// 
122 	enum Method : int
123 	{
124 		/**
125 		HTTP GET method. The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
126 		*/
127 		methodGet = 0,
128 		/**
129 		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.
130 		*/
131 		methodHead = 1,
132 		/**
133 		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.
134 		*/
135 		methodPost = 2,
136 		/**
137 		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).
138 		*/
139 		methodPut = 3,
140 		/**
141 		HTTP DELETE method. The DELETE method requests to delete the specified resource.
142 		*/
143 		methodDelete = 4,
144 		/**
145 		HTTP OPTIONS method. The OPTIONS method asks for a description of the communication options for the target resource. Rarely used.
146 		*/
147 		methodOptions = 5,
148 		/**
149 		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.
150 		*/
151 		methodTrace = 6,
152 		/**
153 		HTTP CONNECT method. The CONNECT method establishes a tunnel to the server identified by the target resource. Rarely used.
154 		*/
155 		methodConnect = 7,
156 		/**
157 		HTTP PATCH method. The PATCH method is used to apply partial modifications to a resource.
158 		*/
159 		methodPatch = 8,
160 		/**
161 		Marker for end of `METHOD_*` enum. Not used.
162 		*/
163 		methodMax = 9,
164 	}
165 	/// 
166 	enum ResponseCode : int
167 	{
168 		/**
169 		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).
170 		*/
171 		responseContinue = 100,
172 		/**
173 		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.
174 		*/
175 		responseSwitchingProtocols = 101,
176 		/**
177 		HTTP status code `102 Processing` (WebDAV). Indicates that the server has received and is processing the request, but no response is available yet.
178 		*/
179 		responseProcessing = 102,
180 		/**
181 		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.
182 		*/
183 		responseOk = 200,
184 		/**
185 		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.
186 		*/
187 		responseCreated = 201,
188 		/**
189 		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.
190 		*/
191 		responseAccepted = 202,
192 		/**
193 		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.
194 		*/
195 		responseNonAuthoritativeInformation = 203,
196 		/**
197 		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.
198 		*/
199 		responseNoContent = 204,
200 		/**
201 		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.
202 		*/
203 		responseResetContent = 205,
204 		/**
205 		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.
206 		*/
207 		responsePartialContent = 206,
208 		/**
209 		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.
210 		*/
211 		responseMultiStatus = 207,
212 		/**
213 		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.
214 		*/
215 		responseAlreadyReported = 208,
216 		/**
217 		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.
218 		*/
219 		responseImUsed = 226,
220 		/**
221 		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.
222 		*/
223 		responseMultipleChoices = 300,
224 		/**
225 		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.
226 		*/
227 		responseMovedPermanently = 301,
228 		/**
229 		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.
230 		*/
231 		responseFound = 302,
232 		/**
233 		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.
234 		*/
235 		responseSeeOther = 303,
236 		/**
237 		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.
238 		*/
239 		responseNotModified = 304,
240 		/**
241 		HTTP status code `305 Use Proxy`. Deprecated. Do not use.
242 		*/
243 		responseUseProxy = 305,
244 		/**
245 		HTTP status code `306 Switch Proxy`. Deprecated. Do not use.
246 		*/
247 		responseSwitchProxy = 306,
248 		/**
249 		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.
250 		*/
251 		responseTemporaryRedirect = 307,
252 		/**
253 		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.
254 		*/
255 		responsePermanentRedirect = 308,
256 		/**
257 		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).
258 		*/
259 		responseBadRequest = 400,
260 		/**
261 		HTTP status code `401 Unauthorized`. Credentials required. The request has not been applied because it lacks valid authentication credentials for the target resource.
262 		*/
263 		responseUnauthorized = 401,
264 		/**
265 		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.
266 		*/
267 		responsePaymentRequired = 402,
268 		/**
269 		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.
270 		*/
271 		responseForbidden = 403,
272 		/**
273 		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.
274 		*/
275 		responseNotFound = 404,
276 		/**
277 		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.
278 		*/
279 		responseMethodNotAllowed = 405,
280 		/**
281 		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.
282 		*/
283 		responseNotAcceptable = 406,
284 		/**
285 		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.
286 		*/
287 		responseProxyAuthenticationRequired = 407,
288 		/**
289 		HTTP status code `408 Request Timeout`. The server did not receive a complete request message within the time that it was prepared to wait.
290 		*/
291 		responseRequestTimeout = 408,
292 		/**
293 		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.
294 		*/
295 		responseConflict = 409,
296 		/**
297 		HTTP status code `410 Gone`. The target resource is no longer available at the origin server and this condition is likely permanent.
298 		*/
299 		responseGone = 410,
300 		/**
301 		HTTP status code `411 Length Required`. The server refuses to accept the request without a defined Content-Length header.
302 		*/
303 		responseLengthRequired = 411,
304 		/**
305 		HTTP status code `412 Precondition Failed`. One or more conditions given in the request header fields evaluated to false when tested on the server.
306 		*/
307 		responsePreconditionFailed = 412,
308 		/**
309 		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.
310 		*/
311 		responseRequestEntityTooLarge = 413,
312 		/**
313 		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.
314 		*/
315 		responseRequestUriTooLong = 414,
316 		/**
317 		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.
318 		*/
319 		responseUnsupportedMediaType = 415,
320 		/**
321 		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.
322 		*/
323 		responseRequestedRangeNotSatisfiable = 416,
324 		/**
325 		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.
326 		*/
327 		responseExpectationFailed = 417,
328 		/**
329 		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.
330 		*/
331 		responseImATeapot = 418,
332 		/**
333 		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.
334 		*/
335 		responseMisdirectedRequest = 421,
336 		/**
337 		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.
338 		*/
339 		responseUnprocessableEntity = 422,
340 		/**
341 		HTTP status code `423 Locked` (WebDAV). The source or destination resource of a method is locked.
342 		*/
343 		responseLocked = 423,
344 		/**
345 		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.
346 		*/
347 		responseFailedDependency = 424,
348 		/**
349 		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.
350 		*/
351 		responseUpgradeRequired = 426,
352 		/**
353 		HTTP status code `428 Precondition Required`. The origin server requires the request to be conditional.
354 		*/
355 		responsePreconditionRequired = 428,
356 		/**
357 		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.
358 		*/
359 		responseTooManyRequests = 429,
360 		/**
361 		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.
362 		*/
363 		responseRequestHeaderFieldsTooLarge = 431,
364 		/**
365 		HTTP status code `451 Response Unavailable For Legal Reasons`. The server is denying access to the resource as a consequence of a legal demand.
366 		*/
367 		responseUnavailableForLegalReasons = 451,
368 		/**
369 		HTTP status code `500 Internal Server Error`. The server encountered an unexpected condition that prevented it from fulfilling the request.
370 		*/
371 		responseInternalServerError = 500,
372 		/**
373 		HTTP status code `501 Not Implemented`. The server does not support the functionality required to fulfill the request.
374 		*/
375 		responseNotImplemented = 501,
376 		/**
377 		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.
378 		*/
379 		responseBadGateway = 502,
380 		/**
381 		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.
382 		*/
383 		responseServiceUnavailable = 503,
384 		/**
385 		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.
386 		*/
387 		responseGatewayTimeout = 504,
388 		/**
389 		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.
390 		*/
391 		responseHttpVersionNotSupported = 505,
392 		/**
393 		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.
394 		*/
395 		responseVariantAlsoNegotiates = 506,
396 		/**
397 		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.
398 		*/
399 		responseInsufficientStorage = 507,
400 		/**
401 		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.
402 		*/
403 		responseLoopDetected = 508,
404 		/**
405 		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.
406 		*/
407 		responseNotExtended = 510,
408 		/**
409 		HTTP status code `511 Network Authentication Required`. The client needs to authenticate to gain network access.
410 		*/
411 		responseNetworkAuthRequired = 511,
412 	}
413 	/// 
414 	enum Constants : int
415 	{
416 		methodGet = 0,
417 		statusDisconnected = 0,
418 		methodHead = 1,
419 		statusResolving = 1,
420 		statusCantResolve = 2,
421 		methodPost = 2,
422 		methodPut = 3,
423 		statusConnecting = 3,
424 		statusCantConnect = 4,
425 		methodDelete = 4,
426 		methodOptions = 5,
427 		statusConnected = 5,
428 		methodTrace = 6,
429 		statusRequesting = 6,
430 		methodConnect = 7,
431 		statusBody = 7,
432 		methodPatch = 8,
433 		statusConnectionError = 8,
434 		statusSslHandshakeError = 9,
435 		methodMax = 9,
436 		responseContinue = 100,
437 		responseSwitchingProtocols = 101,
438 		responseProcessing = 102,
439 		responseOk = 200,
440 		responseCreated = 201,
441 		responseAccepted = 202,
442 		responseNonAuthoritativeInformation = 203,
443 		responseNoContent = 204,
444 		responseResetContent = 205,
445 		responsePartialContent = 206,
446 		responseMultiStatus = 207,
447 		responseAlreadyReported = 208,
448 		responseImUsed = 226,
449 		responseMultipleChoices = 300,
450 		responseMovedPermanently = 301,
451 		responseFound = 302,
452 		responseSeeOther = 303,
453 		responseNotModified = 304,
454 		responseUseProxy = 305,
455 		responseSwitchProxy = 306,
456 		responseTemporaryRedirect = 307,
457 		responsePermanentRedirect = 308,
458 		responseBadRequest = 400,
459 		responseUnauthorized = 401,
460 		responsePaymentRequired = 402,
461 		responseForbidden = 403,
462 		responseNotFound = 404,
463 		responseMethodNotAllowed = 405,
464 		responseNotAcceptable = 406,
465 		responseProxyAuthenticationRequired = 407,
466 		responseRequestTimeout = 408,
467 		responseConflict = 409,
468 		responseGone = 410,
469 		responseLengthRequired = 411,
470 		responsePreconditionFailed = 412,
471 		responseRequestEntityTooLarge = 413,
472 		responseRequestUriTooLong = 414,
473 		responseUnsupportedMediaType = 415,
474 		responseRequestedRangeNotSatisfiable = 416,
475 		responseExpectationFailed = 417,
476 		responseImATeapot = 418,
477 		responseMisdirectedRequest = 421,
478 		responseUnprocessableEntity = 422,
479 		responseLocked = 423,
480 		responseFailedDependency = 424,
481 		responseUpgradeRequired = 426,
482 		responsePreconditionRequired = 428,
483 		responseTooManyRequests = 429,
484 		responseRequestHeaderFieldsTooLarge = 431,
485 		responseUnavailableForLegalReasons = 451,
486 		responseInternalServerError = 500,
487 		responseNotImplemented = 501,
488 		responseBadGateway = 502,
489 		responseServiceUnavailable = 503,
490 		responseGatewayTimeout = 504,
491 		responseHttpVersionNotSupported = 505,
492 		responseVariantAlsoNegotiates = 506,
493 		responseInsufficientStorage = 507,
494 		responseLoopDetected = 508,
495 		responseNotExtended = 510,
496 		responseNetworkAuthRequired = 511,
497 	}
498 	/**
499 	Connect to a host. This needs to be done before any requests are sent.
500 	The host should not have http:// prepended but will strip the protocol identifier if provided.
501 	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).
502 	`verify_host` will check the SSL identity of the host if set to `true`.
503 	*/
504 	GodotError connectToHost(StringArg0)(in StringArg0 host, in long port = -1, in bool use_ssl = false, in bool verify_host = true)
505 	{
506 		checkClassBinding!(typeof(this))();
507 		return ptrcall!(GodotError)(_classBinding.connectToHost, _godot_object, host, port, use_ssl, verify_host);
508 	}
509 	/**
510 	
511 	*/
512 	void setConnection(StreamPeer connection)
513 	{
514 		checkClassBinding!(typeof(this))();
515 		ptrcall!(void)(_classBinding.setConnection, _godot_object, connection);
516 	}
517 	/**
518 	
519 	*/
520 	Ref!StreamPeer getConnection() const
521 	{
522 		checkClassBinding!(typeof(this))();
523 		return ptrcall!(StreamPeer)(_classBinding.getConnection, _godot_object);
524 	}
525 	/**
526 	Sends a raw request to the connected host. The URL parameter is just the part after the host, so for `http://somehost.com/index.php`, it is `index.php`.
527 	Headers are HTTP request headers. For available HTTP methods, see `METHOD_*`.
528 	Sends the body data raw, as a byte array and does not encode it in any way.
529 	*/
530 	GodotError requestRaw(StringArg1)(in long method, in StringArg1 url, in PoolStringArray headers, in PoolByteArray _body)
531 	{
532 		checkClassBinding!(typeof(this))();
533 		return ptrcall!(GodotError)(_classBinding.requestRaw, _godot_object, method, url, headers, _body);
534 	}
535 	/**
536 	Sends a request to the connected host. The URL parameter is just the part after the host, so for `http://somehost.com/index.php`, it is `index.php`.
537 	Headers are HTTP request headers. For available HTTP methods, see `METHOD_*`.
538 	To create a POST request with query strings to push to the server, do:
539 	
540 	
541 	var fields = {"username" : "user", "password" : "pass"}
542 	var queryString = httpClient.query_string_from_dict(fields)
543 	var headers = $(D "Content-Type: application/x-www-form-urlencoded", "Content-Length: " + str(queryString.length()))
544 	var result = httpClient.request(httpClient.METHOD_POST, "index.php", headers, queryString)
545 	
546 	
547 	*/
548 	GodotError request(StringArg1, StringArg3)(in long method, in StringArg1 url, in PoolStringArray headers, in StringArg3 _body = "")
549 	{
550 		checkClassBinding!(typeof(this))();
551 		return ptrcall!(GodotError)(_classBinding.request, _godot_object, method, url, headers, _body);
552 	}
553 	/**
554 	Closes the current connection, allowing reuse of this `HTTPClient`.
555 	*/
556 	void close()
557 	{
558 		checkClassBinding!(typeof(this))();
559 		ptrcall!(void)(_classBinding.close, _godot_object);
560 	}
561 	/**
562 	If `true` this `HTTPClient` has a response available.
563 	*/
564 	bool hasResponse() const
565 	{
566 		checkClassBinding!(typeof(this))();
567 		return ptrcall!(bool)(_classBinding.hasResponse, _godot_object);
568 	}
569 	/**
570 	If `true` this `HTTPClient` has a response that is chunked.
571 	*/
572 	bool isResponseChunked() const
573 	{
574 		checkClassBinding!(typeof(this))();
575 		return ptrcall!(bool)(_classBinding.isResponseChunked, _godot_object);
576 	}
577 	/**
578 	Returns the response's HTTP status code.
579 	*/
580 	long getResponseCode() const
581 	{
582 		checkClassBinding!(typeof(this))();
583 		return ptrcall!(long)(_classBinding.getResponseCode, _godot_object);
584 	}
585 	/**
586 	Returns the response headers.
587 	*/
588 	PoolStringArray getResponseHeaders()
589 	{
590 		checkClassBinding!(typeof(this))();
591 		return ptrcall!(PoolStringArray)(_classBinding.getResponseHeaders, _godot_object);
592 	}
593 	/**
594 	Returns all response headers as dictionary 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.
595 	Structure: ("key":"value1; value2")
596 	Example: (content-length:12), (Content-Type:application/json; charset=UTF-8)
597 	*/
598 	Dictionary getResponseHeadersAsDictionary()
599 	{
600 		checkClassBinding!(typeof(this))();
601 		return ptrcall!(Dictionary)(_classBinding.getResponseHeadersAsDictionary, _godot_object);
602 	}
603 	/**
604 	Returns the response's body length.
605 	*/
606 	long getResponseBodyLength() const
607 	{
608 		checkClassBinding!(typeof(this))();
609 		return ptrcall!(long)(_classBinding.getResponseBodyLength, _godot_object);
610 	}
611 	/**
612 	Reads one chunk from the response.
613 	*/
614 	PoolByteArray readResponseBodyChunk()
615 	{
616 		checkClassBinding!(typeof(this))();
617 		return ptrcall!(PoolByteArray)(_classBinding.readResponseBodyChunk, _godot_object);
618 	}
619 	/**
620 	Sets the size of the buffer used and maximum bytes to read per iteration. see $(D readResponseBodyChunk)
621 	*/
622 	void setReadChunkSize(in long bytes)
623 	{
624 		checkClassBinding!(typeof(this))();
625 		ptrcall!(void)(_classBinding.setReadChunkSize, _godot_object, bytes);
626 	}
627 	/**
628 	
629 	*/
630 	void setBlockingMode(in bool enabled)
631 	{
632 		checkClassBinding!(typeof(this))();
633 		ptrcall!(void)(_classBinding.setBlockingMode, _godot_object, enabled);
634 	}
635 	/**
636 	
637 	*/
638 	bool isBlockingModeEnabled() const
639 	{
640 		checkClassBinding!(typeof(this))();
641 		return ptrcall!(bool)(_classBinding.isBlockingModeEnabled, _godot_object);
642 	}
643 	/**
644 	Returns a STATUS_* enum constant. Need to call $(D poll) in order to get status updates.
645 	*/
646 	HTTPClient.Status getStatus() const
647 	{
648 		checkClassBinding!(typeof(this))();
649 		return ptrcall!(HTTPClient.Status)(_classBinding.getStatus, _godot_object);
650 	}
651 	/**
652 	This needs to be called in order to have any request processed. Check results with $(D getStatus)
653 	*/
654 	GodotError poll()
655 	{
656 		checkClassBinding!(typeof(this))();
657 		return ptrcall!(GodotError)(_classBinding.poll, _godot_object);
658 	}
659 	/**
660 	Generates a GET/POST application/x-www-form-urlencoded style query string from a provided dictionary, e.g.:
661 	
662 	
663 	var fields = {"username": "user", "password": "pass"}
664 	String queryString = httpClient.query_string_from_dict(fields)
665 	returns:= "username=user&password=pass"
666 	
667 	
668 	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.
669 	
670 	
671 	var fields = {"single": 123, "not_valued": null, "multiple": $(D 22, 33, 44)}
672 	String queryString = httpClient.query_string_from_dict(fields)
673 	returns:= "single=123&not_valued&multiple=22&multiple=33&multiple=44"
674 	
675 	
676 	*/
677 	String queryStringFromDict(in Dictionary fields)
678 	{
679 		checkClassBinding!(typeof(this))();
680 		return ptrcall!(String)(_classBinding.queryStringFromDict, _godot_object, fields);
681 	}
682 	/**
683 	If `true`, execution will block until all data is read from the response.
684 	*/
685 	@property bool blockingModeEnabled()
686 	{
687 		return isBlockingModeEnabled();
688 	}
689 	/// ditto
690 	@property void blockingModeEnabled(bool v)
691 	{
692 		setBlockingMode(v);
693 	}
694 	/**
695 	The connection to use for this client.
696 	*/
697 	@property StreamPeer connection()
698 	{
699 		return getConnection();
700 	}
701 	/// ditto
702 	@property void connection(StreamPeer v)
703 	{
704 		setConnection(v);
705 	}
706 }