2 * Copyright (C) 1996-2014 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_CHUNKEDCODINGPARSER_H
10 #define SQUID_CHUNKEDCODINGPARSER_H
15 \ingroup ChunkEncodingAPI Chunked Encoding API
17 * ChunkedCodingParser is an incremental parser for chunked transfer coding
18 * used by HTTP and ICAP. The parser shovels content bytes from the raw
19 * input buffer into the content output buffer, both caller-supplied.
20 * Ignores chunk extensions except for ICAP's ieof.
21 * Has a trailer-handling placeholder.
23 class ChunkedCodingParser
27 ChunkedCodingParser();
32 \retval true complete success
33 \retval false needs more data
36 bool parse(MemBuf
*rawData
, MemBuf
*parsedContent
);
38 bool needsMoreData() const;
39 bool needsMoreSpace() const;
42 typedef void (ChunkedCodingParser::*Step
)();
45 bool mayContinue() const;
47 void parseChunkSize();
48 void parseUnusedChunkExtension();
49 void parseLastChunkExtension();
51 void parseChunkBody();
54 void parseTrailerHeader();
55 void parseMessageEnd();
57 bool findCrlf(size_t &crlfBeg
, size_t &crlfEnd
);
58 bool findCrlf(size_t &crlfBeg
, size_t &crlfEnd
, bool "ed
, bool &slashed
);
61 static Step psChunkSize
;
62 static Step psUnusedChunkExtension
;
63 static Step psLastChunkExtension
;
64 static Step psChunkBody
;
65 static Step psChunkEnd
;
66 static Step psTrailer
;
67 static Step psMessageEnd
;
73 uint64_t theChunkSize
;
74 uint64_t theLeftBodySize
;
76 bool inQuoted
; ///< stores parsing state for incremental findCrlf
77 bool inSlashed
; ///< stores parsing state for incremental findCrlf
80 int64_t useOriginBody
;
83 #endif /* SQUID_CHUNKEDCODINGPARSER_H */