]> git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpBody.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / HttpBody.cc
1 /*
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.
7 */
8
9 /* DEBUG: section 56 HTTP Message Body */
10
11 #include "squid.h"
12 #include "HttpBody.h"
13 #include "MemBuf.h"
14
15 HttpBody::HttpBody() : mb(new MemBuf)
16 {}
17
18 HttpBody::~HttpBody()
19 {
20 delete mb;
21 }
22
23 void
24 HttpBody::clear()
25 {
26 mb->clean();
27 }
28
29 /* set body by absorbing mb */
30 void
31 HttpBody::setMb(MemBuf * mb_)
32 {
33 delete mb;
34 /* note: protection against assign-to-self is not needed
35 * as MemBuf doesn't have a copy-constructor. If such a constructor
36 * is ever added, add such protection here.
37 */
38 mb = mb_; /* absorb */
39 }
40
41 void
42 HttpBody::packInto(Packer * p) const
43 {
44 assert(p);
45
46 if (mb->contentSize())
47 packerAppend(p, mb->content(), mb->contentSize());
48 }
49