HTTP Module Events

http_data_send

Notifies about ready to send the next portion of data of a request. max_data_length contains the maximum number of bytes that can be sent for the current script execution.

This event will be received after establishing a connection with the HTTP server and if last field was false in http.request() or http.repeat_request() methods. Also, this event can be triggered again if not all data were sent in this session.

Name Type Required Description
id string + Unique ID of a request
url string + Full URL for making a connection (can contain custom port)
user_data any - User data that was passed to a http.request() call.
max_data_length int + Amount of data that can be sent per one script execution via http.send_data() method

http_data_received

Notifies about the answer on request or new portion of data. It triggers when the "receiving data buffer" is full or all bytes were received (according to the Content-Length or Transfer-Encoding headers), or two end lines are received. When caching is disabled, it triggers immediately after receiving a new portion of data.

Name Type Required Description
id string + Unique ID of a request
url string + Full URL for making a connection (can contain custom port)
code int + HTTP request return code
headers array of objects - Response headers
headers.key string + Header name
headers.value string + Header value
user_data any - User data that was passed to an http.request() call.
data string, binary + Part of data received from a server. Can be in text or binary format.
last bool - Last part of HTTP request's data. If all bytes were received (according to Content-Length header) or two end lines were received than this field should be true, in all other cases false.

http_connection_closed

Name Type Required Description
id string + Unique ID of a request
url string + Full URL for making connection( can contain custom port )
user_data any - User data that was passed to an http.request() call.
reason object +
reason.code int + Code of reason
reason.text string + Text of reason
code int - HTTP status code returned by an HTTP server.
code_status string - HTTP status code description as it passed over by an HTTP server.

Reasons:

Code Text
1 Cannot resolve DNS name
2 Cannot connect to the server
3 SSL Connection Error
4 Closed by client
5 Closed by server
6 Timeout of response is reached
7 Unknown error