HTTPClient.request

Performs a HTTP request.

requester is called first to populate the request with headers and the desired HTTP method and version. After a response has been received it is then passed to the caller which can in turn read the reponse body. Any part of the body that has not been processed will automatically be consumed and dropped.

Note that the requester callback might be invoked multiple times in the event that a request has to be resent due to a connection failure.

Also note that the second form of this method (returning a HTTPClientResponse) is not recommended to use as it may accidentially block a HTTP connection when only part of the response body was read and also requires a heap allocation for the response object. The callback based version on the other hand uses a stack allocation and guarantees that the request has been fully processed once it has returned.

  1. void request(void delegate(scope HTTPClientRequest req) requester, void delegate(scope HTTPClientResponse) responder)
  2. HTTPClientResponse request(void delegate(HTTPClientRequest) requester)
    class HTTPClient
    @safe
    request
    (
    scope void delegate requester
    )

Meta