22#include <boost/test/unit_test.hpp>
28template <
typename T,
typename U>
31 return os <<
'(' <<
p.first <<
',' <<
p.second <<
')';
65 bool on_http_message_begin(
CyclTime )
noexcept
71 bool on_http_url(
CyclTime , string_view
sv)
noexcept
73 url_.append(
sv.data(),
sv.size());
76 bool on_http_status(
CyclTime , string_view
sv)
noexcept
78 status_.append(
sv.data(),
sv.size());
81 bool on_http_header_field(
CyclTime , string_view
sv,
First first)
noexcept
83 if (first == First::Yes) {
84 headers_.emplace_back(
string{
sv.data(),
sv.size()},
"");
86 headers_.back().first.append(
sv.data(),
sv.size());
92 headers_.back().second.append(
sv.data(),
sv.size());
95 bool on_http_headers_end(
CyclTime )
noexcept {
return true; }
96 bool on_http_body(
CyclTime , string_view
sv)
noexcept
98 body_.append(
sv.data(),
sv.size());
101 bool on_http_message_end(
CyclTime )
noexcept
109 }
catch (
const std::exception& e) {
110 cerr <<
"exception: " << e.what() <<
endl;
114 bool on_http_chunk_header(
CyclTime ,
size_t )
noexcept {
return true; }
115 bool on_http_chunk_end(
CyclTime )
noexcept {
return true; }
130 "GET /path/to/file/index.html HTTP/1.0\r\n"
133 Parser h{Type::Request};
134 const auto now = CyclTime::now();
150 "HTTP/1.0 404 Not Found\r\n"
153 Parser h{Type::Response};
154 const auto now = CyclTime::now();
170 "GET /path/file.html HTTP/1.0\r\n"
171 "From: someuser@reactivemarkets.com\r\n"
172 "User-Agent: HTTPTool/1.0\r\n"
175 Parser h{Type::Request};
176 const auto now = CyclTime::now();
195 "HTTP/1.0 200 OK\r\n"
196 "Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n"
197 "Content-Type: text/plain\r\n"
198 "Content-Length: 13\r\n"
202 Parser h{Type::Response};
203 const auto now = CyclTime::now();
223 "POST /path/script.cgi HTTP/1.0\r\n"
224 "From: frog@reactivemarkets.com\r\n"
225 "User-Agent: HTTPTool/1.0\r\n"
226 "Content-Type: application/x-www-form-urlencoded\r\n"
227 "Content-Length: 32\r\n"
229 "home=Cosby&favorite+flavor=flies"sv;
231 Parser h{Type::Request};
232 const auto now = CyclTime::now();
245 make_pair(
"Content-Type"s,
"application/x-www-form-urlencoded"s));
254 "GET /path/file.html HTTP/1.1\r\n"
255 "Host: www.host1.com:80\r\n"
258 Parser h{Type::Request};
259 const auto now = CyclTime::now();
277 "HTTP/1.1 200 OK\r\n"
278 "Date: Fri, 31 Dec 1999 23:59:59 GMT\r\n"
279 "Content-Type: text/plain\r\n"
280 "Transfer-Encoding: chunked\r\n"
282 "1a; ignore-stuff-here\r\n"
283 "abcdefghijklmnopqrstuvwxyz\r\n"
285 "1234567890abcdef\r\n"
287 "some-footer: some-value\r\n"
288 "another-footer: another-value\r\n"
291 Parser h{Type::Response};
292 const auto now = CyclTime::now();
314 "POST /path/script.cgi HTTP/1.1\r\n"
315 "Content-Type: text/plain\r\n"
316 "Content-Length: 5\r\n"
319 "POST /path/script.cgi HTTP/1.1\r\n"
320 "Content-Type: text/plain\r\n"
321 "Content-Length: 6\r\n"
325 Parser h{Type::Request};
326 const auto now = CyclTime::now();
BOOST_CHECK_EQUAL(v.size(), 10U)
BOOST_AUTO_TEST_CASE(InitialRequestLineCase)
ostream & operator<<(ostream &os, const pair< T, U > &p)
BOOST_CHECK(isnan(stod(""sv, numeric_limits< double >::quiet_NaN())))