Commit Graph

233 Commits

Author SHA1 Message Date
Vinnie Falco
fc7b47fc5d Use suggested timeouts in Websocket examples 2019-02-18 12:18:27 -08:00
Vinnie Falco
00e8c381cd Examples use ssl_stream
fix #1455
2019-02-16 15:09:35 -08:00
Vinnie Falco
22dcb4a3cb example/cppcon2018 is removed:
* Replaced by websocket-chat-multi
2019-02-16 15:09:35 -08:00
Vinnie Falco
ca1b620527 Use std::bind for control_callback 2019-02-16 15:09:34 -08:00
Vinnie Falco
2e62f25701 Use async_op_base::invoke 2019-02-16 15:09:34 -08:00
Vinnie Falco
fdaf2ea7e1 Rename to async_op_base::invoke_now 2019-02-16 13:36:01 -08:00
Vinnie Falco
18447553ca Examples use bind_front_handler 2019-02-14 17:28:54 -08:00
Vinnie Falco
65cbc158cf Tidy up example docs and some names
fix #1450
2019-02-14 07:53:38 -08:00
Vinnie Falco
ebc5246c47 Rewrite the echo-op example
fix #1450
2019-02-13 14:14:34 -08:00
Vinnie Falco
c08ce90e2c Tidy up a warning 2019-02-13 12:16:22 -08:00
Vinnie Falco
45d722874f Use tcp_stream, HTTP timeouts in advanced servers 2019-02-10 11:43:15 -08:00
Vinnie Falco
6ee1a88292 Use tcp_stream in WebSocket server examples 2019-02-10 11:42:01 -08:00
Vinnie Falco
920909673a Use tcp_stream in WebSocket client examples 2019-02-10 11:42:01 -08:00
Vinnie Falco
cab2472ee9 Use timeouts in HTTP client examples 2019-02-10 11:42:01 -08:00
Vinnie Falco
5b97fbb966 Use timeouts in HTTP server examples 2019-02-10 11:42:01 -08:00
Daniel Sewtz
cd28598e5b Fixes to rfc7230:
fix #1435, fix #1438

* Example and test can be built on msvc v141 15.9.6
  using /std:c++17 and BOOST_BEAST_USE_STD_STRING_VIEW.

* changed string_view.to_string() to std:string(string_view),
  awaiting availability of Library Fundamentals TS here.

* Reactivated relevant tests to param_list. #ifdef 0 test
  exhibited same assertion failed error in debug mode.
  Now fixed in DEBUG on msvc v141 15.9.6 with
  BOOST_BEAST_USE_STD_STRING_VIEW and /std:c++17.

* Looked up http paramters (transfer-encoding, etc.)
  and changed tests as well as fixing comment to
  match specs.
2019-02-07 17:37:18 -08:00
Vinnie Falco
bc74cc2374 Spaces not tabs 2019-02-03 17:17:03 -08:00
Vinnie Falco
599104c16a async_echo supports move-only handlers
fix #1420
2019-02-02 10:20:38 -08:00
Vinnie Falco
6a658b5c3a Remove lowest_layer, add get_lowest_layer (API Change):
fix #1417

* New get_lowest_layer free function works for any object
* New lowest_layer_type trait works for any object
* New examples and documentation on layered streams

API Changes:

* The member function lowest_layer is removed from all
  types provided by the library:

Actions Required:

* Call the free function get_lowest_layer instead of
  member lowest_layer.
