function acceptsEncodings
acceptsEncodings(request: Request): string[]Returns an array of content encodings accepted by the request, in order of
preference. If there are no encoding supplied in the request, then ["*"]
is returned, implying any encoding is accepted.
Examples
Example 1
Example 1
import { acceptsEncodings } from "@std/http/negotiation"; const req = new Request("https://example.com/", { headers: { "accept-encoding": "deflate, gzip;q=1.0, *;q=0.5" }, }); acceptsEncodings(req); // ["deflate", "gzip", "*"]
Parameters
request: RequestReturn Type
string[]acceptsEncodings(): string | undefinedFor a given set of content encodings, return the best match accepted in the
request. If no content encodings match, then the function returns
undefined.
NOTE: You should always supply identity as one of the encodings
to ensure that there is a match when the Accept-Encoding header is part
of the request.
Examples
Example 1
Example 1
import { acceptsEncodings } from "@std/http/negotiation"; const req = new Request("https://example.com/", { headers: { "accept-encoding": "deflate, gzip;q=1.0, *;q=0.5" }, }); acceptsEncodings(req, "gzip", "identity"); // "gzip"
Parameters
Return Type
string | undefined