reckfellENGINE

HttpRequest

An asynchronous HTTP request with a completion signal.

On this page
class HttpRequestReckfellSharpInherits Entity

HttpRequest must be inside EntityTree. One instance serves one request at a time. The Error returned by Request/RequestRaw describes startup; RequestCompleted supplies separate result, responseCode, headers and body.

Result.Success means successful transfer, not necessarily HTTP 2xx, valid JSON or a completed application operation. Validate each required layer. Bound Timeout/BodySizeLimit and define redirect policy. CancelRequest does not automatically emit a cancellation completion; coordinate UI/owner lifetime.

Working example.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

HttpRequestConstructor
# HttpRequest
C#
public HttpRequest();

Properties9

AcceptGZipProperty
# AcceptGZip
C#
public bool AcceptGZip { get; set; }

Requests gzip/deflate when Accept-Encoding is unspecified and handles the corresponding response Content-Encoding. A decompressed-data bound is still necessary.

AppendToDownloadFileProperty
# AppendToDownloadFile
C#
public bool AppendToDownloadFile { get; set; }

Allows appending on a suitable Partial Content response. Does not replace Range/Content-Range or existing-file identity checks.

BodySizeLimitProperty
# BodySizeLimit
C#
public int BodySizeLimit { get; set; }

Body-byte bound; -1 disables it. Automatic decompression also bounds the decompressed result. Define an explicit budget for external responses.

DownloadChunkSizeProperty
# DownloadChunkSize
C#
public int DownloadChunkSize { get; set; }

The size of the buffer used and maximum bytes to read per iteration. See HttpClient.ReadChunkSize. Set this to a lower value (e.g. 4096 for 4 KiB) when downloading small files to decrease memory usage at the cost of download speeds.

DownloadFileProperty
# DownloadFile
C#
public string DownloadFile { get; set; }

Writes the response body to a path instead of signal body storage. Successful writing does not establish HTTP 2xx or valid content; use a temporary file first.

KeepPartialDownloadProperty
# KeepPartialDownload
C#
public bool KeepPartialDownload { get; set; }

Keeps an unfinished file when a request stops. A partial file is not a completed resource; validate length/content before use.

MaxRedirectsProperty
# MaxRedirects
C#
public int MaxRedirects { get; set; }

Automatic-redirect limit; 0 disallows them, -1 disables the limit. Validate destination, method and headers across redirects.

TimeoutProperty
# Timeout
C#
public double Timeout { get; set; }

Timeout in seconds; 0 disables it. The internal Timer ignores TimeScale, but its processing still depends on EntityTree/pause.

UseThreadsProperty
# UseThreads
C#
public bool UseThreads { get; set; }

Enables an internal worker if the build supports it. Does not automatically make your handlers or EntityTree access thread-safe.

Methods29

CancelRequestvoid
# CancelRequest
C#
public void CancelRequest();

Stops the active request; does not itself emit RequestCompleted for cancellation. File cleanup depends on completion and KeepPartialDownload.

GetBodySizeint
# GetBodySize
C#
public int GetBodySize();

Returns the response body length. Note: Some Web servers may not send a body length. In this case, the value returned will be -1. If using chunked transfer encoding, the body length will also be -1.

Returns int
GetBodySizeLimitint
# GetBodySizeLimit
C#
public int GetBodySizeLimit();
Returns int
GetDownloadChunkSizeint
# GetDownloadChunkSize
C#
public int GetDownloadChunkSize();
Returns int
GetDownloadFilestring
# GetDownloadFile
C#
public string GetDownloadFile();
Returns string
GetDownloadedBytesint
# GetDownloadedBytes
C#
public int GetDownloadedBytes();

Returns the number of bytes this HTTPRequest downloaded.

Returns int
GetHttpClientStatusHttpClient.Status
# GetHttpClientStatus
C#
public HttpClient.Status GetHttpClientStatus();

Returns the current status of the underlying HttpClient.

Returns HttpClient.Status
GetMaxRedirectsint
# GetMaxRedirects
C#
public int GetMaxRedirects();
Returns int
GetTimeoutdouble
# GetTimeout
C#
public double GetTimeout();
Returns double
IsAcceptingGZipbool
# IsAcceptingGZip
C#
public bool IsAcceptingGZip();
Returns bool
IsAppendingToDownloadFilebool
# IsAppendingToDownloadFile
C#
public bool IsAppendingToDownloadFile();
Returns bool
IsKeepingPartialDownloadbool
# IsKeepingPartialDownload
C#
public bool IsKeepingPartialDownload();
Returns bool
IsUsingThreadsbool
# IsUsingThreads
C#
public bool IsUsingThreads();
Returns bool
Request2 overloads
# Request · 1/2
C#
public Error Request(string url, ReadOnlySpan<string> customHeaders, HttpClient.Method method, string requestData);

Starts an HTTP request with a UTF-8 string body. Requires tree membership and an idle instance. Error.Ok does not mean an HTTP 2xx response arrived: inspect RequestCompleted.

Parameters
NameTypeDefault
urlstring—
customHeadersReadOnlySpan<string>—
methodHttpClient.Method—
requestDatastring—
Returns Error
# Request · 2/2
C#
public Error Request(string url, string[] customHeaders = null, HttpClient.Method method = HttpClient.Method.Get, string requestData = "");

Starts an HTTP request with a UTF-8 string body. Requires tree membership and an idle instance. Error.Ok does not mean an HTTP 2xx response arrived: inspect RequestCompleted.

