Creates (and immediately returns) an Agent representing an HTTP
request running in a new thread.
options are key/value pairs:
:method string
The HTTP method name. Default is "GET".
:headers h
HTTP headers, as a Map or a sequence of pairs like
([key1,value1], [key2,value2]) Default is nil.
:body b
HTTP request entity body, one of nil, String, byte[], InputStream,
Reader, or File. Default is nil.
:connect-timeout int
Timeout value, in milliseconds, when opening a connection to the
URL. Default is zero, meaning no timeout.
:read-timeout int
Timeout value, in milliseconds, when reading data from the
connection. Default is zero, meaning no timeout.
:follow-redirects boolean
If true, HTTP 3xx redirects will be followed automatically. Default
is true.
:handler f
Function to be called when the HTTP response body is ready. If you
do not provide a handler function, the default is to buffer the
entire response body in memory.
The handler function will be called with the HTTP agent as its
argument, and can use the 'stream' function to read the response
body. The return value of this function will be stored in the state
of the agent and can be retrieved with the 'result' function. Any
exceptions thrown by this function will be added to the agent's
error queue (see agent-errors). The default function collects the
response stream in a memory buffer.
Comments top
No comments for http-agent. Log in to add a comment.