]> git.ipfire.org Git - thirdparty/squid.git/blame - src/http/one/ResponseParser.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / http / one / ResponseParser.h
CommitLineData
ad20e647 1/*
4ac4a490 2 * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
ad20e647
AJ
3 *
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.
7 */
8
f1d5359e
AJ
9#ifndef _SQUID_SRC_HTTP_ONE_RESPONSEPARSER_H
10#define _SQUID_SRC_HTTP_ONE_RESPONSEPARSER_H
11
12#include "http/one/Parser.h"
13#include "http/StatusCode.h"
14
15namespace Http {
16namespace One {
17
18/** HTTP/1.x protocol response parser
19 *
20 * Also capable of parsing unexpected ICY responses and
21 * upgrading HTTP/0.9 syntax responses to HTTP/1.1
22 *
23 * Works on a raw character I/O buffer and tokenizes the content into
24 * the major CRLF delimited segments of an HTTP/1 respone message:
25 *
26 * \item status-line (version SP status SP reash-phrase)
27 * \item mime-header (set of RFC2616 syntax header fields)
28 */
29class ResponseParser : public Http1::Parser
30{
31public:
6da63c70 32 ResponseParser() : Parser(), completedStatus_(false), statusCode_(Http::scNone) {}
f1d5359e
AJ
33 virtual ~ResponseParser() {}
34
35 /* Http::One::Parser API */
36 virtual void clear() {*this=ResponseParser();}
37 virtual Http1::Parser::size_type firstLineSize() const;
38 virtual bool parse(const SBuf &aBuf);
39
40 /* respone specific fields, read-only */
41 Http::StatusCode messageStatus() const { return statusCode_;}
42 SBuf reasonPhrase() const { return reasonPhrase_;}
43
44private:
5aea71e7 45 int parseResponseFirstLine();
f29718b0 46 int parseResponseStatusAndReason(Http1::Tokenizer&, const CharacterSet &);
f1d5359e
AJ
47
48 /// magic prefix for identifying ICY response messages
49 static const SBuf IcyMagic;
50
51 /// Whether we found the status code yet.
52 /// We cannot rely on status value because server may send "000".
53 bool completedStatus_;
54
55 /// HTTP/1 status-line status code
56 Http::StatusCode statusCode_;
57
58 /// HTTP/1 status-line reason phrase
59 SBuf reasonPhrase_;
60};
61
62} // namespace One
63} // namespace Http
64
65#endif /* _SQUID_SRC_HTTP_ONE_RESPONSEPARSER_H */
1810a0cb 66