Module requests.request

This module provides API using Request structure.

Structure Request provides configuration, connection pooling, cookie persistance. You can consider it as 'Session' and reuse it - all caches and settings will effective for next requests.

Some most usefull settings:

name type meaning default
keepAlive bool use keepalive connection true
verbosity uint verbosity level (0, 1, 2 or 3) 16KB
maxRedirects uint maximum redirects allowed (0 to disable redirects) true
maxHeadersLength size_t max. acceptable response headers length 32KB
maxContentLength size_t max. acceptable content length 0 - unlimited
bufferSize size_t socket io buffer size 16KB
timeout Duration timeout on connect or data transfer 30.seconds
proxy string url of the HTTP/HTTPS/FTP proxy null
bind string use local address for outgoing connections null
useStreaming bool receive response data as InputRange in case it can't fit memory false
addHeaders string[string] custom headers null
cookie Cookie[] cookies you will send to server null
authenticator Auth authenticator null
socketFactory see doc for socketFactory user-provided connection factory null

Example

import requests;
import std.datetime;

void main()
{
    Request rq = Request();
    Response rs;
    rq.timeout = 10.seconds;
    rq.addHeaders(["User-Agent": "unknown"]);
    rs = rq.get("https://httpbin.org/get");
    assert(rs.code==200);
    rs = rq.post("http://httpbin.org/post", "abc");
    assert(rs.code==200);
}

Functions

NameDescription
__unittest_L637_C1()
addInterceptor(i) Add module-level interceptor. Each Request will include it in the processing. it is handy as you can change behaviour of your requests without any changes in your code, just install interceptor before any call to Request().

Interfaces

NameDescription
Interceptor 'Intercepror' intercepts Request. It can modify request, or log it, or cache it or do whatever you need. When done it can return response or pass it to next request handler.

Classes

NameDescription
RequestHandler

Structs

NameDescription
_LineReader
Request Structure Request provides configuration, connection pooling, cookie persistance. You can consider it as 'Session'.

Global variables

NameTypeDescription
_static_interceptors Interceptor[]

Aliases

NameTypeDescription
NetStreamFactory requests.streams.NetworkStream delegate(string, string, ushort)