]> git.ipfire.org Git - thirdparty/squid.git/blame - src/http/StatusLine.h
Polish default http_access lines ordering
[thirdparty/squid.git] / src / http / StatusLine.h
CommitLineData
450e0c10 1/*
450e0c10 2 *
3 * SQUID Web Proxy Cache http://www.squid-cache.org/
4 * ----------------------------------------------------------
5 *
6 * Squid is the result of efforts by numerous individuals from
7 * the Internet community; see the CONTRIBUTORS file for full
8 * details. Many organizations have provided support for Squid's
9 * development; see the SPONSORS file for full details. Squid is
10 * Copyrighted (C) 2001 by the Regents of the University of
11 * California; see the COPYRIGHT file for full details. Squid
12 * incorporates software developed and/or copyrighted by other
13 * sources; see the CREDITS file for full details.
14 *
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.
26ac0430 19 *
450e0c10 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.
26ac0430 24 *
450e0c10 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., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
28 *
29 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
30 */
9b769c67
AJ
31#ifndef SQUID_HTTP_STATUSLINE_H
32#define SQUID_HTTP_STATUSLINE_H
450e0c10 33
526ed14e 34#include "http/ProtocolVersion.h"
955394ce 35#include "http/StatusCode.h"
e77d7ef0 36#include "SquidString.h"
450e0c10 37
955394ce
AJ
38class Packer;
39class String;
40
9b769c67
AJ
41namespace Http
42{
43
e77d7ef0
AJ
44/**
45 * Holds the values parsed from an HTTP reply status line.
46 *
9b769c67 47 * For example: HTTP/1.1 200 OK
e77d7ef0 48 */
9b769c67 49class StatusLine
450e0c10 50{
9b769c67
AJ
51public:
52 /// reset this status-line back to empty state
53 void init();
54
55 /// reset this status-line back to Internal Server Error state
56 void clean();
57
58 /// set this status-line to the given values
59 /// when reason is NULL the default message text for this StatusCode will be used
60 void set(const Http::ProtocolVersion &newVersion, Http::StatusCode newStatus, const char *newReason = NULL);
61
62 /// retrieve the status code for this status line
63 const Http::StatusCode status() const { return status_; }
64
65 /// retrieve the reason string for this status line
66 const char *reason() const;
67
68 /// pack fields using Packer
69 void packInto(Packer * p) const;
70
71 /**
72 * Parse a buffer and fill internal structures;
73 * \return true on success, false otherwise
74 */
75 bool parse(const String &protoPrefix, const char *start, const char *end);
76
450e0c10 77public:
78 /* public, read only */
e77d7ef0
AJ
79
80 /**
81 * By rights protocol name should be a constant "HTTP", with no need for this field to exist.
0c3d3f65
AJ
82 * However there are protocols which violate HTTP by sending their own custom formats
83 * back with other protocol names (ICY streaming format being the current major problem).
e77d7ef0 84 */
9b769c67 85 // XXX: protocol is part of Http::ProtocolVersion. We should be able to use version.protocol instead now.
0c3d3f65 86 AnyP::ProtocolType protocol;
e77d7ef0 87
9b769c67
AJ
88 Http::ProtocolVersion version; ///< breakdown of protocol version label: (HTTP/ICY) and (0.9/1.0/1.1)
89
90private:
91 /// status code. ie 100 ... 200 ... 404 ... 599
92 Http::StatusCode status_;
93
94 /// points to a _constant_ string (default or supplied), never free()d
95 const char *reason_;
450e0c10 96};
97
9b769c67
AJ
98} // namespace Http
99
100#endif /* SQUID_HTTP_STATUSLINE_H */