Parameters
NameTypeDefault
urlstring—
customHeadersstring[]null
methodHttpClient.MethodHttpClient.Method.Get
requestDatastring""
customHeaders

If the parameter is null, then the default value is Array.Empty<string>().

Returns Error
RequestRaw2 overloads
# RequestRaw · 1/2
C#
public Error RequestRaw(string url, ReadOnlySpan<string> customHeaders, HttpClient.Method method, ReadOnlySpan<byte> requestDataRaw);

Sends exact body bytes. Match method and Content-Type to the API. Specify explicit array types if overload resolution is ambiguous.

Parameters
NameTypeDefault
urlstring—
customHeadersReadOnlySpan<string>—
methodHttpClient.Method—
requestDataRawReadOnlySpan<byte>—
Returns Error
# RequestRaw · 2/2
C#
public Error RequestRaw(string url, string[] customHeaders = null, HttpClient.Method method = HttpClient.Method.Get, byte[] requestDataRaw = null);

Sends exact body bytes. Match method and Content-Type to the API. Specify explicit array types if overload resolution is ambiguous.

Parameters
NameTypeDefault
urlstring—
customHeadersstring[]null
methodHttpClient.MethodHttpClient.Method.Get
requestDataRawbyte[]null
customHeaders

If the parameter is null, then the default value is Array.Empty<string>().

requestDataRaw

If the parameter is null, then the default value is Array.Empty<byte>().

Returns Error
SetAcceptGZipvoid
# SetAcceptGZip
C#
public void SetAcceptGZip(bool enable);
Parameters
NameTypeDefault
enablebool—
SetAppendToDownloadFilevoid
# SetAppendToDownloadFile
C#
public void SetAppendToDownloadFile(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetBodySizeLimitvoid
# SetBodySizeLimit
C#
public void SetBodySizeLimit(int bytes);
Parameters
NameTypeDefault
bytesint—
SetDownloadChunkSizevoid
# SetDownloadChunkSize
C#
public void SetDownloadChunkSize(int chunkSize);
Parameters
NameTypeDefault
chunkSizeint—
SetDownloadFilevoid
# SetDownloadFile
C#
public void SetDownloadFile(string path);
Parameters
NameTypeDefault
pathstring—
SetHttpProxyvoid
# SetHttpProxy
C#
public void SetHttpProxy(string host, int port);

Sets the proxy server for HTTP requests. The proxy server is unset if host is empty or port is -1.

Parameters
NameTypeDefault
hoststring—
portint—
SetHttpsProxyvoid
# SetHttpsProxy
C#
public void SetHttpsProxy(string host, int port);

Sets the proxy server for HTTPS requests. The proxy server is unset if host is empty or port is -1.

Parameters
NameTypeDefault
hoststring—
portint—
SetKeepPartialDownloadvoid
# SetKeepPartialDownload
C#
public void SetKeepPartialDownload(bool enabled);
Parameters
NameTypeDefault
enabledbool—
SetMaxRedirectsvoid
# SetMaxRedirects
C#
public void SetMaxRedirects(int amount);
Parameters
NameTypeDefault
amountint—
SetTimeoutvoid
# SetTimeout
C#
public void SetTimeout(double timeout);
Parameters
NameTypeDefault
timeoutdouble—
SetTlsOptionsvoid
# SetTlsOptions
C#
public void SetTlsOptions(TlsOptions clientOptions);

Sets client options for HTTPS. Use verified Client options and load a private CA correctly before starting.

Parameters
NameTypeDefault
clientOptionsTlsOptions—
SetUseThreadsvoid
# SetUseThreads
C#
public void SetUseThreads(bool enable);
Parameters
NameTypeDefault
enablebool—

Signals and events1

RequestCompletedEvent
# RequestCompleted
C#
public event HttpRequest.RequestCompletedEventHandler RequestCompleted;

Reports transfer result, HTTP code, headers and body bytes. Result.Success can accompany 404. With DownloadFile the body goes to disk while body is empty.

Handler parameters
NameTypeDefault
resultlong—
responseCodelong—
headersstring[]—
bodybyte[]—

HttpRequest.Result

ValueDescription
BodyDecompressFailed = 8

Request failed due to an error while decompressing the response body. Possible causes include unsupported or incorrect compression format, corrupted data, or incomplete transfer.

BodySizeLimitExceeded = 7

Request exceeded its maximum size limit, see HttpRequest.BodySizeLimit.

CantConnect = 2

Request failed while connecting.

CantResolve = 3

Request failed while resolving.

ChunkedBodySizeMismatch = 1

Request failed due to a mismatch between the expected and actual chunked body size during transfer. Possible causes include network errors, server misconfiguration, or issues with chunked encoding.

ConnectionError = 4

Request failed due to connection (read/write) error.

DownloadFileCantOpen = 10

HTTPRequest couldn't open the download file.

DownloadFileWriteError = 11

HTTPRequest couldn't write to the download file.

NoResponse = 6

Request does not have a response (yet).

RedirectLimitReached = 12

Request reached its maximum redirect limit, see HttpRequest.MaxRedirects.

RequestFailed = 9

Request failed (currently unused).

Success = 0

Request successful.

Timeout = 13

Request failed due to a timeout. If you expect requests to take a long time, try increasing the value of HttpRequest.Timeout or setting it to 0.0 to remove the timeout completely.

TlsHandshakeError = 5

Request failed on TLS handshake.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.