dreamworkAPI
Ctrl K
GitHub
libraryDocs / http / client

http.client

librarysharedmenusource

The HTTP client library, asynchronous requests over the engine http client (garrysmod, chttp or reqwest) with timeouts, cookies, redirects and caching.

Classes & types

Functions

http.client.deleteSends a DELETE request.
http.client.getSends a GET request.
http.client.headSends a HEAD request.
http.client.optionsSends an OPTIONS request.
http.client.patchSends a PATCH request.
http.client.postSends a POST request.
http.client.putSends a PUT request.
http.client.requestExecutes an asynchronous http request with the given options.

#http.client.delete

sharedmenuasyncsource
async function http.client.delete(url: http.RequestURL, headers?: http.RequestHeaders, timeout?: integer): http.Response

Sends a DELETE request.

Parameters
NameTypeDescription
urlhttp.RequestURLThe URL to send the request to.
headersoptionalhttp.RequestHeadersThe headers to send with the request.
timeoutoptionalintegerThe timeout in seconds.
Returns
TypeNameDescription
http.ResponseresponseThe response from the request.

#http.client.get

sharedmenuasyncsource
async function http.client.get(url: http.RequestURL, headers?: http.RequestHeaders, timeout?: integer): http.Response

Sends a GET request.

Parameters
NameTypeDescription
urlhttp.RequestURLThe URL to send the request to.
headersoptionalhttp.RequestHeadersThe headers to send with the request.
timeoutoptionalintegerThe timeout in seconds.
Returns
TypeNameDescription
http.ResponseresponseThe response from the request.

#http.client.head

sharedmenuasyncsource
async function http.client.head(url: http.RequestURL, headers?: http.RequestHeaders, timeout?: integer): http.Response

Sends a HEAD request.

Parameters
NameTypeDescription
urlhttp.RequestURLThe URL to send the request to.
headersoptionalhttp.RequestHeadersThe headers to send with the request.
timeoutoptionalintegerThe timeout in seconds.
Returns
TypeNameDescription
http.ResponseresponseThe response from the request.

#http.client.options

sharedmenuasyncsource
async function http.client.options(url: http.RequestURL, headers?: http.RequestHeaders, timeout?: integer): http.Response

Sends an OPTIONS request.

Parameters
NameTypeDescription
urlhttp.RequestURLThe URL to send the request to.
headersoptionalhttp.RequestHeadersThe headers to send with the request.
timeoutoptionalintegerThe timeout in seconds.
Returns
TypeNameDescription
http.ResponseresponseThe response from the request.

#http.client.patch

sharedmenuasyncsource
async function http.client.patch(url: http.RequestURL, parameters?: http.Parameters, headers?: http.RequestHeaders, timeout?: integer): http.Response

Sends a PATCH request.

Parameters
NameTypeDescription
urlhttp.RequestURLThe URL to send the request to.
parametersoptionalhttp.ParametersThe body to send with the request.
headersoptionalhttp.RequestHeadersThe headers to send with the request.
timeoutoptionalintegerThe timeout in seconds.
Returns
TypeNameDescription
http.ResponseresponseThe response from the request.

#http.client.post

sharedmenuasyncsource
async function http.client.post(url: http.RequestURL, parameters?: http.Parameters, headers?: http.RequestHeaders, timeout?: integer): http.Response

Sends a POST request.

Parameters
NameTypeDescription
urlhttp.RequestURLThe URL to send the request to.
parametersoptionalhttp.ParametersThe body to send with the request.
headersoptionalhttp.RequestHeadersThe headers to send with the request.
timeoutoptionalintegerThe timeout in seconds.
Returns
TypeNameDescription
http.ResponseresponseThe response from the request.

#http.client.put

sharedmenuasyncsource
async function http.client.put(url: http.RequestURL, parameters?: http.Parameters, headers?: http.RequestHeaders, timeout?: integer): http.Response

Sends a PUT request.

Parameters
NameTypeDescription
urlhttp.RequestURLThe URL to send the request to.
parametersoptionalhttp.ParametersThe body to send with the request.
headersoptionalhttp.RequestHeadersThe headers to send with the request.
timeoutoptionalintegerThe timeout in seconds.
Returns
TypeNameDescription
http.ResponseresponseThe response from the request.

#http.client.request

sharedmenuasyncsource
async function http.client.request(options: http.Request): http.Response

Executes an asynchronous http request with the given options.

Response header names are always lowercase.

Responses of cache requests are copies, so they can be changed freely.

With cookies and the chttp client, redirects are followed in Lua (up to max_redirects), so the cookies set by every redirect response are stored.

Parameters
NameTypeDescription
optionshttp.RequestThe request options.
Returns
TypeNameDescription
http.ResponsedataThe response.
See also
Generated from the dreamwork meta branch.