A node with the ability to send HTTP requests.
    public class HTTPRequest : Node

A node with the ability to send HTTP requests. Uses HTTPClient internally.

Can be used to make HTTP requests, i.e. download or upload files or web content via HTTP.

Inheritance Chain

Constructors

    public HTTPRequest()

Signals

    "request_completed" (int result, int response_code, PoolStringArray headers, PoolByteArray body)

Emitted when a request is completed.

Properties

    public int BodySizeLimit { get; set; }

Maximum allowed size for response bodies.

    public string DownloadFile { get; set; }

The file to download into. Will output any received file into it.

    public int MaxRedirects { get; set; }

Maximum number of allowed redirects.

    public int Timeout { get; set; }

    public bool UseThreads { get; set; }

If true, multithreading is used to improve performance.

Methods

    public void CancelRequest()

Cancels the current request.

    public int GetBodySize()

Returns the response body length.

    [Obsolete("GetBodySizeLimit is deprecated. Use the BodySizeLimit property instead.")]
    public int GetBodySizeLimit()

Getter for BodySizeLimit

    public int GetDownloadedBytes()

Returns the amount of bytes this HTTPRequest downloaded.

    [Obsolete("GetDownloadFile is deprecated. Use the DownloadFile property instead.")]
    public string GetDownloadFile()

Getter for DownloadFile

    public HTTPClient.Status GetHttpClientStatus()

Returns the current status of the underlying HTTPClient. See STATUS_* enum on HTTPClient.

    [Obsolete("GetMaxRedirects is deprecated. Use the MaxRedirects property instead.")]
    public int GetMaxRedirects()

Getter for MaxRedirects

    [Obsolete("GetTimeout is deprecated. Use the Timeout property instead.")]
    public int GetTimeout()

Getter for Result.Timeout

    [Obsolete("IsUsingThreads is deprecated. Use the UseThreads property instead.")]
    public bool IsUsingThreads()

Getter for UseThreads

    public Error Request(string url, string[] customHeaders = null, bool sslValidateDomain = true, HTTPClient.Method method = HTTPClient.Method.Get, string requestData = "")

Creates request on the underlying HTTPClient. If there is no configuration errors, it tries to connect using HTTPClient.ConnectToHost(string, int, bool, bool) and passes parameters onto HTTPClient.Request(Godot.HTTPClient.Method, string, string[], string).

Returns [constant OK] if request is successfully created. (Does not imply that the server has responded), [constant ERR_UNCONFIGURED] if not in the tree, [constant ERR_BUSY] if still processing previous request, [constant ERR_INVALID_PARAMETER] if given string is not a valid URL format, or [constant ERR_CANT_CONNECT] if not using thread and the HTTPClient cannot connect to host.

    [Obsolete("SetBodySizeLimit is deprecated. Use the BodySizeLimit property instead.")]
    public void SetBodySizeLimit(int bytes)

Setter for BodySizeLimit

    [Obsolete("SetDownloadFile is deprecated. Use the DownloadFile property instead.")]
    public void SetDownloadFile(string path)

Setter for DownloadFile

    [Obsolete("SetMaxRedirects is deprecated. Use the MaxRedirects property instead.")]
    public void SetMaxRedirects(int amount)

Setter for MaxRedirects

    [Obsolete("SetTimeout is deprecated. Use the Timeout property instead.")]
    public void SetTimeout(int timeout)

Setter for Result.Timeout

    [Obsolete("SetUseThreads is deprecated. Use the UseThreads property instead.")]
    public void SetUseThreads(bool enable)

Setter for UseThreads

Inner Types

Result

Name Value Description
Success 0 Request successful.
ChunkedBodySizeMismatch 1  
CantConnect 2 Request failed while connecting.
CantResolve 3 Request failed while resolving.
ConnectionError 4 Request failed due to connection (read/write) error.
SslHandshakeError 5 Request failed on SSL handshake.
NoResponse 6 Request does not have a response (yet).
BodySizeLimitExceeded 7 Request exceeded its maximum size limit, see [member body_size_limit].
RequestFailed 8 Request failed. (Unused)
DownloadFileCantOpen 9 HTTPRequest couldn’t open the download file.
DownloadFileWriteError 10 HTTPRequest couldn’t write to the download file.
RedirectLimitReached 11 Request reached its maximum redirect limit, see [member max_redirects].
Timeout 12  
Tags: