MCPcopy Create free account
hub / github.com/boostorg/beast / testParse

Method testParse

test/beast/http/parser.cpp:117–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115 }
116
117 void
118 testParse()
119 {
120 doMatrix<false>(
121 "HTTP/1.0 200 OK\r\n"
122 "Server: test\r\n"
123 "\r\n"
124 "Hello, world!",
125 [&](parser_type<false> const& p)
126 {
127 auto const& m = p.get();
128 BEAST_EXPECT(! p.chunked());
129 BEAST_EXPECT(p.need_eof());
130 BEAST_EXPECT(p.content_length() == boost::none);
131 BEAST_EXPECT(m.version() == 10);
132 BEAST_EXPECT(m.result() == status::ok);
133 BEAST_EXPECT(m.reason() == "OK");
134 BEAST_EXPECT(m["Server"] == "test");
135 BEAST_EXPECT(m.body() == "Hello, world!");
136 }
137 );
138 doMatrix<false>(
139 "HTTP/1.1 200 OK\r\n"
140 "Server: test\r\n"
141 "Transfer-Encoding: chunked\r\n"
142 "Trailer: Content-Digest, X-Forwarded-For\r\n"
143 "\r\n"
144 "5\r\n"
145 "*****\r\n"
146 "2;a;b=1;c=\"2\"\r\n"
147 "--\r\n"
148 "0;d;e=3;f=\"4\"\r\n"
149 "Content-Digest: 123\r\n"
150 "Signature: xyz\r\n"
151 "X-Forwarded-For: 203.0.113.195\r\n"
152 "\r\n",
153 [&](parser_type<false> const& p)
154 {
155 auto const& m = p.get();
156 BEAST_EXPECT(! p.need_eof());
157 BEAST_EXPECT(p.chunked());
158 BEAST_EXPECT(p.content_length() == boost::none);
159 BEAST_EXPECT(m.version() == 11);
160 BEAST_EXPECT(m.result() == status::ok);
161 BEAST_EXPECT(m.reason() == "OK");
162 BEAST_EXPECT(m["Server"] == "test");
163 BEAST_EXPECT(m["Transfer-Encoding"] == "chunked");
164 BEAST_EXPECT(m["Content-Digest"] == "123");
165 BEAST_EXPECT(! m.contains("Signature"));
166 BEAST_EXPECT(! m.contains("X-Forwarded-For"));
167 BEAST_EXPECT(m.body() == "*****--");
168 }
169 );
170 doMatrix<false>(
171 "HTTP/1.0 200 OK\r\n"
172 "Server: test\r\n"
173 "Content-Length: 5\r\n"
174 "\r\n"

Callers

nothing calls this directly

Calls 15

chunkedMethod · 0.80
need_eofMethod · 0.80
bodyMethod · 0.80
methodMethod · 0.80
targetMethod · 0.80
eagerMethod · 0.80
messageMethod · 0.80
skipMethod · 0.80
getMethod · 0.45
versionMethod · 0.45
putMethod · 0.45
is_doneMethod · 0.45

Tested by

no test coverage detected