Request Header Actions

OpenResty Edge provides the following actions to modify the client request headers.

Set the request header

Two actions are set in this page rule.

  • One is set-request-header, and this action requires the name and value of the request header to be entered.

  • The other action, Use Edge Language, is intended to print the modified request header Host. the code is as follows.

    true =>
        say(req-header("Host"));
    

Example request.

$ curl http://test.com
openresty-edge.com

In this example, the request header Host is changed from the value test.com to openresty-edge.com.

Add request header

This action also requires the name and value of the request header to be entered.

Example request.

$ curl http://test.com
openresty-edge

This example adds a request header with the name X-Add-Name and the value openresty-edge.

Remove the request header

This action has only one parameter request-header-name.

Example request.

``bash $ curl http://test.com -H ‘X-RM-Header: openresty-edge’ (empty)


In this example, the request header with the name `X-RM-Header` is removed.