]> git.ipfire.org Git - thirdparty/squid.git/blame - src/http/StatusLine.h
Fixed status code-based HTTP reason phrase for eCAP-generated messages.
[thirdparty/squid.git] / src / http / StatusLine.h
CommitLineData
450e0c10 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
450e0c10 3 *
bbc27441
AJ
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.
450e0c10 7 */
bbc27441 8
9b769c67
AJ
9#ifndef SQUID_HTTP_STATUSLINE_H
10#define SQUID_HTTP_STATUSLINE_H
450e0c10 11
526ed14e 12#include "http/ProtocolVersion.h"
955394ce 13#include "http/StatusCode.h"
e77d7ef0 14#include "SquidString.h"
450e0c10 15
17802cf1 16class Packable;
955394ce
AJ
17class String;
18
9b769c67
AJ
19namespace Http
20{
21
e77d7ef0
AJ
22/**
23 * Holds the values parsed from an HTTP reply status line.
24 *
9b769c67 25 * For example: HTTP/1.1 200 OK
e77d7ef0 26 */
9b769c67 27class StatusLine
450e0c10 28{
9b769c67
AJ
29public:
30 /// reset this status-line back to empty state
31 void init();
32
33 /// reset this status-line back to Internal Server Error state
34 void clean();
35
36 /// set this status-line to the given values
37 /// when reason is NULL the default message text for this StatusCode will be used
2592bc70 38 void set(const AnyP::ProtocolVersion &newVersion, Http::StatusCode newStatus, const char *newReason = NULL);
9b769c67
AJ
39
40 /// retrieve the status code for this status line
e3b44909 41 Http::StatusCode status() const { return status_; }
9b769c67
AJ
42
43 /// retrieve the reason string for this status line
44 const char *reason() const;
45
0a647ffb
AJ
46 /// pack fields into a Packable object
47 void packInto(Packable *) const;
9b769c67
AJ
48
49 /**
50 * Parse a buffer and fill internal structures;
51 * \return true on success, false otherwise
52 */
53 bool parse(const String &protoPrefix, const char *start, const char *end);
54
450e0c10 55public:
56 /* public, read only */
e77d7ef0
AJ
57
58 /**
59 * By rights protocol name should be a constant "HTTP", with no need for this field to exist.
0c3d3f65
AJ
60 * However there are protocols which violate HTTP by sending their own custom formats
61 * back with other protocol names (ICY streaming format being the current major problem).
e77d7ef0 62 */
2592bc70 63 // XXX: protocol is part of AnyP::ProtocolVersion. We should be able to use version.protocol instead now.
0c3d3f65 64 AnyP::ProtocolType protocol;
e77d7ef0 65
2592bc70 66 AnyP::ProtocolVersion version; ///< breakdown of protocol version label: (HTTP/ICY) and (0.9/1.0/1.1)
9b769c67
AJ
67
68private:
69 /// status code. ie 100 ... 200 ... 404 ... 599
70 Http::StatusCode status_;
71
72 /// points to a _constant_ string (default or supplied), never free()d
73 const char *reason_;
450e0c10 74};
75
9b769c67
AJ
76} // namespace Http
77
78#endif /* SQUID_HTTP_STATUSLINE_H */
f53969cc 79