This topic describes the syntax, parameters, and return values of request logic functions. This topic also provides examples of these functions.
server_addr
This function queries the IP addresses of servers that receive the current request. The following table describes the details about this function.
Item | Description |
Syntax | server_addr() |
Parameters | None |
Example |
|
Return value | Returns the IP addresses of the servers in a string. |
server_port
This function queries the server port that receives the current request. The following table describes the details about this function.
Item | Description |
Syntax | server_port() |
Parameters | None |
Example |
|
Return value | Returns the server port that receives the current request. Data type: numeric. |
client_addr
Caution: The return value may not be accurate because the client address may be changed by the NAT rules of the Internet service provider (ISP) or the IP address is not in the address pool of Alibaba Cloud CDN. Proceed with caution.
This function queries the IP address of a client. The following table describes the details about this function.
Item | Description |
Syntax | client_addr() |
Parameters | None |
Example |
|
Return value | Returns the IP address of the specified client in a string. |
client_port
This function queries the port of a client. The following table describes the details about this function.
Item | Description |
Syntax | client_port() |
Parameters | None |
Example |
|
Return value | Returns the port of the specified client. Data type: numeric. |
client_country
Caution: The return value may not be accurate because the client address may be changed by the NAT rules of the Internet service provider (ISP) or the IP address is not in the address pool of Alibaba Cloud CDN. Proceed with caution.
This function queries the country code and administrative division code of a client. The following table describes the details about this function.
Item | Description |
Syntax | client_country() |
Parameters | None |
Example |
|
Return value | Returns the country code and administrative division code of the specified client in a string. For more information about country codes and administrative division codes, see Country codes. |
client_region
Caution: The return value may not be accurate because the client address may be changed by the NAT rules of the Internet service provider (ISP) or the IP address is not in the address pool of Alibaba Cloud CDN. Proceed with caution.
This function queries the administrative division code of a client. The following table describes the details about this function.
Item | Description |
Syntax | client_region() |
Parameters | None |
Example |
|
Return value | Returns the administrative division code of the specified client in a string. For more information about administrative division codes, see Administrative division codes. |
client_isp
Caution: The return value may not be accurate because the client address may be changed by the NAT rules of the Internet service provider (ISP) or the IP address is not in the address pool of Alibaba Cloud CDN. Proceed with caution.
This function queries the ISP code of a client. The following table describes the details about this function.
Item | Description |
Syntax | client_isp() |
Parameters | None |
Example |
|
Return value | Returns the ISP code of the specified client in a string. For more information about ISP codes, see ISP codes. |
ip_region
Caution: The return value may not be accurate because the client address may be changed by the NAT rules of the Internet service provider (ISP) or the IP address is not in the address pool of Alibaba Cloud CDN. Proceed with caution.
This function queries the administrative division code of the city or province to which a specified IP address belongs. The following table describes the details about this function.
Item | Description |
Syntax | ip_region(ipaddr) |
Parameters | ipaddr: specifies an IP address in dotted decimal notation. |
Example |
|
Return value | Returns the administrative division code of the city or province to which the specified IP address belongs in a string. For more information about administrative division codes, see Administrative division codes. |
ip_isp
Caution: The return value may not be accurate because the client address may be changed by the NAT rules of the Internet service provider (ISP) or the IP address is not in the address pool of Alibaba Cloud CDN. Proceed with caution.
This function queries the ISP code of a specified IP address. The following table describes the details about this function.
Item | Description |
Syntax | ip_isp(ipaddr) |
Parameters | ipaddr: specifies an IP address in dotted decimal notation. |
Example |
|
Return value | Returns the ISP code of the specified IP address in a string. For more information about ISP codes, see ISP codes. |
req_uri
Usage notes on this function:
If the pattern parameter is not included in the request, the URI of the request is returned, excluding the parameters.
If the pattern parameter is included in the request, the URI of the request is compared with the match conditions.
The following table describes the details about this function.
Item | Description |
Syntax | req_uri([pattern]) |
Parameters | pattern: compared with the match conditions. The following match types are supported:
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_uri_basename
Usage notes on this function:
Returns the file name in the request URI if the pattern parameter is not included in the request.
Compares the file name in the request URI with the match conditions if the pattern parameter is included in the request.
Sample file names:
Example 1: For /document_detail/30360.html, the file name is 30360.
Example 2: For /M604/guopei_mp4/ZYJY2017BJGL0101/2-1_g.mp4, the file name is 2-1_g.
Example 3: For /tarball/foo.tar.bz2, the file name is foo.
The following table describes the details about this function.
Item | Description |
Syntax | req_uri_basename([pattern]) |
Parameters | pattern: compared with the match conditions. The following match types are supported:
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_uri_ext
Usage notes on this function:
Returns the extension in the request URI if the pattern parameter is not included in the request.
Compares the extension in the request URI with the match conditions if the pattern parameter is included in the request.
Sample extensions:
Example 1: For /document_detail/30360.html, the extension is .html.
Example 2: For /M604/guopei_mp4/ZYJY2017BJGL0101/2-1_g.mp4, the extension is .mp4.
Example 3: For /tarball/foo.tar.bz2, the extension is .tar.bz2.
The following table describes the details about this function.
Item | Description |
Syntax | req_uri_ext([pattern]) |
Parameters | pattern: compared with the match conditions. The following match types are supported:
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_uri_seg
Usage notes on this function:
In response parameters, the segments are separated by forward slashes (/).
Returns all segments if the idx parameter is not included in the request.
Returns the segments (including the index) that follow the specified index if the idx parameter is included in the request.
Indexes for paragraphs: the index starts from 1 and increases from the leftmost index when more paragraphs are added.
Paragraph limit: A paragraph can contain up to 128 characters. Characters that exceed this limit are dropped.
The following table describes the details about this function.
Item | Description |
Syntax | req_uri_seg([idx]) |
Parameters | idx: specifies the start index. This parameter is optional. |
Example |
|
Return value | Data type: dictionary. The relevant paragraphs are included. Note When the function retrieves the paragraph from the returned dictionary based on the specified index, the function checks whether the paragraph is empty. In this example, the following values are returned:
|
req_uri_arg
This function queries the value of a specified parameter. If the pattern parameter is included in the request, the value of the specified parameter is compared with the match conditions. The following table describes the details about this function.
Item | Description |
Syntax | req_uri_arg(name, [pattern]) |
Parameters |
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_uri_query_string
Usage notes on this function:
If the pattern parameter is not included in the request, the parameters in the request are returned, excluding the question mark (?).
If the pattern parameter is included in the request, the parameters in the requests are compared with the match conditions.
The following table describes the details about this function.
Item | Description |
Syntax | req_uri_query_string([pattern]) |
Parameters | pattern: compared with the match conditions. The following match types are supported:
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_scheme
Usage notes on this function:
Returns the request scheme if the pattern parameter is not included in the request.
Compares the request scheme with the match conditions if the pattern parameter is included in the request.
The following table describes the details about this function.
Item | Description |
Syntax | req_scheme([pattern]) |
Parameters | pattern: compared with the match conditions. The following match types are supported:
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_method
Usage notes on this function:
Returns the request method if the pattern parameter is not included in the request.
Compares the request method with the match conditions if the pattern parameter is included in the request.
The following table describes the details about this function.
Item | Description |
Syntax | req_method([pattern]) |
Parameters | pattern: compared with the match conditions. The following match types are supported:
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_host
Usage notes on this function:
Returns the value of the Host request header if the pattern parameter is not included in the request.
Compares the value of the Host request header with the match conditions if the pattern parameter is included in the request.
The following table describes the details about this function.
Item | Description |
Syntax | req_host([pattern]) |
Parameters | pattern: compared with the match conditions. The following match types are supported:
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_user_agent
Usage notes on this function:
Returns the value of the User-Agent request header if the pattern parameter is not included in the request.
Compares the value of the User-Agent request header with the match conditions if the pattern parameter is included in the request.
The following table describes the details about this function.
Item | Description |
Syntax | req_user_agent([pattern]) |
Parameters | pattern: compared with the match conditions. The following match types are supported:
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_referer
Usage notes on this function:
Returns the value of the Referer request header if the pattern parameter is not included in the request.
Compares the value of the Referer request header with the match conditions if the pattern parameter is included in the request.
The following table describes the details about this function.
Item | Description |
Syntax | req_referer([pattern]) |
Parameters | pattern: compared with the match conditions. The following match types are supported:
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_cookie
This function queries the value of a specified cookie. If the pattern parameter is included in the request, the value of the specified cookie is compared with the match conditions. The following table describes the details about this function.
Item | Description |
Syntax | req_cookie(name, [pattern]) |
Parameters |
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_first_x_forwarded
Usage notes on this function:
Returns the first address in the X-Forwarded-For request header if the pattern parameter is not included in the request.
Compares the first address in the X-Forwarded-For request header with the match conditions if the pattern parameter is included in the request.
The following table describes the details about this function.
Item | Description |
Syntax | req_first_x_forwarded_addr([pattern]) |
Parameters | pattern: compared with the match conditions. The following match types are supported:
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_header
This function queries the value of a specified request header. If the pattern parameter is included in the request, the value of the specified request header is compared with the match conditions. The following table describes the details about this function.
Item | Description |
Syntax | req_header(name, [pattern]) |
Parameters |
|
Example |
|
Return value |
In this example, the following values are returned:
|
req_id
This function queries the Eagle Eye ID of a request. Each Eagle Eye ID uniquely identifies a request. The following table describes the details about this function.
Item | Description |
Syntax | req_id() |
Parameters | None |
Example |
|
Return value | Returns the request ID in a string. In this example, the ID of the request is |