]>
Commit | Line | Data |
---|---|---|
bbc27441 | 1 | /* |
f6e9a3ee | 2 | * Copyright (C) 1996-2019 The Squid Software Foundation and contributors |
bbc27441 AJ |
3 | * |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7 | */ | |
8 | ||
591d54ea AR |
9 | #ifndef SQUID_HTTP_CONTROL_MSG_H |
10 | #define SQUID_HTTP_CONTROL_MSG_H | |
11 | ||
591d54ea | 12 | #include "base/AsyncCall.h" |
602d9612 | 13 | #include "HttpReply.h" |
591d54ea | 14 | |
84540b47 | 15 | class CommIoCbParams; |
591d54ea AR |
16 | class HttpControlMsg; |
17 | ||
de48b288 | 18 | /* |
591d54ea AR |
19 | * This API exists to throttle forwarding of 1xx messages from the server |
20 | * side (Source == HttpStateData) to the client side (Sink == ConnStateData). | |
21 | * | |
22 | * Without throttling, Squid would have to drop some 1xx responses to | |
23 | * avoid DoS attacks that send many 1xx responses without reading them. | |
24 | * Dropping 1xx responses without violating HTTP is as complex as throttling. | |
de48b288 | 25 | */ |
591d54ea AR |
26 | |
27 | /// sends a single control message, notifying the Sink | |
28 | class HttpControlMsgSink: public virtual AsyncJob | |
29 | { | |
30 | public: | |
31 | HttpControlMsgSink(): AsyncJob("unused") {} | |
32 | ||
33 | /// called to send the 1xx message and notify the Source | |
34 | virtual void sendControlMsg(HttpControlMsg msg) = 0; | |
84540b47 | 35 | |
2f97ab10 | 36 | virtual void doneWithControlMsg(); |
24e1fd72 | 37 | |
84540b47 AJ |
38 | /// callback to handle Comm::Write completion |
39 | void wroteControlMsg(const CommIoCbParams &); | |
40 | ||
41 | /// Call to schedule when the control msg has been sent | |
42 | AsyncCall::Pointer cbControlMsgSent; | |
591d54ea AR |
43 | }; |
44 | ||
45 | /// bundles HTTP 1xx reply and the "successfully forwarded" callback | |
46 | class HttpControlMsg | |
47 | { | |
48 | public: | |
de48b288 | 49 | typedef AsyncCall::Pointer Callback; |
591d54ea | 50 | |
b248c2a3 | 51 | HttpControlMsg(const HttpReply::Pointer &aReply, const Callback &aCallback): |
f53969cc | 52 | reply(aReply), cbSuccess(aCallback) {} |
591d54ea AR |
53 | |
54 | public: | |
b248c2a3 | 55 | HttpReply::Pointer reply; ///< the 1xx message being forwarded |
591d54ea AR |
56 | Callback cbSuccess; ///< called after successfully writing the 1xx message |
57 | ||
58 | // We could add an API to notify of send failures as well, but the | |
59 | // current Source and Sink are tied via Store anyway, so the Source | |
60 | // will know, eventually, if the Sink is gone or otherwise failed. | |
61 | }; | |
62 | ||
63 | inline std::ostream & | |
64 | operator <<(std::ostream &os, const HttpControlMsg &msg) | |
65 | { | |
66 | return os << msg.reply << ", " << msg.cbSuccess; | |
67 | } | |
68 | ||
69 | #endif /* SQUID_HTTP_CONTROL_MSG_H */ | |
f53969cc | 70 |