]> git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpStatusLine.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / HttpStatusLine.h
1 /*
2 * $Id$
3 *
4 *
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
7 *
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
16 *
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.
21 *
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.
26 *
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., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
30 *
31 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
32 */
33 #ifndef SQUID_HTTPSTATUSLINE_H
34 #define SQUID_HTTPSTATUSLINE_H
35
36 class Packer;
37 class String;
38
39 #include "HttpStatusCode.h"
40 #include "HttpVersion.h"
41 #include "anyp/ProtocolType.h"
42 #include "SquidString.h"
43
44 /**
45 * Holds the values parsed from an HTTP reply status line.
46 *
47 * For example: HTTP/1.1 200 Okay
48 */
49 class HttpStatusLine
50 {
51 public:
52 /* public, read only */
53
54 /**
55 * By rights protocol name should be a constant "HTTP", with no need for this field to exist.
56 * However there are protocols which violate HTTP by sending their own custom formats
57 * back with other protocol names (ICY streaming format being the current major problem).
58 */
59 AnyP::ProtocolType protocol;
60
61 HttpVersion version; ///< breakdown of protocol version labels: 0.9 1.0 1.1
62 http_status status; ///< status code. ie 200 404
63 const char *reason; ///< points to a _constant_ string (default or supplied), never free()d */
64 };
65
66 /* init/clean */
67 SQUIDCEXTERN void httpStatusLineInit(HttpStatusLine * sline);
68 SQUIDCEXTERN void httpStatusLineClean(HttpStatusLine * sline);
69 /* set/get values */
70 SQUIDCEXTERN void httpStatusLineSet(HttpStatusLine * sline, HttpVersion version,
71 http_status status, const char *reason);
72 SQUIDCEXTERN const char *httpStatusLineReason(const HttpStatusLine * sline);
73 /* parse/pack */
74 /* parse a 0-terminating buffer and fill internal structires; returns true on success */
75 SQUIDCEXTERN int httpStatusLineParse(HttpStatusLine * sline, const String &protoPrefix,
76 const char *start, const char *end);
77 /* pack fields using Packer */
78 SQUIDCEXTERN void httpStatusLinePackInto(const HttpStatusLine * sline, Packer * p);
79
80 SQUIDCEXTERN const char *httpStatusString(http_status status);
81
82 #endif /* SQUID_HTTPSTATUSLINE_H */