]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Message.cc
Renamed squid.h to squid-old.h and config.h to squid.h
[thirdparty/squid.git] / src / adaptation / Message.cc
1 /*
2 * DEBUG: section 93 Adaptation
3 */
4
5 #include "squid-old.h"
6 #include "adaptation/Message.h"
7 #include "base/TextException.h"
8 #include "HttpMsg.h"
9
10 Adaptation::Message::Message(): header(NULL)
11 {
12 }
13
14 Adaptation::Message::Message(Header *aHeader): header(NULL)
15 {
16 set(aHeader);
17 }
18
19 Adaptation::Message::~Message()
20 {
21 clear();
22 }
23
24 void
25 Adaptation::Message::clear()
26 {
27 HTTPMSGUNLOCK(header);
28 body_pipe = NULL;
29 }
30
31 void
32 Adaptation::Message::set(Header *aHeader)
33 {
34 clear();
35 if (aHeader) {
36 header = HTTPMSGLOCK(aHeader);
37 body_pipe = header->body_pipe;
38 }
39 }
40
41 void
42 Adaptation::Message::ShortCircuit(Message &src, Message &dest)
43 {
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
55 }
56 dest.set(src.header->clone());
57 }