1 module hunt.http.client.ClientHttpHandler;
2 
3 import hunt.http.HttpRequest;
4 import hunt.http.HttpResponse;
5 import hunt.http.HttpConnection;
6 import hunt.http.codec.http.stream.HttpHandler;
7 import hunt.http.HttpOutputStream;
8 
9 import hunt.Functions;
10 import hunt.util.Common;
11 import hunt.io.ByteBuffer;
12 
13 /**
14  * 
15  */
16 interface ClientHttpHandler : HttpHandler {
17 
18     void continueToSendData(HttpRequest request, HttpResponse response,
19             HttpOutputStream output, HttpConnection connection);
20 }
21 
22 /**
23  * 
24  */
25 class AbstractClientHttpHandler : AbstractHttpHandler, ClientHttpHandler {
26 
27     protected Action4!(HttpRequest, HttpResponse, HttpOutputStream, HttpConnection) _continueToSendData;
28 
29     AbstractClientHttpHandler headerComplete(Func4!(HttpRequest, HttpResponse,
30             HttpOutputStream, HttpConnection, bool) h) {
31         this._headerComplete = h;
32         return this;
33     }
34 
35     AbstractClientHttpHandler content(Func5!(ByteBuffer, HttpRequest, HttpResponse,
36             HttpOutputStream, HttpConnection, bool) c) {
37         this._content = c;
38         return this;
39     }
40 
41     AbstractClientHttpHandler contentComplete(Func4!(HttpRequest, HttpResponse,
42             HttpOutputStream, HttpConnection, bool) c) {
43         this._contentComplete = c;
44         return this;
45     }
46 
47     AbstractClientHttpHandler messageComplete(Func4!(HttpRequest, HttpResponse,
48             HttpOutputStream, HttpConnection, bool) m) {
49         this._messageComplete = m;
50         return this;
51     }
52 
53     AbstractClientHttpHandler badMessage(Action6!(int, string, HttpRequest,
54             HttpResponse, HttpOutputStream, HttpConnection) b) {
55         this._badMessage = b;
56         return this;
57     }
58 
59     AbstractClientHttpHandler earlyEOF(Action4!(HttpRequest, HttpResponse,
60             HttpOutputStream, HttpConnection) e) {
61         this._earlyEOF = e;
62         return this;
63     }
64 
65     AbstractClientHttpHandler continueToSendData(Action4!(HttpRequest, HttpResponse,
66             HttpOutputStream, HttpConnection) c) {
67         this._continueToSendData = c;
68         return this;
69     }
70 
71     override void continueToSendData(HttpRequest request, HttpResponse response,
72             HttpOutputStream output, HttpConnection connection) {
73         if (_continueToSendData != null) {
74             _continueToSendData(request, response, output, connection);
75         }
76     }
77 
78 }