]> git.ipfire.org Git - thirdparty/squid.git/blob - src/http/one/TeChunkedParser.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / http / one / TeChunkedParser.h
1 /*
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
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
9 #ifndef SQUID_SRC_HTTP_ONE_TeChunkedParser_H
10 #define SQUID_SRC_HTTP_ONE_TeChunkedParser_H
11
12 #include "http/one/Parser.h"
13
14 class MemBuf;
15
16 namespace Http
17 {
18 namespace One
19 {
20
21 /**
22 * An incremental parser for chunked transfer coding
23 * defined in RFC 7230 section 4.1.
24 * http://tools.ietf.org/html/rfc7230#section-4.1
25 *
26 * The parser shovels content bytes from the raw
27 * input buffer into the content output buffer, both caller-supplied.
28 * Ignores chunk extensions except for ICAP's ieof.
29 * Trailers are available via mimeHeader() if wanted.
30 */
31 class TeChunkedParser : public Http1::Parser
32 {
33 public:
34 TeChunkedParser();
35 virtual ~TeChunkedParser() {theOut=NULL;/* we dont own this object */}
36
37 /// set the buffer to be used to store decoded chunk data
38 void setPayloadBuffer(MemBuf *parsedContent) {theOut = parsedContent;}
39
40 bool needsMoreSpace() const;
41
42 /* Http1::Parser API */
43 virtual void clear();
44 virtual bool parse(const SBuf &);
45 virtual Parser::size_type firstLineSize() const {return 0;} // has no meaning with multiple chunks
46
47 private:
48 bool parseChunkSize(Http1::Tokenizer &tok);
49 bool parseChunkExtension(Http1::Tokenizer &tok, bool skipKnown);
50 bool parseChunkBody(Http1::Tokenizer &tok);
51 bool parseChunkEnd(Http1::Tokenizer &tok);
52
53 MemBuf *theOut;
54 uint64_t theChunkSize;
55 uint64_t theLeftBodySize;
56
57 public:
58 int64_t useOriginBody;
59 };
60
61 } // namespace One
62 } // namespace Http
63
64 #endif /* SQUID_SRC_HTTP_ONE_TeChunkedParser_H */
65