Request

Interfacein globals@fastly/js-compute 4.0.0View source

Extends Body.

The Request class as specified by WHATWG

Note: Can only be used when processing requests, not during build-time initialization.

See also

Constructor

new Request(input: RequestInfo | URL, init?: RequestInit)

Parameters

input: RequestInfo | URL
init: RequestInitoptional

Properties

headers

Headersread-onlyView source

Returns a Headers object consisting of the headers associated with request.

method

stringread-onlyView source

Returns request's HTTP method, which is "GET" by default.

url

stringread-onlyView source

Returns the URL of request as a string.

backend

Backend | undefinedread-onlyView source

The backend this request was sent to, or undefined for the downstream request itself.

isCacheable

boolean | undefinedread-onlysince 3.30.0View source

Fastly-specific property - determines whether a request is cacheable per conservative RFC 9111 semantics. In particular, this function checks whether the request method is GET or HEAD, and considers requests with other methods uncacheable. Applications where it is safe to cache responses to other methods should consider using their own cacheability check instead of this function.

This function always returns undefined on hosts not supporting the HTTP Cache API (i.e. Viceroy)

Methods

clone(): Request

Creates a copy of the current Request object.

Returns

setCacheKey

View source
setCacheKey(key: string): void

Set a custom cache key for this request.

Parameters

key: string

The cache key to use.

Returns

void

setCacheOverride

View source
setCacheOverride(override: CacheOverride): void

Set the cache override for this request.

Parameters

override: CacheOverride

The cache override configuration to apply.

Returns

void

setManualFramingHeaders

View source
setManualFramingHeaders(manual: boolean): void

Controls how framing headers (Content-Length, Transfer-Encoding) are determined. In "manual" mode, any provided framing headers will be honored. In "automatic" mode (the default), they are set based on the body.

Parameters

manual: boolean

Whether to use manual mode for framing headers.

Returns

void