Skip to main content

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

NameDescription
deleteExecutes a DELETE request to a specified URL and provides a formatted response.
fetchExecutes a HTTP request to a specified URL and provides a formatted response.
getExecutes a GET request to a specified URL and provides a formatted response.
patchExecutes a PATCH request to a specified URL and provides a formatted response.
postExecutes a POST request to a specified URL and provides a formatted response.
putExecutes 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.

urlRequired
  • Type: str

The target URL for the DELETE request.


optionsOptional

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.

urlRequired
  • Type: str

The target URL for the request.


optionsOptional

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.

urlRequired
  • Type: str

The target URL for the GET request.


optionsOptional

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.

urlRequired
  • Type: str

The target URL for the PATCH request.


optionsOptional

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.

urlRequired
  • Type: str

The target URL for the POST request.


optionsOptional

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.

urlRequired
  • Type: str

The target URL for the PUT request.


optionsOptional

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

NameTypeDescription
bodystrAny body that you want to add to your request.
cacheRequestCacheThe cache mode you want to use for the request.
headersMutMap<str>Any headers you want to add to your request.
methodHttpMethodThe request method, e.g., GET, POST. The default is GET.
redirectRequestRedirectThe redirect mode to use: follow, error.
referrerstrA string specifying "no-referrer", client, or a URL.

bodyOptional
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.


cacheOptional
cache: RequestCache;

The cache mode you want to use for the request.


headersOptional
headers: MutMap<str>;
  • Type: MutMap<str>

Any headers you want to add to your request.


methodOptional
method: HttpMethod;

The request method, e.g., GET, POST. The default is GET.


redirectOptional
redirect: RequestRedirect;

The redirect mode to use: follow, error.

The default is follow.


referrerOptional
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

NameTypeDescription
headersMutMap<str>The map of header information associated with the response.
okboolA boolean indicating whether the response was successful (status in the range 200 – 299) or not.
statusnumThe status code of the response.
urlstrThe URL of the response.
bodystrA string representation of the body contents.

headersRequired
headers: MutMap<str>;
  • Type: MutMap<str>

The map of header information associated with the response.


okRequired
ok: bool;
  • Type: bool

A boolean indicating whether the response was successful (status in the range 200 – 299) or not.


statusRequired
status: num;
  • Type: num

The status code of the response.

(This will be 200 for a success).


urlRequired
url: str;
  • Type: str

The URL of the response.


bodyOptional
body: str;
  • Type: str

A string representation of the body contents.


Enums

HttpMethod

The request's method.

Members

NameDescription
GETGET.
PUTPUT.
DELETEDELETE.
PATCHPATCH.
POSTPOST.
OPTIONSOPTIONS.
HEADHEAD.

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

NameDescription
DEFAULTThe runtime environment looks for a matching request in its HTTP cache.
NO_STOREThe 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.
RELOADThe 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_CACHEThe runtime environment looks for a matching request in its HTTP cache.
FORCE_CACHEThe 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

NameDescription
FOLLOWFollow all redirects incurred when fetching a resource.
ERRORReturn 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.