Name
easy:SetOpt_PreReqFunction -- user callback called when a connection has been (V2.0)
Synopsis
easy:SetOpt_PreReqFunction(prereq_callback[, userdata])
Function
Pass a callback function. This function gets called by libcurl after a connection has been established or a connection has been reused (including any SSL handshaking), but before any request is actually made on the connection. For example, for HTTP, this callback is called once a connection has been established to the server, but before a GET/HEAD/POST/etc request has been sent.

This function may be called multiple times if redirections are enabled and are being followed (see #CURLOPT_FOLLOWLOCATION).

The function is called like this:

 
res = prereq(primary_ip, local_ip, primary_port, local_port[, data])

Here is a description of all parameters:

primary_ip
A string containing the primary IP of the remote server established with this connection. For FTP, this is the IP for the control connection. IPv6 addresses are represented without surrounding brackets.
local_ip
A string containing the originating IP for this connection. IPv6 addresses are represented without surrounding brackets.
primary_port
The primary port number on the remote server established with this connection. For FTP, this is the port for the control connection. This can be a TCP or a UDP port number depending on the protocol.
local_port
The originating port number for this connection. This can be a TCP or a UDP port number depending on the protocol.
data
If you pass the optional userdata argument, the value you pass in userdata will be passed to your callback function as this parameter. The userdata parameter can be of any type.

The callback function must return #CURL_PREREQFUNC_OK on success, or #CURL_PREREQFUNC_ABORT to cause the transfer to fail.

Inputs
prereq_callback
callback function
userdata
optional: user data to pass to callback function

Show TOC