From: Alex Rousskov Date: Fri, 10 Sep 2010 23:47:55 +0000 (-0600) Subject: Added HttpControlMsg class and HttpControlMsgSink API to handle 1xx forwarding. X-Git-Tag: take1~280 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=591d54eaf28b2085c987ccb4eda0e088c4b9aae1;p=thirdparty%2Fsquid.git Added HttpControlMsg class and HttpControlMsgSink API to handle 1xx forwarding. The header was forgotten in r10839 commit. Apparently, "bzr patch" does not understand what "=== added file" line produced by "bzr diff" means. --- diff --git a/src/HttpControlMsg.h b/src/HttpControlMsg.h new file mode 100644 index 0000000000..a417c34910 --- /dev/null +++ b/src/HttpControlMsg.h @@ -0,0 +1,57 @@ +/* + * $Id$ + */ + +#ifndef SQUID_HTTP_CONTROL_MSG_H +#define SQUID_HTTP_CONTROL_MSG_H + +#include "HttpReply.h" +#include "base/AsyncCall.h" + +class HttpControlMsg; + +/* + * This API exists to throttle forwarding of 1xx messages from the server + * side (Source == HttpStateData) to the client side (Sink == ConnStateData). + * + * Without throttling, Squid would have to drop some 1xx responses to + * avoid DoS attacks that send many 1xx responses without reading them. + * Dropping 1xx responses without violating HTTP is as complex as throttling. + */ + +/// sends a single control message, notifying the Sink +class HttpControlMsgSink: public virtual AsyncJob +{ +public: + HttpControlMsgSink(): AsyncJob("unused") {} + + /// called to send the 1xx message and notify the Source + virtual void sendControlMsg(HttpControlMsg msg) = 0; +}; + +/// bundles HTTP 1xx reply and the "successfully forwarded" callback +class HttpControlMsg +{ +public: + typedef HttpMsgPointerT MsgPtr; + typedef AsyncCall::Pointer Callback; + + HttpControlMsg(const MsgPtr &aReply, const Callback &aCallback): + reply(aReply), cbSuccess(aCallback) {} + +public: + MsgPtr reply; ///< the 1xx message being forwarded + Callback cbSuccess; ///< called after successfully writing the 1xx message + + // We could add an API to notify of send failures as well, but the + // current Source and Sink are tied via Store anyway, so the Source + // will know, eventually, if the Sink is gone or otherwise failed. +}; + +inline std::ostream & +operator <<(std::ostream &os, const HttpControlMsg &msg) +{ + return os << msg.reply << ", " << msg.cbSuccess; +} + +#endif /* SQUID_HTTP_CONTROL_MSG_H */