]>
Commit | Line | Data |
---|---|---|
cb255235 | 1 | /* |
bbc27441 AJ |
2 | * Copyright (C) 1996-2014 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. | |
cb255235 AR |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 93 Adaptation */ |
10 | ||
582c2af2 | 11 | #include "squid.h" |
cb255235 | 12 | #include "adaptation/Message.h" |
3d93a84d AJ |
13 | #include "base/TextException.h" |
14 | #include "HttpMsg.h" | |
cb255235 AR |
15 | |
16 | Adaptation::Message::Message(): header(NULL) | |
17 | { | |
18 | } | |
19 | ||
20 | Adaptation::Message::Message(Header *aHeader): header(NULL) | |
21 | { | |
22 | set(aHeader); | |
23 | } | |
24 | ||
25 | Adaptation::Message::~Message() | |
26 | { | |
27 | clear(); | |
28 | } | |
29 | ||
30 | void | |
31 | Adaptation::Message::clear() | |
32 | { | |
33 | HTTPMSGUNLOCK(header); | |
34 | body_pipe = NULL; | |
35 | } | |
36 | ||
37 | void | |
38 | Adaptation::Message::set(Header *aHeader) | |
39 | { | |
40 | clear(); | |
41 | if (aHeader) { | |
b248c2a3 AJ |
42 | header = aHeader; |
43 | HTTPMSGLOCK(header); | |
cb255235 AR |
44 | body_pipe = header->body_pipe; |
45 | } | |
46 | } | |
47 | ||
48 | void | |
d1649fba | 49 | Adaptation::Message::ShortCircuit(Message &src, Message &dest) |
cb255235 | 50 | { |
d1649fba AR |
51 | Must(!dest.header); // the message is not "used" |
52 | Must(!dest.body_pipe); // can relax if needed, but need !body_pipe->used() | |
53 | Must(src.header); // or there is nothing to shortcircuit | |
54 | ||
55 | if (src.header->body_pipe != NULL) { | |
56 | // check that it would not be too late to shortcircuit the pipe | |
57 | Must(!src.header->body_pipe->consumedSize()); | |
58 | src.header->body_pipe->clearConsumer(); // if any | |
59 | // note: current header->body_pipe producer may later become | |
60 | // dest.body_pipe consumer and consume its own data | |
61 | // TODO: consumer should detect and bypass short-circuit adaptation | |
cb255235 | 62 | } |
d1649fba | 63 | dest.set(src.header->clone()); |
cb255235 | 64 | } |
f53969cc | 65 |