Request

This is simplest interface to both http and ftp protocols. Request has methods get, post and exec which routed to proper concrete handler (http or ftp, etc). To enable some protocol-specific featutes you have to use protocol interface directly (see docs for HTTPRequest or FTPRequest)

Members

Functions

addHeaders
void addHeaders(string[string] headers)

Add headers to request

clearHeaders
void clearHeaders()
Undocumented in source. Be warned that the author may not have intended to support it.
exec
Response exec(string uri, A args)

Execute request with method

format
string format(string fmt)
Undocumented in source. Be warned that the author may not have intended to support it.
get
Response get(string uri, A args)

Execute GET for http and retrieve file for FTP. You have to provide at least uri. All other arguments should conform to HTTPRequest.get or FTPRequest.get depending on the URI scheme. When arguments do not conform scheme (for example you try to call get("ftp://somehost.net/pub/README", {"a":"b"}) which doesn't make sense) you will receive Exception("Operation not supported for ftp")

post
Response post(string uri, A args)

Execute POST for http and STOR file for FTP. You have to provide uri and data. Data should conform to HTTPRequest.post or FTPRequest.post depending on the URI scheme. When arguments do not conform scheme you will receive Exception("Operation not supported for ftp")

toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

authenticator
Auth authenticator [@property setter]

Set authenticator for http requests. v - Auth instance.

bind
string bind [@property setter]

Set local address for any outgoing requests. v can be string with hostname or ip address.

bufferSize
size_t bufferSize [@property setter]

Set IO buffer size for http and ftp requests v - buffer size in bytes.

contentLength
long contentLength [@property getter]

get contentLength of the responce

contentReceived
long contentReceived [@property getter]

get length og actually received content. this value increase over time, while we receive data

cookie
Cookie[] cookie [@property setter]

Set Cookie for http requests. v - array of cookie.

cookie
Cookie[] cookie [@property getter]

Get Cookie for http requests.

keepAlive
bool keepAlive [@property setter]

Set http keepAlive value v - use keepalive requests - true, or not - false Request will automatically reopen connection when host, protocol or port change (so it is safe to send different requests through single instance of Request). It also recovers if server prematurely close keep-alive connection.

maxContentLength
size_t maxContentLength [@property setter]

Set maximum content lenth both for http and ftp requests v - maximum content length in bytes. When limit reached - throws RequestException

maxHeadersLength
size_t maxHeadersLength [@property setter]

Set maximum length for HTTP headers v - maximum length of the HTTP response. When limit reached - throws RequestException

maxRedirects
uint maxRedirects [@property setter]

Set limit on HTTP redirects v - limit on redirect depth Throws MaxRedirectsException when limit is reached.

proxy
string proxy [@property setter]

set proxy property. v - full url to proxy.

sslOptions
auto sslOptions [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
sslSetCaCert
string sslSetCaCert [@property setter]

Set path to ssl ca cert file.

sslSetCertFile
void sslSetCertFile(string path, SSLOptions.filetype type)

Set path to ssl cert file.

sslSetKeyFile
void sslSetKeyFile(string path, SSLOptions.filetype type)

Set path to ssl key file.

sslSetVerifyPeer
bool sslSetVerifyPeer [@property setter]

Enable or disable ssl peer verification. v - enable if true, disable if false.

timeout
Duration timeout [@property setter]

Set timeout on connection and IO operation. v - timeout value If timeout expired Request operation will throw TimeoutException.

useStreaming
bool useStreaming [@property setter]

set "streaming" property v = value to set (true - use streaming).

verbosity
uint verbosity [@property setter]

Set verbosity for HTTP or FTP requests. v - verbosity level (0 - no output, 1 - headers to stdout, 2 - headers and data hexdump to stdout). default = 0.

Meta