]>
Commit | Line | Data |
---|---|---|
ad20e647 | 1 | /* |
5b74111a | 2 | * Copyright (C) 1996-2018 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 | ||
15 | namespace Http { | |
16 | namespace 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 | */ | |
29 | class ResponseParser : public Http1::Parser | |
30 | { | |
31 | public: | |
20b1beab AJ |
32 | ResponseParser() = default; |
33 | ResponseParser(const ResponseParser &) = default; | |
34 | ResponseParser &operator =(const ResponseParser &) = default; | |
35 | ResponseParser(ResponseParser &&) = default; | |
36 | ResponseParser &operator =(ResponseParser &&) = default; | |
f1d5359e AJ |
37 | virtual ~ResponseParser() {} |
38 | ||
39 | /* Http::One::Parser API */ | |
40 | virtual void clear() {*this=ResponseParser();} | |
41 | virtual Http1::Parser::size_type firstLineSize() const; | |
42 | virtual bool parse(const SBuf &aBuf); | |
43 | ||
44 | /* respone specific fields, read-only */ | |
45 | Http::StatusCode messageStatus() const { return statusCode_;} | |
46 | SBuf reasonPhrase() const { return reasonPhrase_;} | |
47 | ||
48 | private: | |
5aea71e7 | 49 | int parseResponseFirstLine(); |
f29718b0 | 50 | int parseResponseStatusAndReason(Http1::Tokenizer&, const CharacterSet &); |
f1d5359e AJ |
51 | |
52 | /// magic prefix for identifying ICY response messages | |
53 | static const SBuf IcyMagic; | |
54 | ||
55 | /// Whether we found the status code yet. | |
56 | /// We cannot rely on status value because server may send "000". | |
7a010fb2 | 57 | bool completedStatus_ = false; |
f1d5359e AJ |
58 | |
59 | /// HTTP/1 status-line status code | |
7a010fb2 | 60 | Http::StatusCode statusCode_ = Http::scNone; |
f1d5359e AJ |
61 | |
62 | /// HTTP/1 status-line reason phrase | |
63 | SBuf reasonPhrase_; | |
64 | }; | |
65 | ||
66 | } // namespace One | |
67 | } // namespace Http | |
68 | ||
69 | #endif /* _SQUID_SRC_HTTP_ONE_RESPONSEPARSER_H */ | |
1810a0cb | 70 |