]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added HttpControlMsg class and HttpControlMsgSink API to handle 1xx forwarding.
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 10 Sep 2010 23:47:55 +0000 (17:47 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 10 Sep 2010 23:47:55 +0000 (17:47 -0600)
The header was forgotten in r10839 commit. Apparently, "bzr patch" does not
understand what "=== added file" line produced by "bzr diff" means.

src/HttpControlMsg.h [new file with mode: 0644]

diff --git a/src/HttpControlMsg.h b/src/HttpControlMsg.h
new file mode 100644 (file)
index 0000000..a417c34
--- /dev/null
@@ -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<HttpReply> 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 */