forked from boostorg/beast
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:
|
Version 117:
|
||||||
|
|
||||||
* Add buffers_to_string
|
* Add buffers_to_string
|
||||||
|
@@ -878,7 +878,7 @@ operator<<(std::ostream& os,
|
|||||||
header<true, Fields> const& h)
|
header<true, Fields> const& h)
|
||||||
{
|
{
|
||||||
typename Fields::reader fr{
|
typename Fields::reader fr{
|
||||||
h, h.version, h.method()};
|
h, h.version(), h.method()};
|
||||||
return os << buffers(fr.get());
|
return os << buffers(fr.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -888,7 +888,7 @@ operator<<(std::ostream& os,
|
|||||||
header<false, Fields> const& h)
|
header<false, Fields> const& h)
|
||||||
{
|
{
|
||||||
typename Fields::reader fr{
|
typename Fields::reader fr{
|
||||||
h, h.version, h.result_int()};
|
h, h.version(), h.result_int()};
|
||||||
return os << buffers(fr.get());
|
return os << buffers(fr.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -596,14 +596,36 @@ public:
|
|||||||
void test_std_ostream()
|
void test_std_ostream()
|
||||||
{
|
{
|
||||||
// Conversion to std::string via operator<<
|
// Conversion to std::string via operator<<
|
||||||
request<string_body> m;
|
{
|
||||||
m.method(verb::get);
|
request<string_body> m;
|
||||||
m.target("/");
|
m.method(verb::get);
|
||||||
m.version(11);
|
m.target("/");
|
||||||
m.set(field::user_agent, "test");
|
m.version(11);
|
||||||
m.body() = "*";
|
m.set(field::user_agent, "test");
|
||||||
BEAST_EXPECT(to_string(m) ==
|
m.body() = "*";
|
||||||
"GET / HTTP/1.1\r\nUser-Agent: test\r\n\r\n*");
|
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
|
// Ensure completion handlers are not leaked
|
||||||
|
Reference in New Issue
Block a user