]>
Commit | Line | Data |
---|---|---|
774c051c | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
774c051c | 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. | |
774c051c | 7 | */ |
bbc27441 | 8 | |
db1720f8 AJ |
9 | #ifndef SQUID_SRC_HTTP_ONE_TeChunkedParser_H |
10 | #define SQUID_SRC_HTTP_ONE_TeChunkedParser_H | |
51c3e7f0 | 11 | |
350ec67a | 12 | #include "http/one/Parser.h" |
774c051c | 13 | |
e1f7507e | 14 | class MemBuf; |
774c051c | 15 | |
51c3e7f0 AJ |
16 | namespace Http |
17 | { | |
18 | namespace One | |
19 | { | |
20 | ||
e1f7507e | 21 | /** |
db1720f8 | 22 | * An incremental parser for chunked transfer coding |
51c3e7f0 AJ |
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 | |
e1f7507e AJ |
27 | * input buffer into the content output buffer, both caller-supplied. |
28 | * Ignores chunk extensions except for ICAP's ieof. | |
be29ee33 | 29 | * Trailers are available via mimeHeader() if wanted. |
e1f7507e | 30 | */ |
db1720f8 | 31 | class TeChunkedParser : public Http1::Parser |
774c051c | 32 | { |
774c051c | 33 | public: |
db1720f8 AJ |
34 | TeChunkedParser(); |
35 | virtual ~TeChunkedParser() {theOut=NULL;/* we dont own this object */} | |
774c051c | 36 | |
be29ee33 AJ |
37 | /// set the buffer to be used to store decoded chunk data |
38 | void setPayloadBuffer(MemBuf *parsedContent) {theOut = parsedContent;} | |
774c051c | 39 | |
774c051c | 40 | bool needsMoreSpace() const; |
774c051c | 41 | |
350ec67a AJ |
42 | /* Http1::Parser API */ |
43 | virtual void clear(); | |
be29ee33 AJ |
44 | virtual bool parse(const SBuf &); |
45 | virtual Parser::size_type firstLineSize() const {return 0;} // has no meaning with multiple chunks | |
774c051c | 46 | |
47 | private: | |
cb4c8047 AJ |
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); | |
774c051c | 52 | |
774c051c | 53 | MemBuf *theOut; |
47f6e231 | 54 | uint64_t theChunkSize; |
55 | uint64_t theLeftBodySize; | |
83c51da9 CT |
56 | |
57 | public: | |
58 | int64_t useOriginBody; | |
774c051c | 59 | }; |
60 | ||
51c3e7f0 AJ |
61 | } // namespace One |
62 | } // namespace Http | |
63 | ||
db1720f8 | 64 | #endif /* SQUID_SRC_HTTP_ONE_TeChunkedParser_H */ |
f53969cc | 65 |