]> git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpControlMsg.h
Removed leftover CVS-Id markers
[thirdparty/squid.git] / src / HttpControlMsg.h
1 #ifndef SQUID_HTTP_CONTROL_MSG_H
2 #define SQUID_HTTP_CONTROL_MSG_H
3
4 #include "HttpReply.h"
5 #include "base/AsyncCall.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 HttpMsgPointerT<HttpReply> MsgPtr;
33 typedef AsyncCall::Pointer Callback;
34
35 HttpControlMsg(const MsgPtr &aReply, const Callback &aCallback):
36 reply(aReply), cbSuccess(aCallback) {}
37
38 public:
39 MsgPtr reply; ///< the 1xx message being forwarded
40 Callback cbSuccess; ///< called after successfully writing the 1xx message
41
42 // We could add an API to notify of send failures as well, but the
43 // current Source and Sink are tied via Store anyway, so the Source
44 // will know, eventually, if the Sink is gone or otherwise failed.
45 };
46
47 inline std::ostream &
48 operator <<(std::ostream &os, const HttpControlMsg &msg)
49 {
50 return os << msg.reply << ", " << msg.cbSuccess;
51 }
52
53 #endif /* SQUID_HTTP_CONTROL_MSG_H */