-
Notifications
You must be signed in to change notification settings - Fork 129
/
body_parser.hh
35 lines (29 loc) · 936 Bytes
/
body_parser.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* -*-mode:c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#ifndef BODY_PARSER_HH
#define BODY_PARSER_HH
class BodyParser
{
public:
/* possible return values from body parser:
- entire string belongs to body
- only some of string (0 bytes to n bytes) belongs to body */
virtual std::string::size_type read( const std::string & str ) = 0;
virtual bool eof( void ) = 0;
};
/* used for RFC 2616 4.4 "rule 5" responses -- terminated only by EOF */
class Rule5BodyParser : public BodyParser
{
public:
/* all of buffer always belongs to body */
std::string::size_type read( const std::string & ) override
{
return std::string::npos;
}
/* does message become complete upon EOF in body? */
/* when there was no content-length header on a response, answer is yes */
bool eof( void ) override
{
return true;
}
};
#endif /* BODY_PARSER_HH */