HttpControlMsg.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
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
9#ifndef SQUID_HTTP_CONTROL_MSG_H
10#define SQUID_HTTP_CONTROL_MSG_H
11
12#include "base/AsyncCall.h"
13#include "HttpReply.h"
14
15class CommIoCbParams;
16class HttpControlMsg;
17
18/*
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.
25 */
26
28class HttpControlMsgSink: public virtual AsyncJob
29{
30public:
32
34 virtual void sendControlMsg(HttpControlMsg msg) = 0;
35
36 virtual void doneWithControlMsg();
37
39 void wroteControlMsg(const CommIoCbParams &);
40
43};
44
47{
48public:
50
51 HttpControlMsg(const HttpReply::Pointer &aReply, const Callback &aCallback):
52 reply(aReply), cbSuccess(aCallback) {}
53
54public:
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
63inline std::ostream &
64operator <<(std::ostream &os, const HttpControlMsg &msg)
65{
66 return os << msg.reply << ", " << msg.cbSuccess;
67}
68
69#endif /* SQUID_HTTP_CONTROL_MSG_H */
70
std::ostream & operator<<(std::ostream &os, const HttpControlMsg &msg)
sends a single control message, notifying the Sink
AsyncCall::Pointer cbControlMsgSent
Call to schedule when the control msg has been sent.
void wroteControlMsg(const CommIoCbParams &)
callback to handle Comm::Write completion
virtual void sendControlMsg(HttpControlMsg msg)=0
called to send the 1xx message and notify the Source
virtual void doneWithControlMsg()
bundles HTTP 1xx reply and the "successfully forwarded" callback
AsyncCall::Pointer Callback
Callback cbSuccess
called after successfully writing the 1xx message
HttpReply::Pointer reply
the 1xx message being forwarded
HttpControlMsg(const HttpReply::Pointer &aReply, const Callback &aCallback)

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors