summaryrefslogtreecommitdiff
path: root/doc/classes/HTTPClient.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/HTTPClient.xml')
-rw-r--r--doc/classes/HTTPClient.xml90
1 files changed, 33 insertions, 57 deletions
diff --git a/doc/classes/HTTPClient.xml b/doc/classes/HTTPClient.xml
index a549994a69..861627b526 100644
--- a/doc/classes/HTTPClient.xml
+++ b/doc/classes/HTTPClient.xml
@@ -10,6 +10,7 @@
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).
[b]Note:[/b] 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 [url=https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS]CORS[/url]. If you host the server in question, you should modify its backend to allow requests from foreign origins by adding the [code]Access-Control-Allow-Origin: *[/code] HTTP header.
[b]Note:[/b] 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.
+ [b]Warning:[/b] 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.
</description>
<tutorials>
<link title="HTTP client class">https://docs.godotengine.org/en/latest/tutorials/networking/http_client_class.html</link>
@@ -17,23 +18,17 @@
</tutorials>
<methods>
<method name="close">
- <return type="void">
- </return>
+ <return type="void" />
<description>
Closes the current connection, allowing reuse of this [HTTPClient].
</description>
</method>
<method name="connect_to_host">
- <return type="int" enum="Error">
- </return>
- <argument index="0" name="host" type="String">
- </argument>
- <argument index="1" name="port" type="int" default="-1">
- </argument>
- <argument index="2" name="use_ssl" type="bool" default="false">
- </argument>
- <argument index="3" name="verify_host" type="bool" default="true">
- </argument>
+ <return type="int" enum="Error" />
+ <argument index="0" name="host" type="String" />
+ <argument index="1" name="port" type="int" default="-1" />
+ <argument index="2" name="use_ssl" type="bool" default="false" />
+ <argument index="3" name="verify_host" type="bool" default="true" />
<description>
Connects to a host. This needs to be done before any requests are sent.
The host should not have http:// prepended but will strip the protocol identifier if provided.
@@ -42,30 +37,26 @@
</description>
</method>
<method name="get_response_body_length" qualifiers="const">
- <return type="int">
- </return>
+ <return type="int" />
<description>
Returns the response's body length.
[b]Note:[/b] Some Web servers may not send a body length. In this case, the value returned will be [code]-1[/code]. If using chunked transfer encoding, the body length will also be [code]-1[/code].
</description>
</method>
<method name="get_response_code" qualifiers="const">
- <return type="int">
- </return>
+ <return type="int" />
<description>
Returns the response's HTTP status code.
</description>
</method>
<method name="get_response_headers">
- <return type="PackedStringArray">
- </return>
+ <return type="PackedStringArray" />
<description>
Returns the response headers.
</description>
</method>
<method name="get_response_headers_as_dictionary">
- <return type="Dictionary">
- </return>
+ <return type="Dictionary" />
<description>
Returns all response headers as a Dictionary of structure [code]{ "key": "value1; value2" }[/code] 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.
[b]Example:[/b]
@@ -78,38 +69,32 @@
</description>
</method>
<method name="get_status" qualifiers="const">
- <return type="int" enum="HTTPClient.Status">
- </return>
+ <return type="int" enum="HTTPClient.Status" />
<description>
Returns a [enum Status] constant. Need to call [method poll] in order to get status updates.
</description>
</method>
<method name="has_response" qualifiers="const">
- <return type="bool">
- </return>
+ <return type="bool" />
<description>
If [code]true[/code], this [HTTPClient] has a response available.
</description>
</method>
<method name="is_response_chunked" qualifiers="const">
- <return type="bool">
- </return>
+ <return type="bool" />
<description>
If [code]true[/code], this [HTTPClient] has a response that is chunked.
</description>
</method>
<method name="poll">
- <return type="int" enum="Error">
- </return>
+ <return type="int" enum="Error" />
<description>
This needs to be called in order to have any request processed. Check results with [method get_status].
</description>
</method>
<method name="query_string_from_dict">
- <return type="String">
- </return>
- <argument index="0" name="fields" type="Dictionary">
- </argument>
+ <return type="String" />
+ <argument index="0" name="fields" type="Dictionary" />
<description>
Generates a GET/POST application/x-www-form-urlencoded style query string from a provided dictionary, e.g.:
[codeblocks]
@@ -140,25 +125,20 @@
</description>
</method>
<method name="read_response_body_chunk">
- <return type="PackedByteArray">
- </return>
+ <return type="PackedByteArray" />
<description>
Reads one chunk from the response.
</description>
</method>
<method name="request">
- <return type="int" enum="Error">
- </return>
- <argument index="0" name="method" type="int" enum="HTTPClient.Method">
- </argument>
- <argument index="1" name="url" type="String">
- </argument>
- <argument index="2" name="headers" type="PackedStringArray">
- </argument>
- <argument index="3" name="body" type="String" default="&quot;&quot;">
- </argument>
+ <return type="int" enum="Error" />
+ <argument index="0" name="method" type="int" enum="HTTPClient.Method" />
+ <argument index="1" name="url" type="String" />
+ <argument index="2" name="headers" type="PackedStringArray" />
+ <argument index="3" name="body" type="String" default="&quot;&quot;" />
<description>
- Sends a request to the connected host. The URL parameter is just the part after the host, so for [code]http://somehost.com/index.php[/code], it is [code]index.php[/code].
+ Sends a request to the connected host.
+ The URL parameter is usually just the part after the host, so for [code]https://somehost.com/index.php[/code], it is [code]/index.php[/code]. When sending requests to an HTTP proxy server, it should be an absolute URL. For [constant HTTPClient.METHOD_OPTIONS] requests, [code]*[/code] is also allowed. For [constant HTTPClient.METHOD_CONNECT] requests, it should be the authority component ([code]host:port[/code]).
Headers are HTTP request headers. For available HTTP methods, see [enum Method].
To create a POST request with query strings to push to the server, do:
[codeblocks]
@@ -166,7 +146,7 @@
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)
+ var result = http_client.request(http_client.METHOD_POST, "/index.php", headers, query_string)
[/gdscript]
[csharp]
var fields = new Godot.Collections.Dictionary { { "username", "user" }, { "password", "pass" } };
@@ -179,18 +159,14 @@
</description>
</method>
<method name="request_raw">
- <return type="int" enum="Error">
- </return>
- <argument index="0" name="method" type="int" enum="HTTPClient.Method">
- </argument>
- <argument index="1" name="url" type="String">
- </argument>
- <argument index="2" name="headers" type="PackedStringArray">
- </argument>
- <argument index="3" name="body" type="PackedByteArray">
- </argument>
+ <return type="int" enum="Error" />
+ <argument index="0" name="method" type="int" enum="HTTPClient.Method" />
+ <argument index="1" name="url" type="String" />
+ <argument index="2" name="headers" type="PackedStringArray" />
+ <argument index="3" name="body" type="PackedByteArray" />
<description>
- Sends a raw request to the connected host. The URL parameter is just the part after the host, so for [code]http://somehost.com/index.php[/code], it is [code]index.php[/code].
+ Sends a raw request to the connected host.
+ The URL parameter is usually just the part after the host, so for [code]https://somehost.com/index.php[/code], it is [code]/index.php[/code]. When sending requests to an HTTP proxy server, it should be an absolute URL. For [constant HTTPClient.METHOD_OPTIONS] requests, [code]*[/code] is also allowed. For [constant HTTPClient.METHOD_CONNECT] requests, it should be the authority component ([code]host:port[/code]).
Headers are HTTP request headers. For available HTTP methods, see [enum Method].
Sends the body data raw, as a byte array and does not encode it in any way.
</description>