public static abstract sealed class Sandbox.Http
Lets your game make async HTTP requests.
Related Guides
Broader workflow and conceptual references connected to this API.
s&box provides a static Http class, this lets you easily create asynchronous HTTP requests of different methods (GET, POST, DELETE, etc…) providing JSON content and parsing JSON responses.
By default, async tasks in s&box run on the main thread. They operate a lot like coroutines, making them the perfect replacement.
If you are using HTTP requests or WebSockets in your game, you can use Auth Tokens to validate that the requests were sent from a valid Steam user in a s&box game session. This is useful if you want to tie data to a specific Steam account, or prevent botting.
Methods
Showing 8 methods
public static System.Net.Http.HttpContent CreateJsonContent(T target)
Creates a new `System.Net.Http.HttpContent` instance containing the specified object serialized to JSON.
public static bool IsAllowed(System.Uri uri)
Check if the given Uri matches the following requirements: 1. Scheme is https/http or wss/ws 2. If it's localhost, only allow ports 80/443/8080/8443 3. Not an ip address
Parameters
uri: The Uri to check.
Returns
True if the Uri can be accessed, false if the Uri will be blocked.
public static bool IsHeaderAllowed(string header)
Checks if a given header is allowed to be set.
Parameters
header: The header name to check.
Returns
True 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)
Parameters
method: Default: GETcontent: Default: nullheaders: Default: nullcancellationToken: Default: null
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)
Parameters
method: Default: GETcontent: Default: nullheaders: Default: nullcancellationToken: Default: null
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)
Parameters
method: Default: GETcontent: Default: nullheaders: Default: nullcancellationToken: Default: null
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)
Parameters
method: Default: GETcontent: Default: nullheaders: Default: nullcancellationToken: Default: null
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)
Parameters
method: Default: GETcontent: Default: nullheaders: Default: nullcancellationToken: Default: null
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox |
| Type | class |
| Assembly | Sandbox.Engine |
| Doc ID | T:Sandbox.Http |