2019-02-01 04:31:13 -08:00
Vinnie Falco
383b9cb7f2 Send from the strand 2019-01-21 16:07:00 -08:00
Vinnie Falco
3081f52ad5 Add websocket-chat-multi example:
This is the multi-threaded io_context version of the
CppCon2018 WebSocket chat server and client example.
2019-01-21 12:13:04 -08:00
Vinnie Falco
9a8e22950f websocket stream uses shared_ptr<impl_type> 2019-01-21 08:44:14 -08:00
Vinnie Falco
944b5dcda7 Clear error codes idiomatically 2019-01-20 09:50:43 -08:00
Vinnie Falco
b337abe076 examples use flat_buffer
fix #1401
2019-01-15 11:42:05 -08:00
Vinnie Falco
abb8203cbe session_alloc is thread-safe
fix #1408
2019-01-15 11:42:05 -08:00
Johan Rönnkvist
be800436ea Include error code in call to set_option 2019-01-12 13:14:33 -08:00
Vinnie Falco
3595eb2221 Update networking refresher doc 2019-01-12 13:11:00 -08:00
Vinnie Falco
0006ab3b2b make_printable replaces buffers rename (API Change):
* The function buffers is deprecated, use the new
  function make_printable as the replacement.

Actions Required:

* Replace call sites to use make_printable instead of buffers,
  and also include make_printable.hpp instead of ostream.hpp.
2018-12-19 20:59:20 -08:00
Vinnie Falco
c11682032b Crawler example clears the response before each read:
fix #1100

Unfortunately the example still seems to hang, tested
with 20 threads.
2018-12-06 15:50:24 -08:00
Brett Robinson
88eef1e9e3 Improvements to echo-op example:
close #1347

* Set SO_REUSEADDR in listener
* Use newline as the delimiter in async_read_until
* Add arg parsing and exit status to echo-op example
2018-12-03 17:08:40 -08:00
Vinnie Falco
b3a8e6edb5 Tidy up calls to placement new 2018-12-02 19:48:42 -08:00
Vinnie Falco
f995fd41a3 net is a namespace alias for boost::asio:
The namespace alias beast::net replaces boost::asio in all code
and documentation.
2018-12-02 17:51:43 -08:00
Vinnie Falco
5bff4ed8ab Tidy up warnings and deprecated usage:
fix #1290

* BOOST_ASIO_NO_DEPRECATED=1 is now set
* Fix various warnings from the Boost regression test matrix
* Fix a bug in advanced servers when checking for a timeout
2018-11-26 15:30:48 -08:00
Vinnie Falco
7b93cca28a example/cppcon2018 only requires C++11 2018-11-22 18:34:25 -08:00
Vinnie Falco
e0b3aa7745 Fix warning in is_ssl_handshake 2018-11-22 18:34:09 -08:00
Vinnie Falco
15dd535c24 Use bind_front_handler:
The implementation uses bind_front_handler to reduce the
resources consumed when instantiating templates during
compilation.
2018-11-21 12:47:38 -08:00
Vinnie Falco
c18f3f0ef1 Rename to _experimental directory 2018-11-12 06:52:39 -08:00
Vinnie Falco
bc2f5f1426 Add CppCon2018 chat server example and video 2018-11-08 16:46:38 -08:00
Vinnie Falco
04bac8dce9 Remove extraneous strand from example
fix #1288
2018-11-03 19:30:16 -07:00
jarle
2b977f2770 Fix timer on websocket upgrade in examples
fix #1091, fix #1240, fix #1253
2018-10-07 10:38:36 -07:00
luz.paz
f3212eba48 Fix some typos:
fix #1255

Found via `codespell -q 3 -L uint,te,tim --skip="./test/extern/zlib*,./example/http/client/crawl*"`
2018-10-07 10:35:12 -07:00
Vinnie Falco
82e87ea188 Workaround for http-server-fast and libstdc++:
This fixes a problem where libstdc++ incorrectly assumes that the
allocator used with basic_string is DefaultConstructible.

See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437
2018-09-23 19:08:30 -07:00
PeterW3
4643b0565e Verify certificates in client examples:
fix #1237

HTTP client examples now verify the server's certificate
and generate an error if the certificate is invalid or
expired:

* Set certificate verify mode
* Remove duplicate root certificate
2018-09-23 10:12:08 -07:00
felixguendling
ba4bdfed71 Fix http_server_stackless_ssl.cpp example
fix #1210

