HTTPClientSettings

Defines an HTTP/HTTPS proxy request or a connection timeout for an HTTPClient.

Members

Properties

dup
HTTPClientSettings dup [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

connectTimeout
Duration connectTimeout;

Timeout for establishing a connection to the server

defaultKeepAliveTimeout
Duration defaultKeepAliveTimeout;
Undocumented in source.
dnsAddressFamily
AddressFamily dnsAddressFamily;

Can be used to force looking up IPv4/IPv6 addresses for host names.

networkInterface
NetworkAddress networkInterface;

Forces a specific network interface to use for outgoing connections.

proxyURL
URL proxyURL;
Undocumented in source.
readTimeout
Duration readTimeout;

Timeout during read operations on the underyling transport

tlsContextSetup
void delegate(TLSContext ctx) @(safe) nothrow tlsContextSetup;

Allows to customize the TLS context before connecting to a server.

tlsPeerName
string tlsPeerName;

TLS Peer name override.

Examples

void test() {

	HTTPClientSettings settings = new HTTPClientSettings;
	settings.proxyURL = URL.parse("http://proxyuser:proxypass@192.168.2.50:3128");
	settings.defaultKeepAliveTimeout = 0.seconds; // closes connection immediately after receiving the data.
	requestHTTP("http://www.example.org",
				(scope req){
		req.method = HTTPMethod.GET;
	},
	(scope res){
		logInfo("Headers:");
		foreach (key, ref value; res.headers.byKeyValue) {
			logInfo("%s: %s", key, value);
		}
		logInfo("Response: %s", res.bodyReader.readAllUTF8());
	}, settings);

}

Meta