tencent cloud

DokumentasiTencent Cloud EdgeOne

Request

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-11-04 10:29:57
Diterjemahkan oleh AI
Request represents an HTTP request object and is designed based on the Web APIs standard Request.
Note
In edge functions, you can obtain the Request object in two ways:
Use the Request constructor to create a Request object for Fetch API operations.
Use the FetchEvent object event.request to obtain the Request object for the current request.

Constructor

new Request(input: string | Request, initOptions?: RequestInit): Request

Parameters

Parameter Name
Type
Required
Description
input
string | Request
Yes
URL string or Request object.
initOptions
No
Configuration items for initializing the Request object.

RequestInit

Initialize the property value options for the Request object.
Property Name
Type
Required
Default Value
Description
method
string
No
GET
Request method (GET, POST, and so on).
headers
No
-
Request header information.
body
string |Blob | ArrayBuffer | ArrayBufferView |ReadableStream
No
-
Request body.
redirect
string
No
follow
Redirect policy. Supported values: manual, error, and follow.
maxFollow
number
No
12
Maximum number of redirects.
version
string
No
HTTP/1.1
HTTP version. Supported values: HTTP/1.0, HTTP/1.1, and HTTP/2.0.
copyHeaders
boolean
No
-
Non-standard Web APIs option. Indicates whether to copy the headers of the incoming Request object.
eo
No
-
Non-standard Web APIs option. Controls the behavior of edge functions when they process this request.

RequestInitEoProperties

A non-standard Web APIs option that controls how edge functions handle the request.
Parameter Name
Type
Required
Description
resolveOverride
string
No
Overrides the original domain resolution for fetch requests and supports specifying a domain name or IP address. For more information, see below:
The IP address is not allowed to contain a scheme or port number.
IPv6 addresses do not need to be enclosed in square brackets.
Note: This field does not take effect when fetch meets the condition of accessing the EdgeOne node cache or origin-pull.
image
No
Image processing parameter configuration item.
cacheKey
string
No
Custom cache key used for cache read and write operations of the Cache API: after it is specified, relevant cache operations use an independent edge function cache that is isolated from the EdgeOne site cache. For details on how to specify it and the rules for it to take effect, see Cache Space.
timeoutSetting
No
Used to configure the timeout setting for fetch requests.
tls
No
Used to configure TLS-related settings for fetch requests.
Note: This field takes effect only when fetch does not meet the condition of accessing the EdgeOne node cache or origin-pull.

RequestInitEoTimeoutSettingProperties

The fetch timeout option.
Note:
If fetch times out while establishing a connection, a net_exception_connect_timeout exception is thrown. If fetch times out while reading a response or sending a request, a net_exception_timeout exception is thrown.
Parameter Name
Type
Required
Default Value
Description
connectTimeout
number
No
3000
Timeout for establishing a connection, in milliseconds, with a maximum of 300000.
readTimeout
number
No
3000
Timeout for reading a response, in milliseconds, with a maximum of 300000.
writeTimeout
number
No
15000
Timeout for sending a request, in milliseconds, with a maximum of 300000.

RequestInitEoTlsProperties

The fetch TLS-related options take effect only when fetch does not meet the conditions for accessing the EdgeOne node cache or origin-pull.
Parameter Name
Type
Required
Description
cert
string
No
Client certificate in PEM format.
key
string
No
Private key paired with the client certificate, in PEM format.
ca
string
No
CA certificate corresponding to the origin server certificate, in PEM format.

Instance Properties

body

// request.body
readonly body: ReadableStream;
The request body. For more information, see ReadableStream.

bodyUsed

// request.bodyUsed
readonly bodyUsed: boolean;
Indicates whether the request body has been read.

headers

// request.headers
readonly headers: Headers;
The request headers. For more information, see Headers.

method

// request.method
readonly method: string;
The request method. The default value is GET.

redirect

// request.redirect
readonly redirect: string;
The request redirect policy. Valid values: follow, error, manual. The default value is follow.
Note:
The default redirect policy follow may cause issues in some scenarios. For more information, see Redirect.

maxFollow

// request.maxFollow
readonly maxFollow: number;
The maximum number of redirects for a request.

url

// request.url
readonly url: string;
Request URL.

version

// request.version
readonly version: string;
The HTTP protocol version used by the request.

eo

// request.eo
readonly eo: IncomingRequestEoProperties;
Additional information related to the current request provided by edge functions. For more information, see IncomingRequestEoProperties.

IncomingRequestEoProperties

The client request event.request object contains the eo property. The details are as follows:
Property Name
Type
Description
Example Value
geo
Describes the location information of the client request.
-
tls
Describes the TLS information of the client request.
This field has a value only when the client request is a TLS request.
-
clientIp
string
Client request IP address.
192.168.1.1
clientPort
number
Client request port.
-
httpProtocol
string
HTTP protocol version of the client request.
HTTP/1.1
uuid
string
Unique identifier of the request, functioning the same as EO-LOG-UUID.
-

GeoProperties

