]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpBody.cc
4 * $Id: HttpBody.cc,v 1.8 1998/04/09 23:51:40 rousskov Exp $
6 * DEBUG: section 56 HTTP Message Body
7 * AUTHOR: Alex Rousskov
9 * SQUID Internet Object Cache http://squid.nlanr.net/Squid/
10 * --------------------------------------------------------
12 * Squid is the result of efforts by numerous individuals from the
13 * Internet community. Development is led by Duane Wessels of the
14 * National Laboratory for Applied Network Research and funded by
15 * the National Science Foundation.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
42 httpBodyInit(HttpBody
* body
)
46 body
->freefunc
= NULL
;
50 httpBodyClean(HttpBody
* body
)
54 assert(body
->freefunc
);
55 (*body
->freefunc
) (body
->buf
);
61 /* set body, if freefunc is NULL the content will be copied, otherwise not */
63 httpBodySet(HttpBody
* body
, const char *buf
, int size
, FREE
* freefunc
)
69 assert(buf
[size
- 1] == '\0'); /* paranoid */
70 if (!freefunc
) { /* they want us to make our own copy */
71 body
->buf
= xmalloc(size
);
72 xmemcpy(body
->buf
, buf
, size
);
75 /* @?@ @?@ Fix this cast: we should probably have two httpBodySet()s */
76 body
->buf
= (char*)buf
;
78 body
->freefunc
= freefunc
;
83 httpBodyPackInto(const HttpBody
* body
, Packer
* p
)
86 /* assume it was a 0-terminating buffer */
88 packerAppend(p
, body
->buf
, body
->size
- 1);
92 httpBodyPtr(const HttpBody
* body
)
94 return body
->buf
? body
->buf
: "";