Marmos
v juptune
v asn1
v lang
v ast
v Classes
v Enums
v ir
v parser
v Enums
v Structs
v core
v crypto
v keyexchange
v memory
v data
v alphabet
v buffer
v json
v builder
v parser
v Enums
v Structs
v serialise
v Structs
v Templates
v pem
v Enums
v Structs

Structs HttpClient

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module juptune.http.client;

struct HttpClient
{
    /++ ALIASES ++/
    
    /// A function provided by HttpClient which can be used to push data into the request body. 
    alias PutBodyFunc = Result function(const const ubyte[] bodyChunk);
    /// ditto 
    alias PutBodyFuncGC = Result function(const const ubyte[] bodyChunk);
    /// A function provided by the user which is used to stream an entire request body. 
    alias StreamRequestFunc = Result function(Result function(const const ubyte[] bodyChunk) putter);
    /// ditto 
    alias StreamRequestFuncGC = Result function(Result function(const const ubyte[] bodyChunk) putter);
    /// A function provided by HttpClient which can be used to stream read data from the response body. 
    alias StreamResponseFunc = Result function(HttpResponse statusAndHeaders, const const ubyte[] bodyChunk);
    /// ditto 
    alias StreamResponseFuncGC = Result function(HttpResponse statusAndHeaders, const const ubyte[] bodyChunk);
    ///
    alias __xdtor = __MARMOS_BUG__;
    ///
    alias __xpostblit = __MARMOS_BUG__;
    
    /++ FUNCTIONS ++/
    
    /// Closes the connection to the server. 
    Result close();
    /// Connects this client to the given IP address. 
    Result connect(IpAddress ip, const const char[] host = null);
    /// Connects this client to the given IP address over TLS. 
    Result connectTls(IpAddress ip, const const char[] host);
    ///
    TlsTcpSocket getTlsSocketForUnittests();
    /// Returns whether this client is connected to a server. 
    bool isConnected();
    ///
    HttpClient opAssign(HttpClient p);
    /// Sends a request to the server and returns the response. 
    Result request(HttpRequest request, HttpResponse response);
    /// Returns the version of HTTP that this client is using. 
    HttpClientVersion selectedVersion();
    /// Streams a request to the server and streams the response. 
    Result streamRequest(HttpRequest request, HttpResponse response, Result function(Result function(const const ubyte[] bodyChunk) putter) bodyPutter, Result function(HttpResponse statusAndHeaders, const const ubyte[] bodyChunk) bodyReader);
    /// ditto 
    Result streamRequestGC(HttpRequest request, HttpResponse response, Result function(Result function(const const ubyte[] bodyChunk) putter) bodyPutter, Result function(HttpResponse statusAndHeaders, const const ubyte[] bodyChunk) bodyReader);
    ///
    static void wrapPairedSocket(HttpClient client, TcpSocket socket, HttpClientConfig config);
    
}

Documentation

A medium-level HTTP client, designed to be a good balance between ease of use, flexibility, and performance.

This client attempts to cater to both the @nogc and GC worlds, and as such has a few different named overloads for its functions.

It has two different ways to send a request currently: A 'Simple' way, and a 'Streamed' way.

Simple

This is the easiest way to send a request, but isn't the most suitable for all situations, especially sending/receiving large amounts of data.

This method is used by calling the requestfunction with a pre-built HttpRequestcontaining the entire request. Please consult the documentation for HttpRequestand requestfor more info.

Streamed

This is the most flexible way to send a request beyond using the low-level primitives directly, but is more complex to use. This is the recommended way to send/receive large amounts of data.

This method is used by calling the streamRequestfunction which provides a callback-based pattern for sending/receiving data. Please consult the documentation for streamRequestfor more info.

Aliases

Name Description
PutBodyFunc

A function provided by HttpClientwhich can be used to push data into the request body.

PutBodyFuncGC

ditto

StreamRequestFunc

A function provided by the user which is used to stream an entire request body.

StreamRequestFuncGC

ditto

StreamResponseFunc

A function provided by HttpClientwhich can be used to stream read data from the response body.

StreamResponseFuncGC

ditto

__xdtor
__xpostblit

Functions

Name Description
close

Closes the connection to the server.

connect

Connects this client to the given IP address.

connectTls

Connects this client to the given IP address over TLS.

getTlsSocketForUnittests
isConnected

Returns whether this client is connected to a server.

opAssign
request

Sends a request to the server and returns the response.

selectedVersion

Returns the version of HTTP that this client is using.

streamRequest

Streams a request to the server and streams the response.

streamRequestGC

ditto

wrapPairedSocket