]> git.ipfire.org Git - thirdparty/squid.git/blame - src/adaptation/Message.cc
Release Notes: fix bugzilla URL
[thirdparty/squid.git] / src / adaptation / Message.cc
CommitLineData
cb255235 1/*
b510f3a1 2 * DEBUG: section 93 Adaptation
cb255235
AR
3 */
4
582c2af2 5#include "squid.h"
cb255235 6#include "adaptation/Message.h"
3d93a84d
AJ
7#include "base/TextException.h"
8#include "HttpMsg.h"
cb255235
AR
9
10Adaptation::Message::Message(): header(NULL)
11{
12}
13
14Adaptation::Message::Message(Header *aHeader): header(NULL)
15{
16 set(aHeader);
17}
18
19Adaptation::Message::~Message()
20{
21 clear();
22}
23
24void
25Adaptation::Message::clear()
26{
27 HTTPMSGUNLOCK(header);
28 body_pipe = NULL;
29}
30
31void
32Adaptation::Message::set(Header *aHeader)
33{
34 clear();
35 if (aHeader) {
36 header = HTTPMSGLOCK(aHeader);
37 body_pipe = header->body_pipe;
38 }
39}
40
41void
d1649fba 42Adaptation::Message::ShortCircuit(Message &src, Message &dest)
cb255235 43{
d1649fba
AR
44 Must(!dest.header); // the message is not "used"
45 Must(!dest.body_pipe); // can relax if needed, but need !body_pipe->used()
46 Must(src.header); // or there is nothing to shortcircuit
47
48 if (src.header->body_pipe != NULL) {
49 // check that it would not be too late to shortcircuit the pipe
50 Must(!src.header->body_pipe->consumedSize());
51 src.header->body_pipe->clearConsumer(); // if any
52 // note: current header->body_pipe producer may later become
53 // dest.body_pipe consumer and consume its own data
54 // TODO: consumer should detect and bypass short-circuit adaptation
cb255235 55 }
d1649fba 56 dest.set(src.header->clone());
cb255235 57}