Setup the request object and response handlers in preparation to execute a request.
When using the CurlEasy
interface, this method is called internally by curl_execute
, however when using the CurlMulti
interface, it is necessary to call this on every CurlEasy
handle added to the CurlMulti
handle.
This method allows you to set up your own response data and header handlers that receive streamed data. If you do not pass in a handler, default handlers will be set up that write binary data as bytes (Vector{UInt8}
) to curl.userdata[:databuffer]
and an array of String response headers (Vector{String}
) to curl.userdata[:responseHeaders]
.
Arguments
curl::
CurlEasy
: The CurlEasy
handle to operate on
requestBody::String
: Any request body text that should be passed on to the server. Typically used for POST
requests. Leave this as an empty String to skip. This is passed as-is to curl_setup_request
.
headers::Vector{String} = String[]
: Any request headers that should be passed on to the server as part of the request. Headers SHOULD be of the form key: value
. Consult RFC 2616 section 4.2 for more details on HTTP request headers.
Keyword Arguments
data_handler::Union{Function, Nothing} = <default>
: A function to handle any response Body data. This function should accept a single argument of type Vector{UInt8}
. Its return value will be ignored. If not specified, a default handler will be used. Set this explicitly to nothing
to disable handling of HTTP response body data.
header_handler::Union{Function, Nothing} = <default>
: A function to handle any response Header data. This function should accept a single argument of type String
. Its return value will be ignored. If not specified, a default handler will be used. Set this explicitly to nothing
to disable handling of HTTP response header data.
url::AbstractString=""
: The URL to use for this request. This permanently overrides the url
passed in to the CurlEasy
constructor. If not specified, then the previous value of the CurlEasy
's url is reused.
Returns
The CurlEasy
object.