.. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead. .. _class_HTTPClient: HTTPClient ========== **Inherits:** :ref:`Reference` **<** :ref:`Object` **Category:** Core Brief Description ----------------- Hyper-text transfer protocol client. Member Functions ---------------- +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`close` **(** **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`connect_to_host` **(** :ref:`String` host, :ref:`int` port, :ref:`bool` use_ssl=null, :ref:`bool` verify_host=null **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StreamPeer` | :ref:`get_connection` **(** **)** const | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_response_body_length` **(** **)** const | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_response_code` **(** **)** const | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PoolStringArray` | :ref:`get_response_headers` **(** **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Dictionary` | :ref:`get_response_headers_as_dictionary` **(** **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_status` **(** **)** const | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_response` **(** **)** const | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_blocking_mode_enabled` **(** **)** const | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_response_chunked` **(** **)** const | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`poll` **(** **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`query_string_from_dict` **(** :ref:`Dictionary` fields **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PoolByteArray` | :ref:`read_response_body_chunk` **(** **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`request` **(** :ref:`int` method, :ref:`String` url, :ref:`PoolStringArray` headers, :ref:`String` body=null **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`request_raw` **(** :ref:`int` method, :ref:`String` url, :ref:`PoolStringArray` headers, :ref:`PoolByteArray` body **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`send_body_data` **(** :ref:`PoolByteArray` body **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`send_body_text` **(** :ref:`String` body **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_blocking_mode` **(** :ref:`bool` enabled **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_connection` **(** :ref:`StreamPeer` connection **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_read_chunk_size` **(** :ref:`int` bytes **)** | +------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Numeric Constants ----------------- - **METHOD_GET** = **0** - **METHOD_HEAD** = **1** - **METHOD_POST** = **2** - **METHOD_PUT** = **3** - **METHOD_DELETE** = **4** - **METHOD_OPTIONS** = **5** - **METHOD_TRACE** = **6** - **METHOD_CONNECT** = **7** - **METHOD_MAX** = **8** - **STATUS_DISCONNECTED** = **0** - **STATUS_RESOLVING** = **1** - **STATUS_CANT_RESOLVE** = **2** - **STATUS_CONNECTING** = **3** - **STATUS_CANT_CONNECT** = **4** - **STATUS_CONNECTED** = **5** - **STATUS_REQUESTING** = **6** - **STATUS_BODY** = **7** - **STATUS_CONNECTION_ERROR** = **8** - **STATUS_SSL_HANDSHAKE_ERROR** = **9** - **RESPONSE_CONTINUE** = **100** - **RESPONSE_SWITCHING_PROTOCOLS** = **101** - **RESPONSE_PROCESSING** = **102** - **RESPONSE_OK** = **200** - **RESPONSE_CREATED** = **201** - **RESPONSE_ACCEPTED** = **202** - **RESPONSE_NON_AUTHORITATIVE_INFORMATION** = **203** - **RESPONSE_NO_CONTENT** = **204** - **RESPONSE_RESET_CONTENT** = **205** - **RESPONSE_PARTIAL_CONTENT** = **206** - **RESPONSE_MULTI_STATUS** = **207** - **RESPONSE_IM_USED** = **226** - **RESPONSE_MULTIPLE_CHOICES** = **300** - **RESPONSE_MOVED_PERMANENTLY** = **301** - **RESPONSE_FOUND** = **302** - **RESPONSE_SEE_OTHER** = **303** - **RESPONSE_NOT_MODIFIED** = **304** - **RESPONSE_USE_PROXY** = **305** - **RESPONSE_TEMPORARY_REDIRECT** = **307** - **RESPONSE_BAD_REQUEST** = **400** - **RESPONSE_UNAUTHORIZED** = **401** - **RESPONSE_PAYMENT_REQUIRED** = **402** - **RESPONSE_FORBIDDEN** = **403** - **RESPONSE_NOT_FOUND** = **404** - **RESPONSE_METHOD_NOT_ALLOWED** = **405** - **RESPONSE_NOT_ACCEPTABLE** = **406** - **RESPONSE_PROXY_AUTHENTICATION_REQUIRED** = **407** - **RESPONSE_REQUEST_TIMEOUT** = **408** - **RESPONSE_CONFLICT** = **409** - **RESPONSE_GONE** = **410** - **RESPONSE_LENGTH_REQUIRED** = **411** - **RESPONSE_PRECONDITION_FAILED** = **412** - **RESPONSE_REQUEST_ENTITY_TOO_LARGE** = **413** - **RESPONSE_REQUEST_URI_TOO_LONG** = **414** - **RESPONSE_UNSUPPORTED_MEDIA_TYPE** = **415** - **RESPONSE_REQUESTED_RANGE_NOT_SATISFIABLE** = **416** - **RESPONSE_EXPECTATION_FAILED** = **417** - **RESPONSE_UNPROCESSABLE_ENTITY** = **422** - **RESPONSE_LOCKED** = **423** - **RESPONSE_FAILED_DEPENDENCY** = **424** - **RESPONSE_UPGRADE_REQUIRED** = **426** - **RESPONSE_INTERNAL_SERVER_ERROR** = **500** - **RESPONSE_NOT_IMPLEMENTED** = **501** - **RESPONSE_BAD_GATEWAY** = **502** - **RESPONSE_SERVICE_UNAVAILABLE** = **503** - **RESPONSE_GATEWAY_TIMEOUT** = **504** - **RESPONSE_HTTP_VERSION_NOT_SUPPORTED** = **505** - **RESPONSE_INSUFFICIENT_STORAGE** = **507** - **RESPONSE_NOT_EXTENDED** = **510** Description ----------- Hyper-text transfer protocol client. Supports SSL and SSL server certificate verification. Can be reused to connect to different hosts and make many requests. Member Function Description --------------------------- .. _class_HTTPClient_close: - void **close** **(** **)** Cloces the current connection, allows for reusal of :ref:`HTTPClient`. .. _class_HTTPClient_connect_to_host: - :ref:`int` **connect_to_host** **(** :ref:`String` host, :ref:`int` port, :ref:`bool` use_ssl=null, :ref:`bool` verify_host=null **)** Connect 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. verify_host will check the SSL identity of the host if set to true. .. _class_HTTPClient_get_connection: - :ref:`StreamPeer` **get_connection** **(** **)** const Return current connection. .. _class_HTTPClient_get_response_body_length: - :ref:`int` **get_response_body_length** **(** **)** const Return the response's body length. .. _class_HTTPClient_get_response_code: - :ref:`int` **get_response_code** **(** **)** const Return the HTTP status code of the response. .. _class_HTTPClient_get_response_headers: - :ref:`PoolStringArray` **get_response_headers** **(** **)** Return the response headers. .. _class_HTTPClient_get_response_headers_as_dictionary: - :ref:`Dictionary` **get_response_headers_as_dictionary** **(** **)** 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. Structure: ("key":"value1; value2") Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) .. _class_HTTPClient_get_status: - :ref:`int` **get_status** **(** **)** const Returns a STATUS\_\* enum constant. Need to call :ref:`poll` in order to get status updates. .. _class_HTTPClient_has_response: - :ref:`bool` **has_response** **(** **)** const Return whether this :ref:`HTTPClient` has a response available. .. _class_HTTPClient_is_blocking_mode_enabled: - :ref:`bool` **is_blocking_mode_enabled** **(** **)** const Return whether blocking mode is enabled. .. _class_HTTPClient_is_response_chunked: - :ref:`bool` **is_response_chunked** **(** **)** const Return whether this :ref:`HTTPClient` has a response that is chunked. .. _class_HTTPClient_poll: - :ref:`int` **poll** **(** **)** This needs to be called in order to have any request processed. Check results with :ref:`get_status` .. _class_HTTPClient_query_string_from_dict: - :ref:`String` **query_string_from_dict** **(** :ref:`Dictionary` fields **)** Generates a GET/POST application/x-www-form-urlencoded style query string from a provided dictionary, e.g.: :: var fields = {"username": "user", "password": "pass"} String queryString = httpClient.query_string_from_dict(fields) returns:= "username=user&password=pass" .. _class_HTTPClient_read_response_body_chunk: - :ref:`PoolByteArray` **read_response_body_chunk** **(** **)** Reads one chunk from the response. .. _class_HTTPClient_request: - :ref:`int` **request** **(** :ref:`int` method, :ref:`String` url, :ref:`PoolStringArray` headers, :ref:`String` body=null **)** Sends a request to the connected host. The url is what is normally behind the hostname, i.e. in ``http://somehost.com/index.php``, url would be "index.php". Headers are HTTP request headers. To create a POST request with query strings to push to the server, do: :: var fields = {"username" : "user", "password" : "pass"} var queryString = httpClient.query_string_from_dict(fields) var headers = ["Content-Type: application/x-www-form-urlencoded", "Content-Length: " + str(queryString.length())] var result = httpClient.request(httpClient.METHOD_POST, "index.php", headers, queryString) .. _class_HTTPClient_request_raw: - :ref:`int` **request_raw** **(** :ref:`int` method, :ref:`String` url, :ref:`PoolStringArray` headers, :ref:`PoolByteArray` body **)** Sends a raw request to the connected host. The url is what is normally behind the hostname, i.e. in ``http://somehost.com/index.php``, url would be "index.php". Headers are HTTP request headers. Sends body raw, as a byte array, does not encode it in any way. .. _class_HTTPClient_send_body_data: - :ref:`int` **send_body_data** **(** :ref:`PoolByteArray` body **)** Stub function .. _class_HTTPClient_send_body_text: - :ref:`int` **send_body_text** **(** :ref:`String` body **)** Stub function .. _class_HTTPClient_set_blocking_mode: - void **set_blocking_mode** **(** :ref:`bool` enabled **)** If set to true, execution will block until all data is read from the response. .. _class_HTTPClient_set_connection: - void **set_connection** **(** :ref:`StreamPeer` connection **)** Set connection to use, for this client. .. _class_HTTPClient_set_read_chunk_size: - void **set_read_chunk_size** **(** :ref:`int` bytes **)** Sets the size of the buffer used and maximum bytes to read per iteration. see :ref:`read_response_body_chunk`