The OpenD Programming Language

HttpClient

HttpClient keeps cookies, location, and some other state to reuse connections, when possible, like a web browser. You can use it as your entry point to make http requests.

See the example on arsd.http2#examples.

Constructors

this
this(ICache cache)

Members

Functions

addDefaultHeader
void addDefaultHeader(string key, string value)

Adds a header to be automatically appended to each request created through this client.

clearCookies
void clearCookies(string domain)
getProxyFor
string getProxyFor(Uri uri)

Checks if the given uri should be proxied according to the httpProxy, httpsProxy, proxyIgnore variables and returns either httpProxy, httpsProxy or null.

loadDefaultProxy
void loadDefaultProxy()

Loads the system-default proxy. Note that the constructor does this automatically so you should rarely need to call this explicitly.

navigateTo
HttpRequest navigateTo(Uri where, HttpVerb method)

High level function that works similarly to entering a url into a browser.

request
HttpRequest request(Uri uri, HttpVerb method, ubyte[] bodyData, string contentType)
HttpRequest request(Uri uri, FormData fd, HttpVerb method)

Creates a request without updating the current url state. If you want to save cookies, either call retainCookies with the response yourself or set request.retainCookies to true on the returned object. But see important implementation shortcomings on retainCookies.

retainCookies
void retainCookies(HttpResponse fromResponse)

HttpClient does NOT automatically store cookies. You must explicitly retain them from a response by calling this method.

setClientCertificate
void setClientCertificate(string certFilename, string keyFilename, CertificateFileFormat certFormat)

Sets the client certificate used as a log in identifier on https connections. The certificate and key must be unencrypted at this time and both must be in the same file format.

setCookie
void setCookie(string name, string value, string domain)
void setCookie(CookieHeader ch, string domain)

See retainCookies for important caveats.

Properties

location
Uri location [@property getter]

Static functions

matchProxyIgnore
bool matchProxyIgnore(const(char)[] rule, Uri uri)

Returns true if the given no_proxy rule matches the uri.

Variables

acceptGzip
bool acceptGzip;
authorization
string authorization;
defaultTimeout
Duration defaultTimeout;

Default timeout for requests created on this client.

defaultVerifyPeer
bool defaultVerifyPeer;

Sets whether HttpRequests created through this object (with navigateTo, request, etc.), will have the value of HttpRequest.verifyPeer of true or false upon construction.

httpProxy
string httpProxy;
httpsProxy
string httpsProxy;

Proxies to use for requests. The HttpClient constructor will set these to the system values, then you can reset it to null if you want to override and not use the proxy after all, or you can set it after construction to whatever.

keepAlive
bool keepAlive;
proxyIgnore
string[] proxyIgnore;

List of hosts or ips, optionally including a port, where not to proxy.

useHttp11
bool useHttp11;
userAgent
string userAgent;

Meta