mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 12:57:31 +02:00
@ -9,6 +9,7 @@ Version 61:
|
|||||||
* Flush the output stream in the example
|
* Flush the output stream in the example
|
||||||
* Clean close in Secure WebSocket client
|
* Clean close in Secure WebSocket client
|
||||||
* Add server-framework SSL HTTP and WebSocket ports
|
* Add server-framework SSL HTTP and WebSocket ports
|
||||||
|
* Fix shadowing warnings
|
||||||
|
|
||||||
API Changes:
|
API Changes:
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ receive_expect_100_continue(
|
|||||||
response<empty_body> res;
|
response<empty_body> res;
|
||||||
res.version = 11;
|
res.version = 11;
|
||||||
res.result(status::continue_);
|
res.result(status::continue_);
|
||||||
res.insert(field::server, "test");
|
res.set(field::server, "test");
|
||||||
write(stream, res, ec);
|
write(stream, res, ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
return;
|
return;
|
||||||
@ -199,8 +199,8 @@ send_cgi_response(
|
|||||||
|
|
||||||
res.result(status::ok);
|
res.result(status::ok);
|
||||||
res.version = 11;
|
res.version = 11;
|
||||||
res.insert(field::server, "Beast");
|
res.set(field::server, "Beast");
|
||||||
res.insert(field::transfer_encoding, "chunked");
|
res.set(field::transfer_encoding, "chunked");
|
||||||
|
|
||||||
// No data yet, but we set more = true to indicate
|
// No data yet, but we set more = true to indicate
|
||||||
// that it might be coming later. Otherwise the
|
// that it might be coming later. Otherwise the
|
||||||
@ -308,7 +308,7 @@ void do_server_head(
|
|||||||
// Set up the response, starting with the common fields
|
// Set up the response, starting with the common fields
|
||||||
response<string_body> res;
|
response<string_body> res;
|
||||||
res.version = 11;
|
res.version = 11;
|
||||||
res.insert(field::server, "test");
|
res.set(field::server, "test");
|
||||||
|
|
||||||
// Now handle request-specific fields
|
// Now handle request-specific fields
|
||||||
switch(req.method())
|
switch(req.method())
|
||||||
@ -338,7 +338,7 @@ void do_server_head(
|
|||||||
// We return responses indicating an error if
|
// We return responses indicating an error if
|
||||||
// we do not recognize the request method.
|
// we do not recognize the request method.
|
||||||
res.result(status::bad_request);
|
res.result(status::bad_request);
|
||||||
res.insert(field::content_type, "text/plain");
|
res.set(field::content_type, "text/plain");
|
||||||
res.body = "Invalid request-method '" + req.method_string().to_string() + "'";
|
res.body = "Invalid request-method '" + req.method_string().to_string() + "'";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -398,11 +398,11 @@ do_head_request(
|
|||||||
req.version = 11;
|
req.version = 11;
|
||||||
req.method(verb::head);
|
req.method(verb::head);
|
||||||
req.target(target);
|
req.target(target);
|
||||||
req.insert(field::user_agent, "test");
|
req.set(field::user_agent, "test");
|
||||||
|
|
||||||
// A client MUST send a Host header field in all HTTP/1.1 request messages.
|
// A client MUST send a Host header field in all HTTP/1.1 request messages.
|
||||||
// https://tools.ietf.org/html/rfc7230#section-5.4
|
// https://tools.ietf.org/html/rfc7230#section-5.4
|
||||||
req.insert(field::host, "localhost");
|
req.set(field::host, "localhost");
|
||||||
|
|
||||||
// Now send it
|
// Now send it
|
||||||
write(stream, req, ec);
|
write(stream, req, ec);
|
||||||
|
@ -83,9 +83,9 @@ struct iless
|
|||||||
using std::end;
|
using std::end;
|
||||||
return std::lexicographical_compare(
|
return std::lexicographical_compare(
|
||||||
begin(lhs), end(lhs), begin(rhs), end(rhs),
|
begin(lhs), end(lhs), begin(rhs), end(rhs),
|
||||||
[](char lhs, char rhs)
|
[](char c1, char c2)
|
||||||
{
|
{
|
||||||
return detail::ascii_tolower(lhs) < detail::ascii_tolower(rhs);
|
return detail::ascii_tolower(c1) < detail::ascii_tolower(c2);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,12 @@ parser(Arg1&& arg1, ArgN&&... argn)
|
|||||||
template<bool isRequest, class Body, class Fields>
|
template<bool isRequest, class Body, class Fields>
|
||||||
template<class OtherBody, class... Args, class>
|
template<class OtherBody, class... Args, class>
|
||||||
parser<isRequest, Body, Fields>::
|
parser<isRequest, Body, Fields>::
|
||||||
parser(parser<isRequest, OtherBody, Fields>&& parser,
|
parser(parser<isRequest, OtherBody, Fields>&& p,
|
||||||
Args&&... args)
|
Args&&... args)
|
||||||
: base_type(std::move(parser))
|
: base_type(std::move(p))
|
||||||
, m_(parser.release(), std::forward<Args>(args)...)
|
, m_(p.release(), std::forward<Args>(args)...)
|
||||||
{
|
{
|
||||||
if(parser.wr_)
|
if(p.wr_)
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
BOOST_THROW_EXCEPTION(std::invalid_argument{
|
||||||
"moved-from parser has a body"});
|
"moved-from parser has a body"});
|
||||||
}
|
}
|
||||||
|
@ -538,7 +538,7 @@ struct message : header<isRequest, Fields>
|
|||||||
req.version = 11;
|
req.version = 11;
|
||||||
req.method(verb::upgrade);
|
req.method(verb::upgrade);
|
||||||
req.target("/");
|
req.target("/");
|
||||||
req.insert(field::user_agent, "Beast");
|
req.set(field::user_agent, "Beast");
|
||||||
req.body = "Hello, world!";
|
req.body = "Hello, world!";
|
||||||
req.prepare();
|
req.prepare();
|
||||||
@endcode
|
@endcode
|
||||||
|
@ -532,10 +532,10 @@ template<class DynamicBuffer>
|
|||||||
void
|
void
|
||||||
stream_base::
|
stream_base::
|
||||||
write_ping(DynamicBuffer& db,
|
write_ping(DynamicBuffer& db,
|
||||||
detail::opcode op, ping_data const& data)
|
detail::opcode code, ping_data const& data)
|
||||||
{
|
{
|
||||||
frame_header fh;
|
frame_header fh;
|
||||||
fh.op = op;
|
fh.op = code;
|
||||||
fh.fin = true;
|
fh.fin = true;
|
||||||
fh.rsv1 = false;
|
fh.rsv1 = false;
|
||||||
fh.rsv2 = false;
|
fh.rsv2 = false;
|
||||||
|
@ -145,40 +145,40 @@ utf8_checker_t<_>::
|
|||||||
write(std::uint8_t const* in, std::size_t size)
|
write(std::uint8_t const* in, std::size_t size)
|
||||||
{
|
{
|
||||||
auto const valid =
|
auto const valid =
|
||||||
[](std::uint8_t const*& in)
|
[](std::uint8_t const*& p)
|
||||||
{
|
{
|
||||||
if (in[0] < 128)
|
if (p[0] < 128)
|
||||||
{
|
{
|
||||||
++in;
|
++p;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((in[0] & 0x60) == 0x40)
|
if ((p[0] & 0x60) == 0x40)
|
||||||
{
|
{
|
||||||
if ((in[1] & 0xc0) != 0x80)
|
if ((p[1] & 0xc0) != 0x80)
|
||||||
return false;
|
return false;
|
||||||
in += 2;
|
p += 2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((in[0] & 0xf0) == 0xe0)
|
if ((p[0] & 0xf0) == 0xe0)
|
||||||
{
|
{
|
||||||
if ((in[1] & 0xc0) != 0x80 ||
|
if ((p[1] & 0xc0) != 0x80 ||
|
||||||
(in[2] & 0xc0) != 0x80 ||
|
(p[2] & 0xc0) != 0x80 ||
|
||||||
(in[0] == 224 && in[1] < 160) ||
|
(p[0] == 224 && p[1] < 160) ||
|
||||||
(in[0] == 237 && in[1] > 159))
|
(p[0] == 237 && p[1] > 159))
|
||||||
return false;
|
return false;
|
||||||
in += 3;
|
p += 3;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((in[0] & 0xf8) == 0xf0)
|
if ((p[0] & 0xf8) == 0xf0)
|
||||||
{
|
{
|
||||||
if (in[0] > 244 ||
|
if (p[0] > 244 ||
|
||||||
(in[1] & 0xc0) != 0x80 ||
|
(p[1] & 0xc0) != 0x80 ||
|
||||||
(in[2] & 0xc0) != 0x80 ||
|
(p[2] & 0xc0) != 0x80 ||
|
||||||
(in[3] & 0xc0) != 0x80 ||
|
(p[3] & 0xc0) != 0x80 ||
|
||||||
(in[0] == 240 && in[1] < 144) ||
|
(p[0] == 240 && p[1] < 144) ||
|
||||||
(in[0] == 244 && in[1] > 143))
|
(p[0] == 244 && p[1] > 143))
|
||||||
return false;
|
return false;
|
||||||
in += 4;
|
p += 4;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -199,10 +199,10 @@ write(std::uint8_t const* in, std::size_t size)
|
|||||||
}
|
}
|
||||||
if ((have_[0] & 0xf8) == 0xf0)
|
if ((have_[0] & 0xf8) == 0xf0)
|
||||||
{
|
{
|
||||||
auto const size = p_ - have_;
|
auto const n = p_ - have_;
|
||||||
if (size > 2 && (have_[2] & 0xc0) != 0x80)
|
if (n > 2 && (have_[2] & 0xc0) != 0x80)
|
||||||
return false;
|
return false;
|
||||||
if (size > 1 &&
|
if (n > 1 &&
|
||||||
((have_[1] & 0xc0) != 0x80 ||
|
((have_[1] & 0xc0) != 0x80 ||
|
||||||
(have_[0] == 240 && have_[1] < 144) ||
|
(have_[0] == 240 && have_[1] < 144) ||
|
||||||
(have_[0] == 244 && have_[1] > 143)))
|
(have_[0] == 244 && have_[1] > 143)))
|
||||||
@ -211,17 +211,17 @@ write(std::uint8_t const* in, std::size_t size)
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
auto const needed =
|
auto const needed =
|
||||||
[](std::uint8_t const in)
|
[](std::uint8_t const v)
|
||||||
{
|
{
|
||||||
if (in < 128)
|
if (v < 128)
|
||||||
return 1;
|
return 1;
|
||||||
if (in < 194)
|
if (v < 194)
|
||||||
return 0;
|
return 0;
|
||||||
if (in < 224)
|
if (v < 224)
|
||||||
return 2;
|
return 2;
|
||||||
if (in < 240)
|
if (v < 240)
|
||||||
return 3;
|
return 3;
|
||||||
if (in < 245)
|
if (v < 245)
|
||||||
return 4;
|
return 4;
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
@ -164,12 +164,12 @@ build_request(detail::sec_ws_key_type& key,
|
|||||||
req.target(target);
|
req.target(target);
|
||||||
req.version = 11;
|
req.version = 11;
|
||||||
req.method(http::verb::get);
|
req.method(http::verb::get);
|
||||||
req.insert(http::field::host, host);
|
req.set(http::field::host, host);
|
||||||
req.insert(http::field::upgrade, "websocket");
|
req.set(http::field::upgrade, "websocket");
|
||||||
req.insert(http::field::connection, "upgrade");
|
req.set(http::field::connection, "upgrade");
|
||||||
detail::make_sec_ws_key(key, maskgen_);
|
detail::make_sec_ws_key(key, maskgen_);
|
||||||
req.insert(http::field::sec_websocket_key, key);
|
req.set(http::field::sec_websocket_key, key);
|
||||||
req.insert(http::field::sec_websocket_version, "13");
|
req.set(http::field::sec_websocket_version, "13");
|
||||||
if(pmd_opts_.client_enable)
|
if(pmd_opts_.client_enable)
|
||||||
{
|
{
|
||||||
detail::pmd_offer config;
|
detail::pmd_offer config;
|
||||||
@ -186,7 +186,7 @@ build_request(detail::sec_ws_key_type& key,
|
|||||||
}
|
}
|
||||||
decorator(req);
|
decorator(req);
|
||||||
if(! req.count(http::field::user_agent))
|
if(! req.count(http::field::user_agent))
|
||||||
req.insert(http::field::user_agent,
|
req.set(http::field::user_agent,
|
||||||
BEAST_VERSION_STRING);
|
BEAST_VERSION_STRING);
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ build_response(http::header<true, Fields> const& req,
|
|||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT(sizeof(BEAST_VERSION_STRING) < 20);
|
BOOST_STATIC_ASSERT(sizeof(BEAST_VERSION_STRING) < 20);
|
||||||
static_string<20> s(BEAST_VERSION_STRING);
|
static_string<20> s(BEAST_VERSION_STRING);
|
||||||
res.insert(http::field::server, s);
|
res.set(http::field::server, s);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
auto err =
|
auto err =
|
||||||
@ -245,7 +245,7 @@ build_response(http::header<true, Fields> const& req,
|
|||||||
response_type res;
|
response_type res;
|
||||||
res.result(http::status::upgrade_required);
|
res.result(http::status::upgrade_required);
|
||||||
res.version = req.version;
|
res.version = req.version;
|
||||||
res.insert(http::field::sec_websocket_version, "13");
|
res.set(http::field::sec_websocket_version, "13");
|
||||||
res.prepare();
|
res.prepare();
|
||||||
decorate(res);
|
decorate(res);
|
||||||
return res;
|
return res;
|
||||||
@ -261,12 +261,12 @@ build_response(http::header<true, Fields> const& req,
|
|||||||
}
|
}
|
||||||
res.result(http::status::switching_protocols);
|
res.result(http::status::switching_protocols);
|
||||||
res.version = req.version;
|
res.version = req.version;
|
||||||
res.insert(http::field::upgrade, "websocket");
|
res.set(http::field::upgrade, "websocket");
|
||||||
res.insert(http::field::connection, "upgrade");
|
res.set(http::field::connection, "upgrade");
|
||||||
{
|
{
|
||||||
detail::sec_ws_accept_type accept;
|
detail::sec_ws_accept_type acc;
|
||||||
detail::make_sec_ws_accept(accept, key);
|
detail::make_sec_ws_accept(acc, key);
|
||||||
res.insert(http::field::sec_websocket_accept, accept);
|
res.set(http::field::sec_websocket_accept, acc);
|
||||||
}
|
}
|
||||||
decorate(res);
|
decorate(res);
|
||||||
return res;
|
return res;
|
||||||
@ -290,9 +290,9 @@ do_response(http::header<false> const& res,
|
|||||||
return false;
|
return false;
|
||||||
if(res.count(http::field::sec_websocket_accept) != 1)
|
if(res.count(http::field::sec_websocket_accept) != 1)
|
||||||
return false;
|
return false;
|
||||||
detail::sec_ws_accept_type accept;
|
detail::sec_ws_accept_type acc;
|
||||||
detail::make_sec_ws_accept(accept, key);
|
detail::make_sec_ws_accept(acc, key);
|
||||||
if(accept.compare(
|
if(acc.compare(
|
||||||
res[http::field::sec_websocket_accept]) != 0)
|
res[http::field::sec_websocket_accept]) != 0)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1759,7 +1759,7 @@ public:
|
|||||||
ws.handshake("localhost", "/",
|
ws.handshake("localhost", "/",
|
||||||
[](request_type& req)
|
[](request_type& req)
|
||||||
{
|
{
|
||||||
req.insert(field::user_agent, "Beast");
|
req.set(field::user_agent, "Beast");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
@ -1820,7 +1820,7 @@ public:
|
|||||||
ws.handshake(res, "localhost", "/",
|
ws.handshake(res, "localhost", "/",
|
||||||
[](request_type& req)
|
[](request_type& req)
|
||||||
{
|
{
|
||||||
req.insert(field::user_agent, "Beast");
|
req.set(field::user_agent, "Beast");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
@ -1963,7 +1963,7 @@ public:
|
|||||||
ws.handshake("localhost", "/",
|
ws.handshake("localhost", "/",
|
||||||
[](request_type& req)
|
[](request_type& req)
|
||||||
{
|
{
|
||||||
req.insert(field::user_agent, "Beast");
|
req.set(field::user_agent, "Beast");
|
||||||
},
|
},
|
||||||
ec);
|
ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
@ -2024,7 +2024,7 @@ public:
|
|||||||
ws.handshake(res, "localhost", "/",
|
ws.handshake(res, "localhost", "/",
|
||||||
[](request_type& req)
|
[](request_type& req)
|
||||||
{
|
{
|
||||||
req.insert(field::user_agent, "Beast");
|
req.set(field::user_agent, "Beast");
|
||||||
},
|
},
|
||||||
ec);
|
ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
|
@ -2282,18 +2282,18 @@ fill_window(z_params& zs)
|
|||||||
if(high_water_ < window_size_)
|
if(high_water_ < window_size_)
|
||||||
{
|
{
|
||||||
std::uint32_t curr = strstart_ + (std::uint32_t)(lookahead_);
|
std::uint32_t curr = strstart_ + (std::uint32_t)(lookahead_);
|
||||||
std::uint32_t init;
|
std::uint32_t winit;
|
||||||
|
|
||||||
if(high_water_ < curr)
|
if(high_water_ < curr)
|
||||||
{
|
{
|
||||||
/* Previous high water mark below current data -- zero kWinInit
|
/* Previous high water mark below current data -- zero kWinInit
|
||||||
bytes or up to end of window, whichever is less.
|
bytes or up to end of window, whichever is less.
|
||||||
*/
|
*/
|
||||||
init = window_size_ - curr;
|
winit = window_size_ - curr;
|
||||||
if(init > kWinInit)
|
if(winit > kWinInit)
|
||||||
init = kWinInit;
|
winit = kWinInit;
|
||||||
std::memset(window_ + curr, 0, (unsigned)init);
|
std::memset(window_ + curr, 0, (unsigned)winit);
|
||||||
high_water_ = curr + init;
|
high_water_ = curr + winit;
|
||||||
}
|
}
|
||||||
else if(high_water_ < (std::uint32_t)curr + kWinInit)
|
else if(high_water_ < (std::uint32_t)curr + kWinInit)
|
||||||
{
|
{
|
||||||
@ -2301,11 +2301,11 @@ fill_window(z_params& zs)
|
|||||||
plus kWinInit -- zero out to current data plus kWinInit, or up
|
plus kWinInit -- zero out to current data plus kWinInit, or up
|
||||||
to end of window, whichever is less.
|
to end of window, whichever is less.
|
||||||
*/
|
*/
|
||||||
init = (std::uint32_t)curr + kWinInit - high_water_;
|
winit = (std::uint32_t)curr + kWinInit - high_water_;
|
||||||
if(init > window_size_ - high_water_)
|
if(winit > window_size_ - high_water_)
|
||||||
init = window_size_ - high_water_;
|
winit = window_size_ - high_water_;
|
||||||
std::memset(window_ + high_water_, 0, (unsigned)init);
|
std::memset(window_ + high_water_, 0, (unsigned)winit);
|
||||||
high_water_ += init;
|
high_water_ += winit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,15 +207,15 @@ public:
|
|||||||
// base
|
// base
|
||||||
{
|
{
|
||||||
static_buffer_n<10> b;
|
static_buffer_n<10> b;
|
||||||
[&](static_buffer& b)
|
[&](static_buffer& base)
|
||||||
{
|
{
|
||||||
BEAST_EXPECT(b.max_size() == b.capacity());
|
BEAST_EXPECT(base.max_size() == b.capacity());
|
||||||
}
|
}
|
||||||
(b.base());
|
(b.base());
|
||||||
|
|
||||||
[&](static_buffer const&)
|
[&](static_buffer const& base)
|
||||||
{
|
{
|
||||||
BEAST_EXPECT(b.max_size() == b.capacity());
|
BEAST_EXPECT(base.max_size() == b.capacity());
|
||||||
}
|
}
|
||||||
(b.base());
|
(b.base());
|
||||||
}
|
}
|
||||||
|
@ -120,9 +120,9 @@ public:
|
|||||||
|
|
||||||
flat_buffer buffer;
|
flat_buffer buffer;
|
||||||
relay<true>(upstream.client, downstream.server, buffer, ec,
|
relay<true>(upstream.client, downstream.server, buffer, ec,
|
||||||
[&](header<true, fields>& h, error_code& ec)
|
[&](header<true, fields>& h, error_code& ev)
|
||||||
{
|
{
|
||||||
ec = {};
|
ev = {};
|
||||||
h.erase("Content-Length");
|
h.erase("Content-Length");
|
||||||
h.set("Transfer-Encoding", "chunked");
|
h.set("Transfer-Encoding", "chunked");
|
||||||
});
|
});
|
||||||
|
@ -26,7 +26,6 @@ void fxx() {
|
|||||||
boost::asio::io_service ios;
|
boost::asio::io_service ios;
|
||||||
boost::asio::io_service::work work{ios};
|
boost::asio::io_service::work work{ios};
|
||||||
std::thread t{[&](){ ios.run(); }};
|
std::thread t{[&](){ ios.run(); }};
|
||||||
error_code ec;
|
|
||||||
boost::asio::ip::tcp::socket sock{ios};
|
boost::asio::ip::tcp::socket sock{ios};
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -36,8 +35,8 @@ void fxx() {
|
|||||||
req.version = 11; // HTTP/1.1
|
req.version = 11; // HTTP/1.1
|
||||||
req.method(verb::get);
|
req.method(verb::get);
|
||||||
req.target("/index.htm");
|
req.target("/index.htm");
|
||||||
req.insert(field::accept, "text/html");
|
req.set(field::accept, "text/html");
|
||||||
req.insert(field::user_agent, "Beast");
|
req.set(field::user_agent, "Beast");
|
||||||
|
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
@ -48,7 +47,7 @@ void fxx() {
|
|||||||
response<string_body> res;
|
response<string_body> res;
|
||||||
res.version = 11; // HTTP/1.1
|
res.version = 11; // HTTP/1.1
|
||||||
res.result(status::ok);
|
res.result(status::ok);
|
||||||
res.insert(field::server, "Beast");
|
res.set(field::server, "Beast");
|
||||||
res.body = "Hello, world!";
|
res.body = "Hello, world!";
|
||||||
res.prepare();
|
res.prepare();
|
||||||
|
|
||||||
@ -86,6 +85,7 @@ void fxx() {
|
|||||||
flat_buffer buffer{10};
|
flat_buffer buffer{10};
|
||||||
|
|
||||||
// Try to read a request
|
// Try to read a request
|
||||||
|
error_code ec;
|
||||||
request<string_body> req;
|
request<string_body> req;
|
||||||
read(sock, buffer, req, ec);
|
read(sock, buffer, req, ec);
|
||||||
if(ec == error::buffer_overflow)
|
if(ec == error::buffer_overflow)
|
||||||
@ -100,9 +100,10 @@ void fxx() {
|
|||||||
response<string_body> res;
|
response<string_body> res;
|
||||||
res.version = 11;
|
res.version = 11;
|
||||||
res.result(status::ok);
|
res.result(status::ok);
|
||||||
res.insert(field::server, "Beast");
|
res.set(field::server, "Beast");
|
||||||
res.body = "Hello, world!";
|
res.body = "Hello, world!";
|
||||||
|
|
||||||
|
error_code ec;
|
||||||
write(sock, res, ec);
|
write(sock, res, ec);
|
||||||
if(ec == error::end_of_stream)
|
if(ec == error::end_of_stream)
|
||||||
sock.close();
|
sock.close();
|
||||||
|
@ -63,18 +63,18 @@ public:
|
|||||||
BEAST_EXPECTS(got == s, fmt(got));
|
BEAST_EXPECTS(got == s, fmt(got));
|
||||||
};
|
};
|
||||||
auto const cs =
|
auto const cs =
|
||||||
[&](std::string const& s, std::string const& good)
|
[&](std::string const& s, std::string const& answer)
|
||||||
{
|
{
|
||||||
ce(good);
|
ce(answer);
|
||||||
auto const got = str(param_list{s});
|
auto const got = str(param_list{s});
|
||||||
ce(got);
|
ce(got);
|
||||||
BEAST_EXPECTS(got == good, fmt(got));
|
BEAST_EXPECTS(got == answer, fmt(got));
|
||||||
};
|
};
|
||||||
auto const cq =
|
auto const cq =
|
||||||
[&](std::string const& s, std::string const& good)
|
[&](std::string const& s, std::string const& answer)
|
||||||
{
|
{
|
||||||
auto const got = str(param_list{s});
|
auto const got = str(param_list{s});
|
||||||
BEAST_EXPECTS(got == good, fmt(got));
|
BEAST_EXPECTS(got == answer, fmt(got));
|
||||||
};
|
};
|
||||||
|
|
||||||
ce("");
|
ce("");
|
||||||
|
@ -79,9 +79,9 @@ boost::asio::ip::tcp::socket sock{ios};
|
|||||||
|
|
||||||
//[ws_snippet_9
|
//[ws_snippet_9
|
||||||
ws.handshake_ex("localhost", "/",
|
ws.handshake_ex("localhost", "/",
|
||||||
[](request_type& req)
|
[](request_type& m)
|
||||||
{
|
{
|
||||||
req.insert(http::field::sec_websocket_protocol, "xmpp;ws-chat");
|
m.insert(http::field::sec_websocket_protocol, "xmpp;ws-chat");
|
||||||
});
|
});
|
||||||
//]
|
//]
|
||||||
|
|
||||||
@ -98,9 +98,9 @@ boost::asio::ip::tcp::socket sock{ios};
|
|||||||
|
|
||||||
//[ws_snippet_12
|
//[ws_snippet_12
|
||||||
ws.accept_ex(
|
ws.accept_ex(
|
||||||
[](response_type& res)
|
[](response_type& m)
|
||||||
{
|
{
|
||||||
res.insert(http::field::server, "MyServer");
|
m.insert(http::field::server, "MyServer");
|
||||||
});
|
});
|
||||||
//]
|
//]
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ boost::asio::ip::tcp::socket sock{ios};
|
|||||||
//[ws_snippet_20
|
//[ws_snippet_20
|
||||||
multi_buffer buffer;
|
multi_buffer buffer;
|
||||||
ws.async_read(buffer,
|
ws.async_read(buffer,
|
||||||
[](error_code ec)
|
[](error_code)
|
||||||
{
|
{
|
||||||
// Do something with the buffer
|
// Do something with the buffer
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user