Write to self_.stream_ instead of the socket_ directly
2018-07-28 07:00:51 -07:00
Vinnie Falco
92d34b9e3b Use static_cast instead
fix #1163
2018-07-15 09:11:15 -07:00
cos-public
c2ecba968c Check error in example set_option
fix #1186
2018-07-12 11:07:10 -07:00
Arvid Norberg
478c19e863 Use the root certificate which matches the fingerprint:
fix #1121

https://www.geotrust.com/resources/root_certificates/certificates/GeoTrust_Global_CA.pem
2018-05-08 14:08:28 -07:00
Vinnie Falco
f48b978044 Use a shared string for example HTTP server doc roots
fix #1109
2018-05-03 14:18:33 -07:00
Vinnie Falco
292801fef7 Add ssl_stream to experimental:
The ssl_stream wrapper provides C++11 move semantics for ssl::stream,
as well as incorporating the flat_stream workaround for a performance
problem with ssl::stream writes and buffer sequences having length
greater than one.
2018-05-02 08:32:09 -07:00
Vinnie Falco
6108cf3eb7 Add flat_stream to experimental:
This adds a new stream wrapper class template designed to address
a performance shortcoming of boost::asio::ssl::stream.
2018-05-02 08:32:07 -07:00
Vinnie Falco
90c01e82ca Use flat_stream in ssl_stream example code 2018-04-30 19:49:43 -07:00
Vinnie Falco
c9a445a937 New flat_stream example class:
fix #1108

The `flat_stream` is a stream wrapper designed to overcome a
performance limitation of the `boost::asio::ssl::stream`
implementation. Specifically, when writing buffer sequences having
length greater than one, the `ssl::stream` implementation does
not use scatter-gather I/O and instead performs a kernel transition
for every buffer in the sequence.

The wrapper addresses this problem by allocating memory and
presenting the buffer sequence into a single buffer, using
some logic to determine when this allocation is advantageous
versus simply passing the buffers through as-is.

See Also:
https://github.com/boostorg/asio/issues/100
https://stackoverflow.com/questions/50026167/performance-drop-on-port-from-beast-1-0-0-b66-to-boost-1-67-0-beast
2018-04-30 19:49:42 -07:00
Vinnie Falco
c592782a1b Simplify some type trait expressions
fix #466
2018-04-26 17:30:46 -07:00
Vinnie Falco
f1b1ee2345 Fix race in advanced server examples
fix #1073
2018-04-12 08:54:44 -07:00
Vinnie Falco
86342dd72b Use executor_work_guard in composed operations:
fix #1076

As per Asio and Networking TS requirements, composed operations must
maintain an object of type executor_work_guard for the executor associated
with the I/O object, for the lifetime of the asynchronous operation.

This is in addition to the requirement for maintaining an object of type
executor_work_guard for the executor associated with the handler.
2018-04-10 08:03:04 -07:00
Vinnie Falco
12cc10f8bb Revert "Tidy up calls to post()"
This reverts commit 5eaa2be85e.
2018-03-22 20:13:39 -07:00
Vinnie Falco
5eaa2be85e Tidy up calls to post() 2018-03-04 13:19:17 -08:00
Vinnie Falco
073b53e448 Fix handler parameter javadocs 2018-02-28 15:04:54 -08:00
Vinnie Falco
04ced3b954 Examples clear the HTTP message before reading
fix #1043
2018-02-27 08:12:54 -08:00
Vinnie Falco
10ce0283c2 Advanced servers support clean shutdown via SIGINT or SIGTERM
fix #1026
2018-02-21 12:44:11 -08:00
Vinnie Falco
a4714746dc Examples set reuse_address(true)
fix #1027
2018-02-21 12:35:07 -08:00
Vinnie Falco
593ccb15cd Fix teardown for TIME_WAIT
fix #1024, fix #1029
2018-02-20 04:33:43 -08:00
Benjamin Roland Buch
9f3c981d6a Fix memory leak in advanced server examples 2018-02-14 21:24:59 -08:00
Vinnie Falco
72cf7db931 Fix use-after-move in example request handlers
fix #992
2018-01-25 06:02:43 -08:00
Vinnie Falco
45798e0a6e Refactor detect_ssl_op:
fix #955

