Request Object

Request objects are received by splash:on_request callbacks; they are also available as response.request.


Request objects has several attributes with information about a HTTP request. These fields are for information only; changing them doesn’t change the request to be sent.


Requested URL.


HTTP method name in upper case, e.g. “GET”.


A Lua table with request HTTP headers (header name => header value). Keys are header names (strings), values are header values (strings).

Lookups are case-insensitive, so request.headers['content-type'] is the same as request.headers['Content-Type'].

A table with request data in HAR request format.


To change or drop the request before sending use one of the request methods. Note that these methods are only available before the request is sent (they has no effect if a request is already sent). Currently it means you can only use them in splash:on_request callbacks.


Drop the request.

Signature: request:abort()

Returns: nil.

Async: no.


Enable tracking of response content (i.e. response.body attribute).

Signature: request:enable_response_body()

Returns: nil.

Async: no.

This function allows to enable response content tracking per-request when splash.response_body_enabled is set to false. Call it in a splash:on_request callback.


Change request URL to a specified value.

Signature: request:set_url(url)


  • url - new request URL

Returns: nil.

Async: no.


Set a proxy server to use for this request.

Signature: request:set_proxy{host, port, username=nil, password=nil, type='HTTP'}


  • host
  • port
  • username
  • password
  • type - proxy type; allowed proxy types are ‘HTTP’ and ‘SOCKS5’.

Returns: nil.

Async: no.

Omit username and password arguments if a proxy doesn’t need auth.

When type is set to ‘HTTP’ HTTPS proxying should also work; it is implemented using CONNECT command.


Set a timeout for this request.

Signature: request:set_timeout(timeout)


  • timeout - timeout value, in seconds.

Returns: nil.

Async: no.

If response is not fully received after the timeout, request is aborted. See also: splash.resource_timeout.


Set an HTTP header for this request.

Signature: request:set_header(name, value)


  • name - header name;
  • value - header value.

Returns: nil.

Async: no.

See also: splash:set_custom_headers