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)

This signal is emitted upon request completion.

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 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.

    public int GetBodySizeLimit()

Getter for BodySizeLimit

    public int GetDownloadedBytes()

Returns the amount of bytes this HTTPRequest downloaded.

    public string GetDownloadFile()

Getter for DownloadFile

    public HTTPClient.Status GetHttpClientStatus()

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

    public int GetMaxRedirects()

Getter for MaxRedirects

    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 = "")

    public void SetBodySizeLimit(int bytes)

Setter for BodySizeLimit

    public void SetDownloadFile(string path)

Setter for DownloadFile

    public void SetMaxRedirects(int amount)

Setter for MaxRedirects

    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 [method set_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 [method set_max_redirects].
Tags: