Message.cc
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/* 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
18{
19}
20
21Adaptation::Message::Message(Header *aHeader): header(nullptr)
22{
23 set(aHeader);
24}
25
27{
28 clear();
29}
30
31void
33{
34 HTTPMSGUNLOCK(header);
35 body_pipe = nullptr;
36}
37
38void
40{
41 clear();
42 if (aHeader) {
43 header = aHeader;
44 HTTPMSGLOCK(header);
45 body_pipe = header->body_pipe;
46 }
47}
48
49void
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
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
#define Must(condition)
Definition: TextException.h:75
Header * header
Definition: Message.h:42
static void ShortCircuit(Message &src, Message &dest)
Definition: Message.cc:50
BodyPipePointer body_pipe
Definition: Message.h:46
void set(Header *aHeader)
Definition: Message.cc:39
void clearConsumer()
Definition: BodyPipe.cc:254
uint64_t consumedSize() const
Definition: BodyPipe.h:111
common parts of HttpRequest and HttpReply
Definition: Message.h:26
virtual Http::Message * clone() const =0
BodyPipe::Pointer body_pipe
optional pipeline to receive message body
Definition: Message.h:97
void HTTPMSGUNLOCK(M *&a)
Definition: Message.h:150
void HTTPMSGLOCK(Http::Message *a)
Definition: Message.h:161

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors