* 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().
* '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. * * Example: * --- * class ChangePath : Interceptor * { * Response opCall(Request r, RequestHandler next) * { * r.path = r.path ~ "get"; * auto rs = next.handle(r); * return rs; * } * } * --- * Later in the code you can use this class: * Example: * --- * Request rq; * rq.addInterceptor(new ChangePath()); * rq.get("http://example.com"); * --- *
* Structure Request provides configuration, connection pooling, cookie * persistance. You can consider it as 'Session'.
* 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:
* 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); * } * ---