TeChunkedParser.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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 using ::Parser::InsufficientInput;
22 
23 // TODO: Move this class into http/one/ChunkExtensionValueParser.*
30 {
31 public:
32  typedef ::Parser::Tokenizer Tokenizer;
33 
35  static void Ignore(Tokenizer &tok, const SBuf &extName);
36 
38  virtual void parse(Tokenizer &tok, const SBuf &extName) = 0;
39 };
40 
52 {
53 public:
55  virtual ~TeChunkedParser() { theOut=nullptr; /* we do not own this object */ }
56 
58  void setPayloadBuffer(MemBuf *parsedContent) {theOut = parsedContent;}
59 
62  void parseExtensionValuesWith(ChunkExtensionValueParser *parser) { customExtensionValueParser = parser; }
63 
64  bool needsMoreSpace() const;
65 
66  /* Http1::Parser API */
67  virtual void clear();
68  virtual bool parse(const SBuf &);
69  virtual Parser::size_type firstLineSize() const {return 0;} // has no meaning with multiple chunks
70 
71 private:
72  bool parseChunkSize(Tokenizer &tok);
73  bool parseChunkMetadataSuffix(Tokenizer &);
74  void parseChunkExtensions(Tokenizer &);
75  void parseOneChunkExtension(Tokenizer &);
76  bool parseChunkBody(Tokenizer &tok);
77  bool parseChunkEnd(Tokenizer &tok);
78 
80  uint64_t theChunkSize;
81  uint64_t theLeftBodySize;
82 
86 };
87 
88 } // namespace One
89 } // namespace Http
90 
91 #endif /* SQUID_SRC_HTTP_ONE_TeChunkedParser_H */
92 
Definition: SBuf.h:86
SBuf::size_type size_type
Definition: Parser.h:43
ChunkExtensionValueParser * customExtensionValueParser
static void Ignore(Tokenizer &tok, const SBuf &extName)
extracts and ignores the value of a named extension
void parseExtensionValuesWith(ChunkExtensionValueParser *parser)
virtual void parse(Tokenizer &tok, const SBuf &extName)=0
extracts and then interprets (or ignores) the extension value
Definition: parse.c:160
virtual Parser::size_type firstLineSize() const
size in bytes of the first line including CRLF terminator
void setPayloadBuffer(MemBuf *parsedContent)
set the buffer to be used to store decoded chunk data
Definition: MemBuf.h:23
::Parser::Tokenizer Tokenizer
Definition: Parser.h:44
Definition: forward.h:21

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors