Interface WebRequest
baseURL: string;
clientIp: string;
clientWebServer: number;
headers: Headers;
localPath: string;
method:
| "POST"
| "GET"
| "DELETE"
| "HEAD"
| "PUT"
| "OPTIONS"
| "PATCH"
| "TRACE";
url: string;
blob(): Promise<Blob>;
encodeForTransfer(): {
transferList: Transferable[];
value: WebRequestTransferData;
};
getAllCookies(): Record<string, string>;
getCookie(name: string): string | null;
getDebugSettings(): { flags: DebugFlags };
getOriginURL(pathname: string): string | null;
json(): Promise<unknown>;
text(): Promise<string>;
}
Hierarchy
- SupportedRequestSubset
- WebRequest
Index
Properties
Readonlybase URL
Readonlyclient Ip
Readonlyclient Web Server
Readonlyheaders
Readonlylocal Path
Readonlymethod
| "POST"
| "GET"
| "DELETE"
| "HEAD"
| "PUT"
| "OPTIONS"
| "PATCH"
| "TRACE"
The method read-only property of the Request interface contains the request's method (GET, POST, etc.)
Readonlyurl
The url read-only property of the Request interface contains the URL of the request.
Methods
blob
Returns Promise<Blob>
encode For Transfer
Returns { transferList: Transferable[]; value: WebRequestTransferData }
get All Cookies
This returns all the cookies originally sent by the client. They are not decrypted.
Returns Record<string, string>
- The cookies
get Cookie
This returns a single cookie originally sent by the client. It is not decrypted.
Parameters
- name: string
The name of the cookie
Returns string | null
- The cookie value or null if not found
- name: string
get Debug Settings
The return value only contains the trusted flags set in this request (from both cookies and URL - either signed or part of the subset of flags that do not need a signature) You should normally use debugFlags from @webhare/env - request specific flags will be merged into this set for the current code context.
Returns { flags: DebugFlags }
get Origin URL
Calculate origin of a request using unforgable headers (Origin or Referer)
Parameters
- pathname: string
Local path as specified by app. Browsers should pass
location.pathname. The URL may or may not start with a slash but may not be a full url. Leave empty to get just a URL to the root
Returns string | null
The pathname rebased to the actual origin URL or null if we couldn't safely determine it
- pathname: string
json
Returns Promise<unknown>
text
Returns Promise<string>
The
headersread-only property of the Request interface contains the Headers object associated with the request.MDN Reference