API Reference
Classes
Http
The Http class is used for calling different HTTP methods and requesting and sending information online, as well as testing public accessible resources.
Static Functions
Name | Description |
---|---|
delete | Executes a DELETE request to a specified URL and provides a formatted response. |
fetch | Executes a HTTP request to a specified URL and provides a formatted response. |
get | Executes a GET request to a specified URL and provides a formatted response. |
patch | Executes a PATCH request to a specified URL and provides a formatted response. |
post | Executes a POST request to a specified URL and provides a formatted response. |
put | Executes a PUT request to a specified URL and provides a formatted response. |
delete
bring http;
inflight http.delete(url: str, options?: RequestOptions);
Executes a DELETE request to a specified URL and provides a formatted response.
url
Required
- Type: str
The target URL for the DELETE request.
options
Optional
- Type: RequestOptions
Optional parameters for customizing the DELETE request.
fetch
bring http;
inflight http.fetch(url: str, options?: RequestOptions);
Executes a HTTP request to a specified URL and provides a formatted response.
This method allows various HTTP methods based on the provided options.
url
Required
- Type: str
The target URL for the request.
options
Optional
- Type: RequestOptions
Optional parameters for customizing the HTTP request.
get
bring http;
inflight http.get(url: str, options?: RequestOptions);
Executes a GET request to a specified URL and provides a formatted response.
url
Required
- Type: str
The target URL for the GET request.
options
Optional
- Type: RequestOptions
Optional parameters for customizing the GET request.
patch
bring http;
inflight http.patch(url: str, options?: RequestOptions);
Executes a PATCH request to a specified URL and provides a formatted response.
url
Required
- Type: str
The target URL for the PATCH request.
options
Optional
- Type: RequestOptions
Optional parameters for customizing the PATCH request.
post
bring http;
inflight http.post(url: str, options?: RequestOptions);
Executes a POST request to a specified URL and provides a formatted response.
url
Required
- Type: str
The target URL for the POST request.
options
Optional
- Type: RequestOptions
Optional parameters for customizing the POST request.
put
bring http;
inflight http.put(url: str, options?: RequestOptions);
Executes a PUT request to a specified URL and provides a formatted response.
url
Required
- Type: str
The target URL for the PUT request.
options
Optional
- Type: RequestOptions
ptional parameters for customizing the PUT request.
Structs
RequestOptions
An object containing any custom settings that you want to apply to the request.
Initializer
bring http;
let RequestOptions = http.RequestOptions{ ... };
Properties
Name | Type | Description |
---|---|---|
body | str | Any body that you want to add to your request. |
cache | RequestCache | The cache mode you want to use for the request. |
headers | MutMap<str> | Any headers you want to add to your request. |
method | HttpMethod | The request method, e.g., GET, POST. The default is GET. |
redirect | RequestRedirect | The redirect mode to use: follow, error. |
referrer | str | A string specifying "no-referrer", client, or a URL. |
body
Optional
body: str;
- Type: str
Any body that you want to add to your request.
Note that a request using the GET or HEAD method cannot have a body.
cache
Optional
cache: RequestCache;
- Type: RequestCache
The cache mode you want to use for the request.
headers
Optional
headers: MutMap<str>;
- Type: MutMap<str>
Any headers you want to add to your request.
method
Optional
method: HttpMethod;
- Type: HttpMethod
- Default: GET
The request method, e.g., GET, POST. The default is GET.
redirect
Optional
redirect: RequestRedirect;
- Type: RequestRedirect
- Default: follow
The redirect mode to use: follow, error.
The default is follow.
referrer
Optional
referrer: str;
- Type: str
- Default: about:client
A string specifying "no-referrer", client, or a URL.
The default is "about:client".
Response
The response to a HTTP request.
Initializer
bring http;
let Response = http.Response{ ... };
Properties
Name | Type | Description |
---|---|---|
headers | MutMap<str> | The map of header information associated with the response. |
ok | bool | A boolean indicating whether the response was successful (status in the range 200 – 299) or not. |
status | num | The status code of the response. |
url | str | The URL of the response. |
body | str | A string representation of the body contents. |
headers
Required
headers: MutMap<str>;
- Type: MutMap<str>
The map of header information associated with the response.
ok
Required
ok: bool;
- Type: bool
A boolean indicating whether the response was successful (status in the range 200 – 299) or not.
status
Required
status: num;
- Type: num
The status code of the response.
(This will be 200 for a success).
url
Required
url: str;
- Type: str
The URL of the response.
body
Optional
body: str;
- Type: str
A string representation of the body contents.
Enums
HttpMethod
The request's method.
Members
Name | Description |
---|---|
GET | GET. |
PUT | PUT. |
DELETE | DELETE. |
PATCH | PATCH. |
POST | POST. |
OPTIONS | OPTIONS. |
HEAD | HEAD. |
GET
GET.
PUT
PUT.
DELETE
DELETE.
PATCH
PATCH.
POST
POST.
OPTIONS
OPTIONS.
HEAD
HEAD.
RequestCache
The cache mode of the request.
It controls how a request will interact with the system's HTTP cache.
Members
Name | Description |
---|---|
DEFAULT | The runtime environment looks for a matching request in its HTTP cache. |
NO_STORE | The runtime environment fetches the resource from the remote server without first looking in the cache, and will not update the cache with the downloaded resource. |
RELOAD | The runtime environment fetches the resource from the remote server without first looking in the cache, but then will update the cache with the downloaded resource. |
NO_CACHE | The runtime environment looks for a matching request in its HTTP cache. |
FORCE_CACHE | The runtime environment looks for a matching request in its HTTP cache. |
DEFAULT
The runtime environment looks for a matching request in its HTTP cache.
- If there is a match and it is fresh, it will be returned from the cache.
- If there is a match but it is stale, the runtime environment will make a conditional request to the remote server.
- If the server indicates that the resource has not changed, it will be returned from the cache.
- Otherwise the resource will be downloaded from the server and the cache will be updated.
- If there is no match, the runtime environment will make a normal request, and will update the cache with the downloaded resource.
NO_STORE
The runtime environment fetches the resource from the remote server without first looking in the cache, and will not update the cache with the downloaded resource.
RELOAD
The runtime environment fetches the resource from the remote server without first looking in the cache, but then will update the cache with the downloaded resource.
NO_CACHE
The runtime environment looks for a matching request in its HTTP cache.
- If there is a match, fresh or stale, the runtime environment will make a conditional request to the remote server.
- If the server indicates that the resource has not changed, it will be returned from the cache. Otherwise the resource will be downloaded from the server and the cache will be updated.
- If there is no match, the runtime environment will make a normal request, and will update the cache with the downloaded resource.
FORCE_CACHE
The runtime environment looks for a matching request in its HTTP cache.
- If there is a match, fresh or stale, it will be returned from the cache.
- If there is no match, the runtime environment will make a normal request, and will update the cache with the downloaded resource.
RequestRedirect
The redirect read-only property that contains the mode for how redirects are handled.
Members
Name | Description |
---|---|
FOLLOW | Follow all redirects incurred when fetching a resource. |
ERROR | Return a network error when a request is met with a redirect. |
FOLLOW
Follow all redirects incurred when fetching a resource.
ERROR
Return a network error when a request is met with a redirect.