Describes the location information of the client request.
Property Name
Type
Description
Example Value
asn
number
ASN.
132203
continent
string
Continent name.
Asia
countryName
string
Country name.
Singapore
countryCodeAlpha2
string
ISO-3166 alpha2 code of the country.
SG
countryCodeAlpha3
string
ISO-3166 alpha3 code of the country.
SGP
countryCodeNumeric
string
ISO-3166 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

TlsProperties

Describes the TLS information of the client request.
Property Name
Type
Description
Example Value
version
string
TLS version requested by the client.
TLS1.3
cipher
string
TLS cipher suite requested by the client.
TLS_AES_256_GCM_SHA384
clientAuth
Describes the information related to the client certificate.
This field has a value only when the client carries a certificate request.
-
clientCiphersSha1
string
SHA-1 hash value (Base64-encoded) of the cipher_suites list sent by the client in ClientHello during the TLS handshake, encoded in big-endian format.
-
clientExtensionsSha1
string
SHA-1 hash value (Base64-encoded) of the extensions list sent by the client in ClientHello during the TLS handshake, encoded in big-endian format.
-
clientExtensionsSha1Le
string
SHA-1 hash value (Base64-encoded) of the extensions list sent by the client in ClientHello during the TLS handshake, encoded in little-endian format.
-
clientHelloLength
string
Byte length of the ClientHello message sent by the client during the TLS handshake.
-
clientRandom
string
32-byte random field (Base64-encoded) sent by the client in ClientHello during the TLS handshake.
-

TlsClientAuthProperties

Describes the information about the client certificate.
Property Name
Type
Description
Example Value
certPresented
string
Whether the client actually sent the certificate.
The value is always "1".
1
certVerified
string
Verification result of the client certificate.
There are only two values: "SUCCESS" (successful verification) and "FAILED" (failed verification).
SUCCESS
certIssuerDN
string
Unique Distinguished Name (DN) of the client certificate issuer, in RFC 4514 format.
-
certSubjectDN
string
Unique Distinguished Name (DN) of the client certificate subject, in RFC 4514 format.
-
certIssuerDNRFC2253
string
Unique Distinguished Name (DN) of the client certificate issuer, in RFC 2253 format.
-
certSubjectDNRFC2253
string
Unique Distinguished Name (DN) of the client certificate subject, in RFC 2253 format.
-
certIssuerDNLegacy
string
Unique Distinguished Name (DN) of the client certificate issuer, in OpenSSL legacy format.
-
certSubjectDNLegacy
string
Unique Distinguished Name (DN) of the client certificate subject, in OpenSSL legacy format.
-
certSerial
string
Serial number of the client certificate.
-
certIssuerSerial
string
Serial number of the CA certificate that issued this client certificate (the serialNumber field in the issuer certificate).
-
certSKI
string
Subject Key Identifier (SKI) of the client certificate.
-
certIssuerSKI
string
Subject Key Identifier (SKI) of the client certificate issuer.
-
certFingerprintSHA1
string
SHA-1 fingerprint of the client certificate.
-
certFingerprintSHA256
string
SHA-256 fingerprint of the client certificate.
-
certNotBefore
string
Time when the client certificate takes effect, in OpenSSL conventional print format (not ISO 8601).
Jan 01 00:00:00 2026 GMT
certNotAfter
string
Time when the client certificate expires, in OpenSSL conventional print format (not ISO 8601).
Jan 01 00:00:00 2026 GMT
certPublicKeyAlgorithm
string
Public key algorithm type of the client certificate, with values "RSA", "DSA", "EC", "ED25519", "SM2", and "Other".
-
certPublicKeyAlgorithmLongName
string
Long name of the public key algorithm of the client certificate, passed through from OpenSSL.
-
certPublicKeyAlgorithmShortName
string
Short name of the public key algorithm of the client certificate, passed through from OpenSSL.
-

Instance Methods

Note
The method for obtaining the request body accepts an HTTP body of up to 1 MB. If the size is exceeded, an OverSize exception is thrown. In this case, it is recommended to use request.body for streaming reads. For more information, see ReadableStream.

arrayBuffer

request.arrayBuffer(): Promise<ArrayBuffer>;
Obtains the request body and parses it as an ArrayBuffer.

blob

request.blob(): Promise<Blob>;
Obtains the request body and parses it as a Blob.

clone

request.clone(copyHeaders?: boolean): Request;
Create a copy of the request object.

Parameters

Parameter Name
Type
Required
Description
copyHeaders
boolean
No
Enables copying request headers. The default value is false. The values are described as follows.
true
Copies the request headers of the source object.
false
References the request headers of the source object.

formData

request.formData(): Promise<FormData>;
Obtains the resquest body and parses it as FormData.

json

request.json(): Promise<object>;
Obtains the request body and parses it as JSON.

text

request.text(): Promise<string>;
Obtains the request body and parses it as a text string.

Sample Code

async function handleRequest() {
const request = new Request('https://www.tencentcloud.com/');
const response = await fetch(request);
return response;
}

addEventListener('fetch', (event) => {
event.respondWith(handleRequest());
});

References

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan