]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpBody.cc
2 * $Id: HttpBody.cc,v 1.3 1998/02/21 18:46:32 rousskov Exp $
4 * DEBUG: section 56 HTTP Message Body
5 * AUTHOR: Alex Rousskov
7 * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
8 * --------------------------------------------------------
10 * Squid is the result of efforts by numerous individuals from the
11 * Internet community. Development is led by Duane Wessels of the
12 * National Laboratory for Applied Network Research and funded by
13 * the National Science Foundation.
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
40 httpBodyInit(HttpBody
*body
)
44 body
->freefunc
= NULL
;
48 httpBodyClean(HttpBody
*body
)
52 assert(body
->freefunc
);
53 (*body
->freefunc
)(body
->buf
);
60 httpBodySet(HttpBody
*body
, const char *buf
, int size
, FREE
*freefunc
)
66 assert(buf
[size
-1] == '\0'); /* paranoid */
67 if (!freefunc
) { /* they want us to make our own copy */
68 body
->buf
= xmalloc(size
);
69 xmemcpy(body
->buf
, buf
, size
);
72 body
->freefunc
= freefunc
;
77 httpBodyPackInto(const HttpBody
*body
, Packer
*p
)
80 /* assume it was a 0-terminating buffer */
82 packerAppend(p
, body
->buf
, body
->size
-1);
86 httpBodyPtr(const HttpBody
*body
)
88 return body
->buf
? body
->buf
: "";