| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#pragma once |
|
2
|
|
|
|
|
|
|
#include "Request.h" |
|
3
|
|
|
|
|
|
|
#include "Response.h" |
|
4
|
|
|
|
|
|
|
#include "compression/Compressor.h" |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
namespace panda { namespace protocol { namespace http { |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
constexpr const size_t SIZE_UNLIMITED = size_t(-1); |
|
9
|
|
|
|
|
|
|
|
|
10
|
0
|
|
|
|
|
|
struct MessageParser { |
|
11
|
|
|
|
|
|
|
size_t max_headers_size = SIZE_UNLIMITED; |
|
12
|
|
|
|
|
|
|
size_t max_body_size = SIZE_UNLIMITED; |
|
13
|
|
|
|
|
|
|
bool uncompress_content = true; // false have sense only for proxies |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
protected: |
|
16
|
|
|
|
|
|
|
MessageSP message; |
|
17
|
|
|
|
|
|
|
RequestSP request; |
|
18
|
|
|
|
|
|
|
ResponseSP response; |
|
19
|
|
|
|
|
|
|
State state; // high-level state |
|
20
|
|
|
|
|
|
|
int cs; // ragel state |
|
21
|
|
|
|
|
|
|
bool has_content_length; |
|
22
|
|
|
|
|
|
|
uint64_t content_length; |
|
23
|
|
|
|
|
|
|
std::error_code error; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
MessageParser () {} |
|
26
|
|
|
|
|
|
|
MessageParser (const MessageParser&) = delete; |
|
27
|
|
|
|
|
|
|
MessageParser (MessageParser&&) = delete; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
inline void reset () { |
|
30
|
|
|
|
|
|
|
message = nullptr; |
|
31
|
|
|
|
|
|
|
request = nullptr; |
|
32
|
|
|
|
|
|
|
response = nullptr; |
|
33
|
|
|
|
|
|
|
state = State::headers; |
|
34
|
|
|
|
|
|
|
mark = -1; |
|
35
|
|
|
|
|
|
|
marked = false; |
|
36
|
|
|
|
|
|
|
headers_so_far = 0; |
|
37
|
|
|
|
|
|
|
headers_finished = false; |
|
38
|
|
|
|
|
|
|
has_content_length = false; |
|
39
|
|
|
|
|
|
|
content_length = 0; |
|
40
|
|
|
|
|
|
|
body_so_far = 0; |
|
41
|
|
|
|
|
|
|
error.clear(); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
if (compressor) { |
|
44
|
|
|
|
|
|
|
compressor->reset(); |
|
45
|
|
|
|
|
|
|
compressor.reset(); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
template size_t parse (const string& buffer, F1&& after_headers_cb, F2&& no_body_cb); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
void set_error (const std::error_code& e) { |
|
52
|
|
|
|
|
|
|
error = e; |
|
53
|
|
|
|
|
|
|
state = State::error; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
compression::CompressorPtr compressor; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
private: |
|
59
|
|
|
|
|
|
|
ptrdiff_t mark; |
|
60
|
|
|
|
|
|
|
bool marked; |
|
61
|
|
|
|
|
|
|
string acc; |
|
62
|
|
|
|
|
|
|
size_t headers_so_far; |
|
63
|
|
|
|
|
|
|
bool headers_finished; |
|
64
|
|
|
|
|
|
|
size_t body_so_far; |
|
65
|
|
|
|
|
|
|
size_t chunk_length; |
|
66
|
|
|
|
|
|
|
size_t chunk_so_far; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
std::uint8_t compr = 0; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
size_t machine_exec (const string& buffer, size_t off); |
|
71
|
|
|
|
|
|
|
}; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
}}} |