Squid Web Cache
master
Loading...
Searching...
No Matches
Message.cc
Go to the documentation of this file.
1
/*
2
* Copyright (C) 1996-2025 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
/* DEBUG: section 93 Adaptation */
10
11
#include "
squid.h
"
12
#include "
adaptation/Message.h
"
13
#include "
base/TextException.h
"
14
#include "
BodyPipe.h
"
15
#include "
http/Message.h
"
16
17
Adaptation::Message::Message
(): header(nullptr)
18
{
19
}
20
21
Adaptation::Message::Message
(
Header
*aHeader): header(nullptr)
22
{
23
set
(aHeader);
24
}
25
26
Adaptation::Message::~Message
()
27
{
28
clear();
29
}
30
31
void
32
Adaptation::Message::clear
()
33
{
34
HTTPMSGUNLOCK
(header);
35
body_pipe =
nullptr
;
36
}
37
38
void
39
Adaptation::Message::set
(
Header
*aHeader)
40
{
41
clear();
42
if
(aHeader) {
43
header = aHeader;
44
HTTPMSGLOCK
(header);
45
body_pipe = header->body_pipe;
46
}
47
}
48
49
void
50
Adaptation::Message::ShortCircuit
(
Message
&src,
Message
&dest)
51
{
52
Must
(!dest.
header
);
// the message is not "used"
53
Must
(!dest.
body_pipe
);
// can relax if needed, but need !body_pipe->used()
54
Must
(src.
header
);
// or there is nothing to shortcircuit
55
56
if
(src.
header
->
body_pipe
!=
nullptr
) {
57
// check that it would not be too late to shortcircuit the pipe
58
Must
(!src.
header
->
body_pipe
->
consumedSize
());
59
src.
header
->
body_pipe
->
clearConsumer
();
// if any
60
// note: current header->body_pipe producer may later become
61
// dest.body_pipe consumer and consume its own data
62
// TODO: consumer should detect and bypass short-circuit adaptation
63
}
64
dest.
set
(src.
header
->
clone
());
65
}
66
BodyPipe.h
TextException.h
Must
#define Must(condition)
Definition
TextException.h:75
Message.h
Adaptation::Message
Definition
Message.h:26
Adaptation::Message::header
Header * header
Definition
Message.h:42
Adaptation::Message::~Message
~Message()
Definition
Message.cc:26
Adaptation::Message::clear
void clear()
Definition
Message.cc:32
Adaptation::Message::ShortCircuit
static void ShortCircuit(Message &src, Message &dest)
Definition
Message.cc:50
Adaptation::Message::Message
Message()
Definition
Message.cc:17
Adaptation::Message::body_pipe
BodyPipePointer body_pipe
Definition
Message.h:46
Adaptation::Message::set
void set(Header *aHeader)
Definition
Message.cc:39
BodyPipe::clearConsumer
void clearConsumer()
Definition
BodyPipe.cc:254
BodyPipe::consumedSize
uint64_t consumedSize() const
Definition
BodyPipe.h:111
Http::Message
common parts of HttpRequest and HttpReply
Definition
Message.h:26
Http::Message::clone
virtual Http::Message * clone() const =0
Http::Message::body_pipe
BodyPipe::Pointer body_pipe
optional pipeline to receive message body
Definition
Message.h:97
Message.h
HTTPMSGUNLOCK
void HTTPMSGUNLOCK(M *&a)
Definition
Message.h:150
HTTPMSGLOCK
void HTTPMSGLOCK(Http::Message *a)
Definition
Message.h:161
squid.h
squid
src
adaptation
Message.cc
Generated by
1.9.8