gossamer/request
Types
pub type RequestInit {
Method(http_method.HttpMethod)
Headers(headers.Headers)
Body(String)
BodyBytes(uint8_array.Uint8Array)
BodyBlob(blob.Blob)
BodyBuffer(array_buffer.ArrayBuffer)
BodyFormData(form_data.FormData)
BodyParams(url_search_params.URLSearchParams)
BodyStream(
readable_stream.ReadableStream(uint8_array.Uint8Array),
)
Cache(request_cache.RequestCache)
Credentials(request_credentials.RequestCredentials)
Integrity(String)
Keepalive(Bool)
Mode(request_mode.RequestMode)
Priority(request_priority.RequestPriority)
Redirect(request_redirect.RequestRedirect)
Referrer(String)
ReferrerPolicy(referrer_policy.ReferrerPolicy)
Signal(abort_signal.AbortSignal)
}
Constructors
-
Method(http_method.HttpMethod) -
Headers(headers.Headers) -
Body(String) -
BodyBytes(uint8_array.Uint8Array) -
BodyBlob(blob.Blob) -
BodyBuffer(array_buffer.ArrayBuffer) -
BodyFormData(form_data.FormData) -
BodyParams(url_search_params.URLSearchParams) -
BodyStream( readable_stream.ReadableStream(uint8_array.Uint8Array), ) -
Cache(request_cache.RequestCache) -
Credentials(request_credentials.RequestCredentials) -
Integrity(String) -
Keepalive(Bool) -
Mode(request_mode.RequestMode) -
Priority(request_priority.RequestPriority) -
Redirect(request_redirect.RequestRedirect) -
Referrer(String) -
ReferrerPolicy(referrer_policy.ReferrerPolicy) -
Signal(abort_signal.AbortSignal)
Values
pub fn array_buffer(
of request: Request,
) -> promise.Promise(
Result(array_buffer.ArrayBuffer, js_error.JsError),
)
Reads the request body as an ArrayBuffer. Returns an error if the
body has already been consumed or cannot be read.
pub fn blob(
of request: Request,
) -> promise.Promise(Result(blob.Blob, js_error.JsError))
Reads the request body as a Blob. Returns an error if the body has
already been consumed or cannot be read.
pub fn body(
of request: Request,
) -> Result(
readable_stream.ReadableStream(uint8_array.Uint8Array),
Nil,
)
The request body as a ReadableStream. Returns an error if the request
has no body.
pub fn bytes(
of request: Request,
) -> promise.Promise(
Result(uint8_array.Uint8Array, js_error.JsError),
)
Reads the request body as a Uint8Array. Returns an error if the body
has already been consumed or cannot be read.
pub fn cache(of request: Request) -> request_cache.RequestCache
Returns the cache mode associated with the request.
Note: Deno doesn’t expose this getter; on Deno this returns
request_cache.Default regardless of the cache mode set on the request.
See https://github.com/denoland/deno/issues/27763
pub fn clone(
request: Request,
) -> Result(Request, js_error.JsError)
Creates a clone of the request. Returns an error if the body has already been consumed or is locked to a reader.
pub fn credentials(
of request: Request,
) -> request_credentials.RequestCredentials
Returns the credentials mode associated with the request.
Note: Deno doesn’t expose this getter; on Deno this returns
request_credentials.SameOrigin regardless of the credentials mode
set on the request.
See https://github.com/denoland/deno/issues/27763
pub fn destination(
of request: Request,
) -> request_destination.RequestDestination
Returns the kind of resource requested by the request.
Note: Deno doesn’t expose this getter; on Deno this returns
request_destination.Empty.
See https://github.com/denoland/deno/issues/27763
pub fn form_data(
of request: Request,
) -> promise.Promise(Result(form_data.FormData, js_error.JsError))
Reads the request body as FormData. Returns an error if the body has
already been consumed or the Content-Type is not multipart/form-data
or application/x-www-form-urlencoded.
pub fn from_request(
existing: Request,
) -> Result(Request, js_error.JsError)
Creates a new Request by copying existing. The body is shared with
existing — after copying, existing’s body can no longer be
consumed. Returns an error if existing’s body is already disturbed
or locked.
pub fn from_request_with(
existing: Request,
with init: List(RequestInit),
) -> Result(Request, js_error.JsError)
Creates a new Request by copying existing and applying init
options. Returns an error if existing’s body is disturbed or locked,
or init contains an invalid method, header, or mode.
pub fn from_url(
url: url.URL,
) -> Result(Request, js_error.JsError)
Creates a new Request from url. Returns an error if url contains
credentials (the Fetch spec rejects user:pass@ URLs).
pub fn from_url_string(
url: String,
) -> Result(Request, js_error.JsError)
Creates a new Request from a URL given as a string. Returns an error
if url is not a valid URL or contains credentials (the Fetch spec
rejects user:pass@ URLs).
pub fn from_url_string_with(
url: String,
with init: List(RequestInit),
) -> Result(Request, js_error.JsError)
Creates a new Request from a URL given as a string, with init
options. Returns an error if url is not a valid URL or contains
credentials, or init contains an invalid method, header, or mode.
pub fn from_url_with(
url: url.URL,
with init: List(RequestInit),
) -> Result(Request, js_error.JsError)
Creates a new Request from url with init options. Returns an error
if url contains credentials, or init contains an invalid method,
header, or mode.
pub fn headers(of request: Request) -> headers.Headers
pub fn integrity(of request: Request) -> String
Returns the subresource integrity metadata of the request.
Note: Panics on Deno — the property is not exposed. See https://github.com/denoland/deno/issues/27763
pub fn is_body_used(request: Request) -> Bool
pub fn is_keepalive(request: Request) -> Bool
Returns whether the request can outlive the global in which it was created.
Note: Panics on Deno and Bun — the property is not exposed. See https://github.com/denoland/deno/issues/27763
pub fn json(
of request: Request,
) -> promise.Promise(Result(dynamic.Dynamic, js_error.JsError))
Reads the request body and parses it as JSON. Returns an error if the body has already been consumed or the content is not valid JSON.
pub fn method(of request: Request) -> http_method.HttpMethod
pub fn mode(of request: Request) -> request_mode.RequestMode
Returns the mode associated with the request.
Note: Deno doesn’t expose this getter; on Deno this returns
request_mode.Cors regardless of the mode set on the request.
See https://github.com/denoland/deno/issues/27763
pub fn priority(
of request: Request,
) -> request_priority.RequestPriority
Returns the priority hint associated with the request.
Note: Deno doesn’t expose this getter; on Deno this returns
request_priority.Auto regardless of the priority set on the
request.
See https://github.com/denoland/deno/issues/27763
pub fn redirect(
of request: Request,
) -> request_redirect.RequestRedirect
pub fn referrer(of request: Request) -> String
Returns the referrer of the request.
Note: Panics on Deno — the property is not exposed. See https://github.com/denoland/deno/issues/27763
pub fn referrer_policy(
of request: Request,
) -> referrer_policy.ReferrerPolicy
Returns the referrer policy associated with the request.
Note: Deno doesn’t expose this getter; on Deno this returns
referrer_policy.StrictOriginWhenCrossOrigin regardless of the policy
set on the request.
See https://github.com/denoland/deno/issues/27763
pub fn signal(of request: Request) -> abort_signal.AbortSignal
pub fn text(
of request: Request,
) -> promise.Promise(Result(String, js_error.JsError))
Reads the request body as text. Returns an error if the body has already been consumed or cannot be read.