http write returns success on connection close (API Change):

fix #767

The write family of HTTP stream algorithms no longer returns
error::end_of_stream when the message indicates that the connection
should be closed.

Actions Required:

* Add code to servers to close the connection after successfully
  writing a message where `message::keep_alive()` would return `false`.
This commit is contained in:
Vinnie Falco
2017-10-22 07:03:04 -07:00
parent 885b9dfe0b
commit d0d4e0a740
16 changed files with 122 additions and 83 deletions
+8 -4
View File
@@ -328,7 +328,8 @@ public:
test::stream ts{ios_}, tr{ios_};
ts.connect(tr);
async_write(ts, m, do_yield[ec]);
if(BEAST_EXPECTS(ec == error::end_of_stream, ec.message()))
BEAST_EXPECT(! m.keep_alive());
if(BEAST_EXPECTS(! ec, ec.message()))
BEAST_EXPECT(tr.str() ==
"HTTP/1.0 200 OK\r\n"
"Server: test\r\n"
@@ -406,8 +407,9 @@ public:
m.body() = "*****";
error_code ec = test::error::fail_error;
write(ts, m, ec);
if(ec == error::end_of_stream)
if(! ec)
{
BEAST_EXPECT(! m.keep_alive());
BEAST_EXPECT(tr.str() ==
"GET / HTTP/1.0\r\n"
"User-Agent: test\r\n"
@@ -436,8 +438,9 @@ public:
m.body() = "*****";
error_code ec = test::error::fail_error;
async_write(ts, m, do_yield[ec]);
if(ec == error::end_of_stream)
if(! ec)
{
BEAST_EXPECT(! m.keep_alive());
BEAST_EXPECT(tr.str() ==
"GET / HTTP/1.0\r\n"
"User-Agent: test\r\n"
@@ -543,7 +546,8 @@ public:
ts.connect(tr);
error_code ec;
write(ts, m, ec);
BEAST_EXPECT(ec == error::end_of_stream);
BEAST_EXPECT(! m.keep_alive());
BEAST_EXPECTS(! ec, ec.message());
BEAST_EXPECT(tr.str() ==
"GET / HTTP/1.0\r\n"
"User-Agent: test\r\n"
+1 -1
View File
@@ -484,7 +484,7 @@ public:
};
// wrong version
check(http::error::end_of_stream,
check(error::handshake_failed,
"GET / HTTP/1.0\r\n"
"Host: localhost:80\r\n"
"Upgrade: WebSocket\r\n"