The asynchronous SSL detector uses a stackless coroutine.
2017-12-31 10:50:26 -08:00
Vinnie Falco
dabb78afe7 Sanitizer failures are errors 2017-12-23 08:46:34 -08:00
Damian Jarek
285965d82e handler_ptr gives the strong exception guarantee (API Change):
* The handler_ptr constructor now provides the
  strong exception guarantee.

* The signature for managed objects constructed by
  `handler_ptr` receives a const reference to the handler.

Actions required:

* Change the constructor signature for state objects
  used with handler_ptr to receive a const reference to
  the handler.
2017-12-08 10:58:46 -08:00
Vinnie Falco
eb0cc97e1a Protect calls from macros
fix #918
2017-12-04 12:14:11 -08:00
Vinnie Falco
c01224ddc4 Tidy up ssl_stream special members
fix #916
2017-12-04 12:14:11 -08:00
Vinnie Falco
7ac24d77be Send idle pings in advanced servers:
fix #899

The timer logic for the advanced-server and advanced-server-flex
examples is refactored to use idle pings when the connection has
not seen activity for some period of time. This demonstrates the
use of the stream's control_callback interface.
2017-11-27 16:44:59 -08:00
Vinnie Falco
12a355efc9 Fix typo in example server help text 2017-11-01 11:31:03 -07:00
Vinnie Falco
e39e4c73bf Rename Cmake variables for clarity 2017-10-30 12:35:56 -07:00
Vinnie Falco
42679ee0bc Tidy up project folders in CMakeLists.txt 2017-10-30 12:35:55 -07:00
Vinnie Falco
b75d4e5e14 Set SNI hostname in example SSL clients
fix #853
2017-10-29 14:58:57 -07:00
Vinnie Falco
b5389ba5f2 Documentation tidying
fix #836
2017-10-27 11:16:09 -07:00
Vinnie Falco
2746184850 Tidy up fast websocket server host names 2017-10-26 05:52:56 -07:00
Vinnie Falco
2555942010 Use message::need_eof in example servers 2017-10-25 18:48:19 -07:00
Sorin Fetche
f4facffae3 Version command line option for HTTP client examples:
The examples HTTP clients allow an optional command line switch
to choose the HTTP-version used ("1.0" or "1.1").
2017-10-25 10:33:24 -07:00
Vinnie Falco
41e61a7458 Fix executor type compilation 2017-10-24 09:33:29 -07:00
Vinnie Falco
e94dcae10c Fix shadowing in session_alloc 2017-10-24 09:33:29 -07:00
Vinnie Falco
8312c6eb86 Tidy up unused variable warnings 2017-10-23 20:19:36 -07:00
Vinnie Falco
3a28e999af Update for Net-TS Asio (API Change):
fix #769

The following classes are removed:

* handler_type
* async_result
* async_completion
* is_dynamic_buffer
* is_const_buffer_sequence
* is_mutable_buffer_sequence
* handler_alloc

Actions Required:

