mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 06:44:39 +02:00
Fix writing headers into std::ostream
This commit is contained in:
committed by
Vinnie Falco
parent
0f5ea371c1
commit
5a7b8b23db
@@ -1,3 +1,11 @@
|
||||
Version 118:
|
||||
|
||||
HTTP:
|
||||
|
||||
* Fix writing header into std::ostream
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Version 117:
|
||||
|
||||
* Add buffers_to_string
|
||||
|
@@ -878,7 +878,7 @@ operator<<(std::ostream& os,
|
||||
header<true, Fields> const& h)
|
||||
{
|
||||
typename Fields::reader fr{
|
||||
h, h.version, h.method()};
|
||||
h, h.version(), h.method()};
|
||||
return os << buffers(fr.get());
|
||||
}
|
||||
|
||||
@@ -888,7 +888,7 @@ operator<<(std::ostream& os,
|
||||
header<false, Fields> const& h)
|
||||
{
|
||||
typename Fields::reader fr{
|
||||
h, h.version, h.result_int()};
|
||||
h, h.version(), h.result_int()};
|
||||
return os << buffers(fr.get());
|
||||
}
|
||||
|
||||
|
@@ -596,14 +596,36 @@ public:
|
||||
void test_std_ostream()
|
||||
{
|
||||
// Conversion to std::string via operator<<
|
||||
request<string_body> m;
|
||||
m.method(verb::get);
|
||||
m.target("/");
|
||||
m.version(11);
|
||||
m.set(field::user_agent, "test");
|
||||
m.body() = "*";
|
||||
BEAST_EXPECT(to_string(m) ==
|
||||
"GET / HTTP/1.1\r\nUser-Agent: test\r\n\r\n*");
|
||||
{
|
||||
request<string_body> m;
|
||||
m.method(verb::get);
|
||||
m.target("/");
|
||||
m.version(11);
|
||||
m.set(field::user_agent, "test");
|
||||
m.body() = "*";
|
||||
BEAST_EXPECT(to_string(m) ==
|
||||
"GET / HTTP/1.1\r\nUser-Agent: test\r\n\r\n*");
|
||||
}
|
||||
|
||||
// Output to std::ostream
|
||||
{
|
||||
request<string_body> m{verb::get, "/", 11};
|
||||
std::stringstream ss;
|
||||
ss << m;
|
||||
BEAST_EXPECT(ss.str() ==
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"\r\n");
|
||||
}
|
||||
|
||||
// Output header to std::ostream
|
||||
{
|
||||
request<string_body> m{verb::get, "/", 11};
|
||||
std::stringstream ss;
|
||||
ss << m.base();
|
||||
BEAST_EXPECT(ss.str() ==
|
||||
"GET / HTTP/1.1\r\n"
|
||||
"\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure completion handlers are not leaked
|
||||
|
Reference in New Issue
Block a user