HTTPClient.request

Sends a request to the connected host. 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 constant HTTPClient.METHOD_OPTIONS requests, * is also allowed. For constant HTTPClient.METHOD_CONNECT requests, it should be the authority component (host:port). Headers are HTTP request headers. For available HTTP methods, see method. To create a POST request with query strings to push to the server, do:

More...
struct HTTPClient
@nogc nothrow
GodotError
request
(
in long method
,
in String url
,
in PoolStringArray headers
,
in String _body = gs!""
)

Detailed Description

var fields = {"username" : "user", "password" : "pass"} var query_string = http_client.query_string_from_dict(fields) var headers = "Content-Type: application/x-www-form-urlencoded", "Content-Length: " + str(query_string.length()) var result = http_client.request(http_client.METHOD_POST, "/index.php", headers, query_string)

Note: The request_data parameter is ignored if method is 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 String.httpEscape for an example.

Meta