* Use BOOST_ASIO_HANDLER_TYPE instead of handler_type
* Use BOOST_ASIO_INITFN_RESULT_TYPE instead of async_result
* Use boost::asio::async_completion
* Use boost::asio::is_dynamic_buffer
* Use boost::asio::is_const_buffer_sequence
* Use boost::asio::is_mutable_buffer_sequence
* boost::asio::associated_allocator_t replaces handler_alloc
2017-10-23 17:11:27 -07:00
Vinnie Falco
d0d4e0a740 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`.
2017-10-22 07:03:04 -07:00
Vinnie Falco
c0cf030528 OpenSSL targets are optional (CMake) 2017-10-01 10:34:17 -07:00
Vinnie Falco
bbc1f14347 Fix spurious strand_ in advanced_server_flex 2017-10-01 10:14:47 -07:00
Peter Jankuliak
fa4df7eb60 Remove unused strands in server examples 2017-09-25 21:33:04 -07:00
Vinnie Falco
e94a65b04a buffers_prefix replaces buffer_prefix (API Change)
fix #773

* buffer_prefix is renamed to buffers_prefix
* buffer_prefix_view is renamed to buffers_prefix_view

Actions Required:

* Use buffers_prefix instead of buffer_prefix
* Use buffers_prefix_view instead of buffer_prefix_view
2017-09-15 12:52:58 -07:00
Vinnie Falco
38e28966ea message::version is a member function (API Change):
fix #778

* The version data member is replaced with accessor
  member functions.

Actions Required:

* Call member function message::version instead of accessing
  the version member at call sites.
2017-09-12 17:13:02 -07:00
Vinnie Falco
54fe7cacf7 message::body is a member function (API Change):
fix #778

* The body data member is replaced with accessor
  member functions.

Actions Required:

* Call member function message::body instead of accessing
  the data member at call sites.
2017-09-12 17:12:12 -07:00
Vinnie Falco
49d9d47a0b HTTP reads and writes return bytes transferred (API Change):
* HTTP read and write operations now return the
  number of bytes transferred to or from the stream.

Actions Required:

* Modify HTTP read and/or write completion handlers to receive
  the extra std::size_t bytes_transferred parameter.
2017-09-03 20:37:28 -07:00
Vinnie Falco
c0e5f14702 WebSocket writes return the bytes transferred (API Change):
* Stream write operations now return the number of bytes
transferred from the caller's input buffers.

Actions Required:

* Modify websocket write completion handlers to receive
  the extra std::size_t bytes_transferred parameter.
2017-09-03 20:05:19 -07:00
Vinnie Falco
59d4b85e15 Don't use async_write_msg in examples
fix #746
2017-08-18 07:55:30 -07:00
Vinnie Falco
830e651f99 Fix argument parsing in HTTP examples
fix #746
2017-08-18 07:55:20 -07:00
Vinnie Falco
76feb4afd4 Fix for basic_parser::skip(true) and docs
fix #742
2017-08-15 07:00:56 -07:00
Vinnie Falco
66b657a85f Autobahn|Testsuite fixes 2017-08-14 15:41:31 -07:00
Vinnie Falco
d613feae01 Example HTTP server fixes 2017-08-08 19:25:35 -07:00
Vinnie Falco
dd71b0f94d Refactor all examples:
fix #575, fix #604, fix #608, fix #634, fix #712

All examples are rewritten:

* Using Best Practices
* Mostly self-contained
* New examples to complete the feature matrix
* The server-framework example is removed
2017-08-07 20:53:11 -07:00
Vinnie Falco
60c8a560bf Add teardown_role for correct TIME_WAIT behavior (API Change):
* teardown_tag is replaced with teardown_role, a client/server
  flag used to determine whether the shutdown is performed
  before or after reading the EOF. This is in accordance with
  RFC6455 7.1.1:

  https://tools.ietf.org/html/rfc6455#section-7.1.1

Actions Required:

* Modify signatures of teardown and async_teardown to use
  teardown_role instead of teardown_tag

* Change calls to teardown and async_teardown to pass the
  correct role: client or server depending on context.
2017-08-04 19:02:13 -07:00
Vinnie Falco
64327739f0 WebSocket close will automatically drain (API Change):
fix #642

* Calls to stream::close and stream::async_close will
  automatically perform the required read operations

Actions Required:

* Remove calling code which drains the connection after
  calling stream::close or stream::async_close
2017-08-04 19:02:13 -07:00
Vinnie Falco
030f5eef87 Move extras/ to test/ 2017-07-31 19:02:46 -07:00