]> git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpControlMsg.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / HttpControlMsg.h
1 #ifndef SQUID_HTTP_CONTROL_MSG_H
2 #define SQUID_HTTP_CONTROL_MSG_H
3
4 #include "base/AsyncCall.h"
5 #include "HttpReply.h"
6
7 class HttpControlMsg;
8
9 /*
10 * This API exists to throttle forwarding of 1xx messages from the server
11 * side (Source == HttpStateData) to the client side (Sink == ConnStateData).
12 *
13 * Without throttling, Squid would have to drop some 1xx responses to
14 * avoid DoS attacks that send many 1xx responses without reading them.
15 * Dropping 1xx responses without violating HTTP is as complex as throttling.
16 */
17
18 /// sends a single control message, notifying the Sink
19 class HttpControlMsgSink: public virtual AsyncJob
20 {
21 public:
22 HttpControlMsgSink(): AsyncJob("unused") {}
23
24 /// called to send the 1xx message and notify the Source
25 virtual void sendControlMsg(HttpControlMsg msg) = 0;
26 };
27
28 /// bundles HTTP 1xx reply and the "successfully forwarded" callback
29 class HttpControlMsg
30 {
31 public:
32 typedef AsyncCall::Pointer Callback;
33
34 HttpControlMsg(const HttpReply::Pointer &aReply, const Callback &aCallback):
35 reply(aReply), cbSuccess(aCallback) {}
36
37 public:
38 HttpReply::Pointer reply; ///< the 1xx message being forwarded
39 Callback cbSuccess; ///< called after successfully writing the 1xx message
40
41 // We could add an API to notify of send failures as well, but the
42 // current Source and Sink are tied via Store anyway, so the Source
43 // will know, eventually, if the Sink is gone or otherwise failed.
44 };
45
46 inline std::ostream &
47 operator <<(std::ostream &os, const HttpControlMsg &msg)
48 {
49 return os << msg.reply << ", " << msg.cbSuccess;
50 }
51
52 #endif /* SQUID_HTTP_CONTROL_MSG_H */