Syntax, parameters, return values, and examples of request processing functions.
add_req_header
| Item | Description |
| Syntax | add_req_header(name, value [, append]) |
| Description | Adds a request header to requests before they are redirected to the origin server. |
| Parameter |
|
| Return value | Returns true by default and returns false if the specified request header is invalid. |
| Example | |
del_req_header
| Item | Description |
| Syntax | del_req_header(name) |
| Description | Deletes a request header from requests before they are redirected to the origin server. |
| Parameter | name: the name of the request header that you want to delete. Data type: string. |
| Return value | Returns true by default and returns false if the specified request header is invalid. |
| Example | |
add_rsp_header
| Item | Description |
| Syntax | add_rsp_header(name, value [, append]) |
| Description | Adds a response header. |
| Parameter |
|
| Return value | Returns true by default and returns false if the specified response header is invalid. |
| Example | |
del_rsp_header
| Item | Description |
| Syntax | del_rsp_header(name) |
| Description | Deletes a response header. |
| Parameter | name: the name of the response header that you want to delete. Data type: string. |
| Return value | Returns true by default and returns false if the specified response header is invalid. |
| Example | |
encode_args
| Item | Description |
| Syntax | encode_args(d) |
| Description | Converts the k/v pairs in the dictionary specified by d to a URI-encoded string in the format of k1=v1&k2=v2. |
| Parameter | d: the dictionary that you want to convert. |
| Return value | Returns a URI-encoded string. |
| Example | |
decode_args
| Item | Description |
| Syntax | decode_args(s) |
| Description | Converts a URI-encoded string in the format of k1=v1&k2=v2 to a string of dictionary type. |
| Parameter | s: the string that you want to convert. |
| Return value | Returns a dictionary object converted from the specified string. |
| Example | |
rewrite
| Item | Description |
| syntax | rewrite(url, flag [, code]) |
| description | Rewrites the URL or issues a redirect. |
| parameter |
|
| return value |
|
| example | |
say
| Item | Description |
| Syntax | say(arg) |
| Description | Prints a response body and appends a newline character at the end of the output. |
| Parameter | arg: the content of the response body. Data type: any type. |
| Return value | None. |
| Example | |
| Item | Description |
| Syntax | print(arg) |
| Description | Prints a response body without appending a newline, unlike the say() function. |
| Parameter | arg: the content of the response body. Data type: any type. |
| Return value | None. |
| Example | |
exit
| Item | Description |
| Syntax | exit(code [, body]) |
| Description | Ends the current request with the specified code. If body is specified, the response includes that body content. |
| Parameter |
|
| Return value | None. |
| Example |
|
get_rsp_header
| Item | Description |
| Syntax | get_rsp_header(str) |
| Description | Retrieves a response header. |
| Parameter | str: the response header that you want to obtain. Data type: string. |
| Return value | Returns the value of the specified response header.
|
| Example | |
add_rsp_cookie
| Item | Description |
| Syntax | add_rsp_cookie(k, v [,properties]) |
| Description | Sets the response cookie. Each time the function is called, a new Set-Cookie response header is generated. |
| Parameter |
|
| Return value | Returns true if the cookie is set, or false if the operation fails. |
| Example | Response: |