API ReferenceSandbox
Httpclass
Lets your game make async HTTP requests.
object→Http
Methods8
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.
| Parameter | Type | Description |
|---|---|---|
| target | T | — |
Returns:
HttpContent—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
| Parameter | Type | Description |
|---|---|---|
| uri | Uri | The Uri to check. |
Returns:
boolTrue 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.
| Parameter | Type | Description |
|---|---|---|
| header | string | The 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)
| Parameter | Type | Description |
|---|---|---|
| requestUri | string | — |
| method = GET | string | — |
| content = null | HttpContent | — |
| headers = null | Dictionary<string,string> | — |
| cancellationToken = null | CancellationToken | — |
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)
| Parameter | Type | Description |
|---|---|---|
| requestUri | string | — |
| method = GET | string | — |
| content = null | HttpContent | — |
| headers = null | Dictionary<string,string> | — |
| cancellationToken = null | CancellationToken | — |
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)
| Parameter | Type | Description |
|---|---|---|
| requestUri | string | — |
| method = GET | string | — |
| content = null | HttpContent | — |
| headers = null | Dictionary<string,string> | — |
| cancellationToken = null | CancellationToken | — |
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)
| Parameter | Type | Description |
|---|---|---|
| requestUri | string | — |
| method = GET | string | — |
| content = null | HttpContent | — |
| headers = null | Dictionary<string,string> | — |
| cancellationToken = null | CancellationToken | — |
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)
| Parameter | Type | Description |
|---|---|---|
| requestUri | string | — |
| method = GET | string | — |
| content = null | HttpContent | — |
| headers = null | Dictionary<string,string> | — |
| cancellationToken = null | CancellationToken | — |
Returns:
Task<string>—No results match this filter.