Request
object by using any of the following methods:Request
object for the Fetch API by using the Request
constructor.FetchEvent
object event.request to obtain a Request
object.const request = new Request(input: string | Request, init?: RequestInit)
Parameter name | Type | Required | Description |
input | string | Request | Yes | A URL string or a Request object. |
options | No | Initial configuration items of the Request object. |
Name | Type | Required | Default value | Description |
method | string | No | GET | Request method. Examples: GET and POST . |
headers | No | - | Headers that you want to add to the request. | |
body | No | - | Request body. | |
redirect | string | No | follow | Redirect mode. Valid values: manual , error , and follow . |
maxFollow | number | No | 12 | The maximum number of redirects allowed. |
version | string | No | HTTP/1.1 | HTTP version. Valid values: HTTP/1.0 , HTTP/1.1 , and HTTP/2.0 . |
copyHeaders | boolean | No | - | Specifies whether to copy the headers of the Request object. This parameter is not in the Web API specifications. |
eo | No | - | Specifies the behavior that Edge Functions adopts in processing the request. This parameter is not in the Web API specifications. |
Parameter name | Type | Required | Description |
resolveOverride | string | No | Overrides the original domain name resolution for the fetch request. You can specify a domain name or IP address that meets the following requirements: The IP address cannot contain a scheme or port number. For an IPv6 address, you do not need to enclose it in a pair of square brackets. |
Image | No | Image processing configurations |
Parameter name | Type | Required | Description |
format | string | No | Convert an image into a specified format. Valid values: jpg , gif , png , bmp , webp , avif , jp2 , jxr , heif . |
long | number | No | Specify the length of the long side, and automatically scale the short side (if not specified) |
short | number | No | Specify the length of the short side, and automatically scale the long side (if not specified) |
width | number | No | Specify the width, and automatically scale the height (if not specified) |
height | number | No | Specify the height, and automatically scale the width (if not specified) |
// request.bodyreadonly body: ReadableStream;
// request.bodyUsedreadonly bodyUsed: boolean;
// request.headersreadonly headers: Headers;
// request.methodreadonly method: string;
GET
.// request.redirectreadonly redirect: string;
follow
, error
, and manual
. Default value: manual
.// request.maxFollowreadonly maxFollow: number;
// request.urlreadonly url: string;
// request.versionreadonly version: string;
// request.versionreadonly eo: IncomingRequestEoProperties;
Name | Type | Description | Example |
geo | Location of the client who initiates the request. | - |
Name | Type | Description | Example |
asn | number | 132203 | |
countryName | string | Country name | Singapore |
countryCodeAlpha2 | string | ISO-3611 alpha2 code of the country | SG |
countryCodeAlpha3 | string | ISO-3611 alpha3 code of the country | SGP |
countryCodeNumeric | string | ISO-3611 numeric code of the country. | 702 |
regionName | string | Region name | - |
regionCode | string | Region code | AA-AA |
cityName | string | City name | singapore |
latitude | number | Latitude | 1.29027 |
longitude | number | Longitude | 103.851959 |
HTTP body
is capped at 1 MB. If the threshold is exceeded, an OverSize exception is returned. In this case, we recommend that you use request.body to read the request body in streaming mode. For more information, see ReadableStream.request.arrayBuffer(): Promise<ArrayBuffer>;
request.blob(): Promise<Blob>;
request.clone(copyHeaders?: boolean): Request;
Parameter name | Type | Required | Description |
copyHeaders | boolean | No | Specifies whether to copy the request headers of the original object. Default value: false . Valid values:true Copy the request headers of the original object. false Reference the request headers of the original object. |
request.json(): Promise<object>;
json
.request.text(): Promise<string>;
request.formData(): Promise<FormData>;
Parameter name | Type | Required | Description |
cookies | No | A new Cookies object. |
async function handleRequest() {const request = new Request('https://www.tencentcloud.com/');const response = await fetch(request);return response;}addEventListener('fetch', (event) => {event.respondWith(handleRequest());});
Was this page helpful?