]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/http/StatusLine.h
2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
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.
9 #ifndef SQUID_HTTP_STATUSLINE_H
10 #define SQUID_HTTP_STATUSLINE_H
12 #include "http/ProtocolVersion.h"
13 #include "http/StatusCode.h"
14 #include "SquidString.h"
23 * Holds the values parsed from an HTTP reply status line.
25 * For example: HTTP/1.1 200 OK
30 /// reset this status-line back to empty state
33 /// reset this status-line back to Internal Server Error state
36 /// set this status-line to the given values
37 /// when reason is NULL the default message text for this StatusCode will be used
38 /// when reason is not NULL, it must not point to a dynamically allocated value
39 void set(const AnyP::ProtocolVersion
&newVersion
, Http::StatusCode newStatus
, const char *newReason
= NULL
);
41 /// reset the reason phrase to its default status code-derived value
42 void resetReason() { reason_
= nullptr; }
44 /// retrieve the status code for this status line
45 Http::StatusCode
status() const { return status_
; }
47 /// retrieve the reason string for this status line
48 const char *reason() const;
50 /// pack fields into a Packable object
51 void packInto(Packable
*) const;
54 * Parse a buffer and fill internal structures;
55 * \return true on success, false otherwise
57 bool parse(const String
&protoPrefix
, const char *start
, const char *end
);
60 /* public, read only */
63 * By rights protocol name should be a constant "HTTP", with no need for this field to exist.
64 * However there are protocols which violate HTTP by sending their own custom formats
65 * back with other protocol names (ICY streaming format being the current major problem).
67 // XXX: protocol is part of AnyP::ProtocolVersion. We should be able to use version.protocol instead now.
68 AnyP::ProtocolType protocol
;
70 AnyP::ProtocolVersion version
; ///< breakdown of protocol version label: (HTTP/ICY) and (0.9/1.0/1.1)
73 /// status code. ie 100 ... 200 ... 404 ... 599
74 Http::StatusCode status_
;
76 /// points to a _constant_ string (default or supplied), never free()d
82 #endif /* SQUID_HTTP_STATUSLINE_H */