Httpclass

Lets your game make async HTTP requests.

object→Http
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public static abstract sealed class Sandbox.Http

Methods8

Showing 8 methods

public static System.Net.Http.HttpContent CreateJsonContent(T target)PUBLICSTATIC

Creates a new `System.Net.Http.HttpContent` instance containing the specified object serialized to JSON.

ParameterTypeDescription
targetT—
Returns:HttpContent—

public static bool IsAllowed(System.Uri uri)PUBLICSTATIC

Check if the given Uri matches the following requirements: 1. Scheme is https/http or wss/ws 2. If it resolves to loopback, only allow ports 80/443/8080/8443 3. Not an ip address 4. Doesn't resolve to a private range

ParameterTypeDescription
uriUriThe Uri to check.
Returns:boolTrue if the Uri can be accessed, false if the Uri will be blocked.

public static bool IsHeaderAllowed(string header)PUBLICSTATIC

Checks if a given header is allowed to be set.

ParameterTypeDescription
headerstringThe header name to check.
Returns:boolTrue if the header is allowed to be set.

public static System.Threading.Tasks.Task`1<System.Net.Http.HttpResponseMessage> RequestAsync(string requestUri, string method = GET, System.Net.Http.HttpContent content = null, System.Collections.Generic.Dictionary`2<string,string> headers = null, System.Threading.CancellationToken cancellationToken = null)PUBLICSTATIC

ParameterTypeDescription
requestUristring—
method = GETstring—
content = nullHttpContent—
headers = nullDictionary<string,string>—
cancellationToken = nullCancellationToken—
Returns:Task<HttpResponseMessage>—

public static System.Threading.Tasks.Task`1<byte[]> RequestBytesAsync(string requestUri, string method = GET, System.Net.Http.HttpContent content = null, System.Collections.Generic.Dictionary`2<string,string> headers = null, System.Threading.CancellationToken cancellationToken = null)PUBLICSTATIC

ParameterTypeDescription
requestUristring—
method = GETstring—
content = nullHttpContent—
headers = nullDictionary<string,string>—
cancellationToken = nullCancellationToken—
Returns:Task<byte[]>—

public static System.Threading.Tasks.Task`1<T> RequestJsonAsync(string requestUri, string method = GET, System.Net.Http.HttpContent content = null, System.Collections.Generic.Dictionary`2<string,string> headers = null, System.Threading.CancellationToken cancellationToken = null)PUBLICSTATIC

ParameterTypeDescription
requestUristring—
method = GETstring—
content = nullHttpContent—
headers = nullDictionary<string,string>—
cancellationToken = nullCancellationToken—
Returns:Task<T>—

public static System.Threading.Tasks.Task`1<System.IO.Stream> RequestStreamAsync(string requestUri, string method = GET, System.Net.Http.HttpContent content = null, System.Collections.Generic.Dictionary`2<string,string> headers = null, System.Threading.CancellationToken cancellationToken = null)PUBLICSTATIC

ParameterTypeDescription
requestUristring—
method = GETstring—
content = nullHttpContent—
headers = nullDictionary<string,string>—
cancellationToken = nullCancellationToken—
Returns:Task<Stream>—

public static System.Threading.Tasks.Task`1<string> RequestStringAsync(string requestUri, string method = GET, System.Net.Http.HttpContent content = null, System.Collections.Generic.Dictionary`2<string,string> headers = null, System.Threading.CancellationToken cancellationToken = null)PUBLICSTATIC

ParameterTypeDescription
requestUristring—
method = GETstring—
content = nullHttpContent—
headers = nullDictionary<string,string>—
cancellationToken = nullCancellationToken—
Returns:Task<string>—

On this page

Methodspublic static System.Net.Http.HttpContent CreateJsonContent(T target)public static System.Boolean IsAllowed(System.Uri uri)public static System.Boolean IsHeaderAllowed(System.String header)public static System.Threading.Tasks.Task`1<System.Net.Http.HttpResponseMessage> RequestAsync(System.String requestUri, System.String method = GET, System.Net.Http.HttpContent content = null, System.Collections.Generic.Dictionary`2<System.String,System.String> headers = null, System.Threading.CancellationToken cancellationToken = null)public static System.Threading.Tasks.Task`1<System.Byte[]> RequestBytesAsync(System.String requestUri, System.String method = GET, System.Net.Http.HttpContent content = null, System.Collections.Generic.Dictionary`2<System.String,System.String> headers = null, System.Threading.CancellationToken cancellationToken = null)public static System.Threading.Tasks.Task`1<T> RequestJsonAsync(System.String requestUri, System.String method = GET, System.Net.Http.HttpContent content = null, System.Collections.Generic.Dictionary`2<System.String,System.String> headers = null, System.Threading.CancellationToken cancellationToken = null)public static System.Threading.Tasks.Task`1<System.IO.Stream> RequestStreamAsync(System.String requestUri, System.String method = GET, System.Net.Http.HttpContent content = null, System.Collections.Generic.Dictionary`2<System.String,System.String> headers = null, System.Threading.CancellationToken cancellationToken = null)public static System.Threading.Tasks.Task`1<System.String> RequestStringAsync(System.String requestUri, System.String method = GET, System.Net.Http.HttpContent content = null, System.Collections.Generic.Dictionary`2<System.String,System.String> headers = null, System.Threading.CancellationToken cancellationToken = null)Metadata