From 8b60ef9db43089f08444ede0d9171d4903b6a174 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 24 Feb 2017 12:42:36 -0500 Subject: [PATCH] Squashed 'src/beast/' changes from 06f74f0..9f10b11 9f10b11 Set version to 1.0.0-b28 195f974 Fix HTTP split parse edge case: 264fd41 Restyle async result constructions 572a0eb Split out and rename test stream classes 95b6646 Tidy up some WebSocket javadocs f6938d3 Set version to 1.0.0-b27 a6120cd Update copyright dates c7bfe7d Add documentation building instructions f6c91ce Tidy up tests and docs: f03985f Move basic_streambuf to streambuf.hpp (API Change): b8639a7 Invoke callback on pings and pongs (API Change): git-subtree-dir: src/beast git-subtree-split: 9f10b11eff58aeb793b673c8a8cb6e2bee3db621 --- CHANGELOG.md | 20 + doc/Dockerfile | 22 + doc/Jamfile.v2 | 2 +- doc/README.md | 72 +++ doc/design.qbk | 2 +- doc/examples.qbk | 2 +- doc/http.qbk | 2 +- doc/index.xml | 2 +- doc/makeqbk.sh | 2 +- doc/master.qbk | 11 +- doc/overview.qbk | 2 +- doc/quickref.xml | 4 +- doc/reference.xsl | 5 +- doc/types/Body.qbk | 2 +- doc/types/BufferSequence.qbk | 2 +- doc/types/DynamicBuffer.qbk | 2 +- doc/types/Field.qbk | 2 +- doc/types/FieldSequence.qbk | 2 +- doc/types/Parser.qbk | 2 +- doc/types/Reader.qbk | 2 +- doc/types/Streams.qbk | 2 +- doc/types/Writer.qbk | 2 +- doc/websocket.qbk | 42 +- examples/Jamfile.v2 | 2 +- examples/file_body.hpp | 2 +- examples/http_async_server.hpp | 2 +- examples/http_crawl.cpp | 2 +- examples/http_example.cpp | 2 +- examples/http_server.cpp | 2 +- examples/http_sync_server.hpp | 2 +- examples/mime_type.hpp | 2 +- examples/ssl/Jamfile.v2 | 2 +- examples/ssl/http_ssl_example.cpp | 2 +- examples/ssl/websocket_ssl_example.cpp | 2 +- examples/urls_large_data.cpp | 2 +- examples/urls_large_data.hpp | 2 +- examples/websocket_async_echo_server.hpp | 2 +- examples/websocket_echo.cpp | 2 +- examples/websocket_example.cpp | 2 +- examples/websocket_sync_echo_server.hpp | 2 +- extras/beast/doc_debug.hpp | 2 +- extras/beast/test/fail_counter.hpp | 2 +- extras/beast/test/fail_stream.hpp | 6 +- extras/beast/test/sig_wait.hpp | 2 +- .../{string_stream.hpp => string_istream.hpp} | 26 +- extras/beast/test/string_ostream.hpp | 118 +++++ extras/beast/test/yield_to.hpp | 2 +- extras/beast/unit_test/amount.hpp | 2 +- .../unit_test/detail/const_container.hpp | 2 +- extras/beast/unit_test/dstream.hpp | 2 +- extras/beast/unit_test/global_suites.hpp | 2 +- extras/beast/unit_test/main.cpp | 2 +- extras/beast/unit_test/match.hpp | 2 +- extras/beast/unit_test/recorder.hpp | 2 +- extras/beast/unit_test/reporter.hpp | 4 +- extras/beast/unit_test/results.hpp | 2 +- extras/beast/unit_test/runner.hpp | 2 +- extras/beast/unit_test/suite.hpp | 4 +- extras/beast/unit_test/suite_info.hpp | 2 +- extras/beast/unit_test/suite_list.hpp | 2 +- extras/beast/unit_test/thread.hpp | 2 +- include/beast/core.hpp | 3 +- include/beast/core/async_completion.hpp | 4 +- include/beast/core/basic_streambuf.hpp | 333 ------------ include/beast/core/bind_handler.hpp | 38 +- include/beast/core/buffer_cat.hpp | 7 +- include/beast/core/buffer_concepts.hpp | 2 +- include/beast/core/buffers_adapter.hpp | 2 +- include/beast/core/consuming_buffers.hpp | 21 +- include/beast/core/detail/base64.hpp | 2 +- include/beast/core/detail/bind_handler.hpp | 9 +- include/beast/core/detail/buffer_cat.hpp | 2 +- include/beast/core/detail/buffer_concepts.hpp | 2 +- include/beast/core/detail/ci_char_traits.hpp | 2 +- include/beast/core/detail/clamp.hpp | 2 +- .../core/detail/empty_base_optimization.hpp | 2 +- .../beast/core/detail/get_lowest_layer.hpp | 2 +- .../beast/core/detail/integer_sequence.hpp | 2 +- .../beast/core/detail/is_call_possible.hpp | 49 +- include/beast/core/detail/prepare_buffers.hpp | 2 +- include/beast/core/detail/sha1.hpp | 4 +- include/beast/core/detail/stream_concepts.hpp | 2 +- include/beast/core/detail/sync_ostream.hpp | 2 +- include/beast/core/detail/type_traits.hpp | 2 +- include/beast/core/detail/write_dynabuf.hpp | 2 +- include/beast/core/dynabuf_readstream.hpp | 152 ++++-- include/beast/core/error.hpp | 2 +- include/beast/core/handler_alloc.hpp | 27 +- include/beast/core/handler_concepts.hpp | 2 +- include/beast/core/handler_helpers.hpp | 4 +- include/beast/core/handler_ptr.hpp | 2 +- include/beast/core/impl/buffers_adapter.ipp | 2 +- include/beast/core/impl/consuming_buffers.ipp | 2 +- .../beast/core/impl/dynabuf_readstream.ipp | 4 +- include/beast/core/impl/handler_ptr.ipp | 2 +- include/beast/core/impl/static_streambuf.ipp | 2 +- .../{basic_streambuf.ipp => streambuf.ipp} | 12 +- include/beast/core/placeholders.hpp | 8 +- include/beast/core/prepare_buffer.hpp | 6 +- include/beast/core/prepare_buffers.hpp | 2 +- include/beast/core/static_streambuf.hpp | 2 +- include/beast/core/static_string.hpp | 2 +- include/beast/core/stream_concepts.hpp | 2 +- include/beast/core/streambuf.hpp | 320 +++++++++++- include/beast/core/to_string.hpp | 2 +- include/beast/core/write_dynabuf.hpp | 2 +- include/beast/http.hpp | 2 +- include/beast/http/basic_dynabuf_body.hpp | 2 +- include/beast/http/basic_fields.hpp | 2 +- include/beast/http/basic_parser_v1.hpp | 9 +- include/beast/http/chunk_encode.hpp | 2 +- include/beast/http/concepts.hpp | 2 +- include/beast/http/detail/basic_fields.hpp | 2 +- include/beast/http/detail/basic_parser_v1.hpp | 2 +- include/beast/http/detail/chunk_encode.hpp | 2 +- include/beast/http/detail/rfc7230.hpp | 4 +- include/beast/http/empty_body.hpp | 2 +- include/beast/http/fields.hpp | 2 +- include/beast/http/header_parser_v1.hpp | 2 +- include/beast/http/impl/basic_fields.ipp | 2 +- include/beast/http/impl/basic_parser_v1.ipp | 13 +- include/beast/http/impl/message.ipp | 2 +- include/beast/http/impl/parse.ipp | 6 +- include/beast/http/impl/parse_error.ipp | 2 +- include/beast/http/impl/read.ipp | 6 +- include/beast/http/impl/rfc7230.ipp | 2 +- include/beast/http/impl/write.ipp | 8 +- include/beast/http/message.hpp | 2 +- include/beast/http/parse.hpp | 2 +- include/beast/http/parse_error.hpp | 2 +- include/beast/http/parser_v1.hpp | 2 +- include/beast/http/read.hpp | 2 +- include/beast/http/reason.hpp | 2 +- include/beast/http/resume_context.hpp | 2 +- include/beast/http/rfc7230.hpp | 2 +- include/beast/http/streambuf_body.hpp | 2 +- include/beast/http/string_body.hpp | 2 +- include/beast/http/write.hpp | 2 +- include/beast/version.hpp | 4 +- include/beast/websocket.hpp | 2 +- include/beast/websocket/detail/debug.hpp | 2 +- include/beast/websocket/detail/decorator.hpp | 2 +- include/beast/websocket/detail/endian.hpp | 2 +- include/beast/websocket/detail/frame.hpp | 2 +- include/beast/websocket/detail/hybi13.hpp | 2 +- include/beast/websocket/detail/invokable.hpp | 2 +- include/beast/websocket/detail/mask.hpp | 2 +- .../beast/websocket/detail/pmd_extension.hpp | 2 +- .../beast/websocket/detail/stream_base.hpp | 8 +- .../beast/websocket/detail/utf8_checker.hpp | 2 +- include/beast/websocket/error.hpp | 2 +- include/beast/websocket/impl/accept.ipp | 8 +- include/beast/websocket/impl/close.ipp | 8 +- include/beast/websocket/impl/error.ipp | 2 +- include/beast/websocket/impl/handshake.ipp | 4 +- include/beast/websocket/impl/ping.ipp | 8 +- include/beast/websocket/impl/read.ipp | 30 +- include/beast/websocket/impl/ssl.ipp | 2 +- include/beast/websocket/impl/stream.ipp | 4 +- include/beast/websocket/impl/teardown.ipp | 2 +- include/beast/websocket/impl/write.ipp | 6 +- include/beast/websocket/option.hpp | 61 ++- include/beast/websocket/rfc6455.hpp | 2 +- include/beast/websocket/ssl.hpp | 2 +- include/beast/websocket/stream.hpp | 168 +++--- include/beast/websocket/teardown.hpp | 4 +- include/beast/zlib.hpp | 2 +- include/beast/zlib/deflate_stream.hpp | 10 +- include/beast/zlib/detail/bitstream.hpp | 8 +- include/beast/zlib/detail/deflate_stream.hpp | 8 +- include/beast/zlib/detail/inflate_stream.hpp | 4 +- include/beast/zlib/detail/ranges.hpp | 2 +- include/beast/zlib/detail/window.hpp | 2 +- include/beast/zlib/error.hpp | 2 +- include/beast/zlib/impl/error.ipp | 2 +- include/beast/zlib/inflate_stream.hpp | 2 +- include/beast/zlib/zlib.hpp | 4 +- test/Jamfile | 5 +- test/core.cpp | 2 +- test/core/CMakeLists.txt | 3 +- test/core/async_completion.cpp | 2 +- test/core/base64.cpp | 2 +- test/core/basic_streambuf.cpp | 480 ------------------ test/core/bind_handler.cpp | 12 +- test/core/buffer_cat.cpp | 4 +- test/core/buffer_concepts.cpp | 2 +- test/core/buffer_test.hpp | 2 +- test/core/buffers_adapter.cpp | 2 +- test/core/clamp.cpp | 2 +- test/core/consuming_buffers.cpp | 2 +- test/core/dynabuf_readstream.cpp | 12 +- test/core/empty_base_optimization.cpp | 2 +- test/core/error.cpp | 2 +- test/core/get_lowest_layer.cpp | 2 +- test/core/handler_alloc.cpp | 35 +- test/core/handler_concepts.cpp | 2 +- test/core/handler_ptr.cpp | 73 ++- test/core/is_call_possible.cpp | 56 ++ test/core/placeholders.cpp | 2 +- test/core/prepare_buffer.cpp | 9 + test/core/prepare_buffers.cpp | 2 +- test/core/sha1.cpp | 2 +- test/core/static_streambuf.cpp | 2 +- test/core/static_string.cpp | 2 +- test/core/stream_concepts.cpp | 2 +- test/core/streambuf.cpp | 468 ++++++++++++++++- test/core/to_string.cpp | 20 +- test/core/write_dynabuf.cpp | 2 +- test/core/zlib.cpp | 2 +- test/http.cpp | 2 +- test/http/basic_dynabuf_body.cpp | 2 +- test/http/basic_fields.cpp | 2 +- test/http/basic_parser_v1.cpp | 2 +- test/http/chunk_encode.cpp | 4 +- test/http/concepts.cpp | 2 +- test/http/empty_body.cpp | 2 +- test/http/fail_parser.hpp | 2 +- test/http/fields.cpp | 2 +- test/http/header_parser_v1.cpp | 2 +- test/http/message.cpp | 2 +- test/http/message_fuzz.hpp | 2 +- test/http/nodejs_parser.cpp | 2 +- test/http/nodejs_parser.hpp | 4 +- test/http/parse.cpp | 2 +- test/http/parse_error.cpp | 2 +- test/http/parser_bench.cpp | 2 +- test/http/parser_v1.cpp | 132 ++--- test/http/read.cpp | 30 +- test/http/reason.cpp | 2 +- test/http/resume_context.cpp | 2 +- test/http/rfc7230.cpp | 2 +- test/http/streambuf_body.cpp | 6 +- test/http/string_body.cpp | 2 +- test/http/write.cpp | 91 +--- test/version.cpp | 2 +- test/websocket.cpp | 2 +- test/websocket/error.cpp | 2 +- test/websocket/frame.cpp | 2 +- test/websocket/mask.cpp | 2 +- test/websocket/option.cpp | 2 +- test/websocket/rfc6455.cpp | 2 +- test/websocket/stream.cpp | 28 +- test/websocket/teardown.cpp | 2 +- test/websocket/utf8_checker.cpp | 2 +- .../websocket/websocket_async_echo_server.hpp | 2 +- test/websocket/websocket_sync_echo_server.hpp | 2 +- test/zlib.cpp | 2 +- test/zlib/deflate_stream.cpp | 2 +- test/zlib/error.cpp | 2 +- test/zlib/inflate_stream.cpp | 2 +- test/zlib/ztest.hpp | 2 +- 251 files changed, 1999 insertions(+), 1561 deletions(-) create mode 100644 doc/Dockerfile create mode 100644 doc/README.md rename extras/beast/test/{string_stream.hpp => string_istream.hpp} (80%) create mode 100644 extras/beast/test/string_ostream.hpp delete mode 100644 include/beast/core/basic_streambuf.hpp rename include/beast/core/impl/{basic_streambuf.ipp => streambuf.ipp} (98%) delete mode 100644 test/core/basic_streambuf.cpp create mode 100644 test/core/is_call_possible.cpp create mode 100644 test/core/prepare_buffer.cpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 4aec8f03b..0b913b491 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +1.0.0-b28 + +* Split out and rename test stream classes +* Restyle async result constructions +* Fix HTTP split parse edge case + +-------------------------------------------------------------------------------- + +1.0.0-b27 + +* Tidy up tests and docs +* Add documentation building instructions + +API Changes: + +* Invoke callback on pings and pongs +* Move basic_streambuf to streambuf.hpp + +-------------------------------------------------------------------------------- + 1.0.0-b26 * Tidy up warnings and tests diff --git a/doc/Dockerfile b/doc/Dockerfile new file mode 100644 index 000000000..46ba0ee33 --- /dev/null +++ b/doc/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu:16.04 + +RUN apt-get update +RUN apt-get -y install build-essential g++ git libbz2-dev wget python-dev + +# Install Boost +ENV BOOST_SHA 440a59f8bc4023dbe6285c9998b0f7fa288468b889746b1ef00e8b36c559dce1 +RUN wget https://sourceforge.net/projects/boost/files/boost/1.62.0/boost_1_62_0.tar.gz +RUN echo "$BOOST_SHA boost_1_62_0.tar.gz" | sha256sum -c +RUN tar xzf boost_1_62_0.tar.gz +RUN cd boost_1_62_0 && ./bootstrap.sh --prefix=/usr/local +RUN cd boost_1_62_0 && ./b2 install +ENV BOOST_ROOT=/boost_1_62_0 + +# Install dependencies +RUN apt-get -y install doxygen +RUN apt-get -y install xsltproc + +CMD cd /opt/beast/doc && \ + chmod +x makeqbk.sh && \ + ./makeqbk.sh && \ + $BOOST_ROOT/b2 diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 8e78d6cd8..39e9ecfbb 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 000000000..02a9c555e --- /dev/null +++ b/doc/README.md @@ -0,0 +1,72 @@ +# Building documentation + +## Specifying Files + +To specify the source files for which to build documentation, modify `INPUT` +and its related fields in `doc/source.dox`. Note that the `INPUT` paths are +relative to the `doc/` directory. + +## Install Dependencies + +### Windows + +Install these dependencies: + +1. Install [Doxygen](http://www.stack.nl/~dimitri/doxygen/download.html) +2. Download the following zip files from [xsltproc](https://www.zlatkovic.com/pub/libxml/) + (Alternate download: ftp://ftp.zlatkovic.com/libxml/), + and extract the `bin\` folder contents into any folder in your path. + * iconv + * libxml2 + * libxslt + * zlib +3. Download [Boost](http://www.boost.org/users/download/) + 1. Extract the compressed file contents to your (new) `$BOOST_ROOT` location. + 2. Open a command prompt or shell in the `$BOOST_ROOT`. + 3. `./bootstrap.bat` + 4. If it is not already there, add your `$BOOST_ROOT` to your environment `$PATH`. + +### MacOS + +1. Install doxygen: + * Use homebrew to install: `brew install doxygen`. The executable will be + installed in `/usr/local/bin` which is already in your path. + * Alternatively, install from here: [doxygen](http://www.stack.nl/~dimitri/doxygen/download.html). + You'll then need to make doxygen available to your command line. You can + do this by adding a symbolic link from `/usr/local/bin` to the doxygen + executable. For example, `$ ln -s /Applications/Doxygen.app/Contents/Resources/doxygen /usr/local/bin/doxygen` +2. Install [Boost](http://www.boost.org/users/download/) + 1. Extract the compressed file contents to your (new) `$BOOST_ROOT` location. + 2. Open a command prompt or shell in the `$BOOST_ROOT`. + 3. `$ ./bootstrap.bat` + 4. If it is not already there, add your `$BOOST_ROOT` to your environment + `$PATH`. This makes the `b2` command available to the command line. +3. That should be all that's required. In OS X 10.11, at least, libxml2 and + libxslt come pre-installed. + +### Linux + +1. Install [Docker](https://docs.docker.com/engine/installation/) +2. Build Docker image. From the Beast root folder: +``` +sudo docker build -t beast-docs doc/ +``` + +## Do it + +### Windows & MacOS + +From the Beast root folder: +``` +cd doc +./makeqbk.sh && b2 +``` +The output will be in `doc/html`. + +### Linux + +From the Beast root folder: +``` +sudo docker run -v $PWD:/opt/beast --rm beast-docs +``` +The output will be in `doc/html`. diff --git a/doc/design.qbk b/doc/design.qbk index 50e086a6e..ff925b4ab 100644 --- a/doc/design.qbk +++ b/doc/design.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/examples.qbk b/doc/examples.qbk index 3ad72b09a..418215e25 100644 --- a/doc/examples.qbk +++ b/doc/examples.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/http.qbk b/doc/http.qbk index 8ef784ff4..9249fd64f 100644 --- a/doc/http.qbk +++ b/doc/http.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/index.xml b/doc/index.xml index 0c0cba262..5029fc912 100644 --- a/doc/index.xml +++ b/doc/index.xml @@ -2,7 +2,7 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -1580,6 +1580,9 @@ class ``[link beast.ref.DynamicBuffer [*DynamicBuffer]]`` + + class __Handler__ + class __MutableBufferSequence__ diff --git a/doc/types/Body.qbk b/doc/types/Body.qbk index 41560e67e..e0099d92a 100644 --- a/doc/types/Body.qbk +++ b/doc/types/Body.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/types/BufferSequence.qbk b/doc/types/BufferSequence.qbk index ae493f480..c008457be 100644 --- a/doc/types/BufferSequence.qbk +++ b/doc/types/BufferSequence.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/types/DynamicBuffer.qbk b/doc/types/DynamicBuffer.qbk index ff8c12258..792c25914 100644 --- a/doc/types/DynamicBuffer.qbk +++ b/doc/types/DynamicBuffer.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/types/Field.qbk b/doc/types/Field.qbk index c24925275..e628b980b 100644 --- a/doc/types/Field.qbk +++ b/doc/types/Field.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/types/FieldSequence.qbk b/doc/types/FieldSequence.qbk index b602c32df..2c3aa7f1a 100644 --- a/doc/types/FieldSequence.qbk +++ b/doc/types/FieldSequence.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/types/Parser.qbk b/doc/types/Parser.qbk index 3bf31ca27..12cd7b749 100644 --- a/doc/types/Parser.qbk +++ b/doc/types/Parser.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/types/Reader.qbk b/doc/types/Reader.qbk index d1952e42f..0fd852f1c 100644 --- a/doc/types/Reader.qbk +++ b/doc/types/Reader.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/types/Streams.qbk b/doc/types/Streams.qbk index a5493600a..67d603755 100644 --- a/doc/types/Streams.qbk +++ b/doc/types/Streams.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/types/Writer.qbk b/doc/types/Writer.qbk index 32ea72273..3015b238f 100644 --- a/doc/types/Writer.qbk +++ b/doc/types/Writer.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/doc/websocket.qbk b/doc/websocket.qbk index 904a703c9..ce989f042 100644 --- a/doc/websocket.qbk +++ b/doc/websocket.qbk @@ -1,5 +1,5 @@ [/ - Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) + Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -309,9 +309,9 @@ and received a close frame. During read operations, Beast automatically reads and processes control frames. Pings are replied to as soon as possible with a pong, received -pongs are delivered to the pong callback. The receipt of a close frame -initiates the WebSocket close procedure, eventually resulting in the error -code [link beast.ref.websocket__error `error::closed`] being delivered +ping and pongs are delivered to the ping callback. The receipt of a close +frame initiates the WebSocket close procedure, eventually resulting in the +error code [link beast.ref.websocket__error `error::closed`] being delivered to the caller in a subsequent read operation, assuming no other error takes place. @@ -331,29 +331,33 @@ using the functions [link beast.ref.websocket__stream.ping `ping`] and [link beast.ref.websocket__stream.pong `pong`]. -To receive pong control frames, callers may register a "pong callback" using -[link beast.ref.websocket__stream.set_option `set_option`]. The object provided -with this option should be callable with the following signature: +To be notified of ping and pong control frames, callers may register a +"ping callback" using [link beast.ref.websocket__stream.set_option `set_option`]. +The object provided with this option should be callable with the following +signature: ``` - void on_pong(ping_data const& payload); + void on_ping(bool is_pong, ping_data const& payload); ... - ws.set_option(pong_callback{&on_pong}); + ws.set_option(ping_callback{&on_ping}); ``` -When a pong callback is registered, any pongs received through either -synchronous read functions or asynchronous read functions will invoke the -pong callback, passing the payload in the pong message as the argument. +When a ping callback is registered, all pings and pongs received through +either synchronous read functions or asynchronous read functions will +invoke the ping callback, with the value of `is_pong` set to `true` if a +pong was received else `false` if a ping was received. The payload of +the ping or pong control frame is passed in the payload argument. Unlike regular completion handlers used in calls to asynchronous initiation -functions, the pong callback only needs to be set once. The callback is not -reset when a pong is received. The same callback is used for both synchronous -and asynchronous reads. The pong callback is passive; in order to receive -pongs, a synchronous or asynchronous stream read function must be active. +functions, the ping callback only needs to be set once. The callback is not +reset when a ping or pong is received. The same callback is used for both +synchronous and asynchronous reads. The ping callback is passive; in order +to receive pings and pongs, a synchronous or asynchronous stream read +function must be active. [note - When an asynchronous read function receives a pong, the the pong - callback is invoked in the same manner as that used to invoke the - final completion handler of the corresponding read function. + When an asynchronous read function receives a ping or pong, the + ping callback is invoked in the same manner as that used to invoke + the final completion handler of the corresponding read function. ] [heading Close Frames] diff --git a/examples/Jamfile.v2 b/examples/Jamfile.v2 index 0bfbb5947..c80330b61 100644 --- a/examples/Jamfile.v2 +++ b/examples/Jamfile.v2 @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/file_body.hpp b/examples/file_body.hpp index c92d4fe7e..8aef3f2de 100644 --- a/examples/file_body.hpp +++ b/examples/file_body.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/http_async_server.hpp b/examples/http_async_server.hpp index 2e248a390..33ad51a85 100644 --- a/examples/http_async_server.hpp +++ b/examples/http_async_server.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/http_crawl.cpp b/examples/http_crawl.cpp index 3e67a14ed..1a794169b 100644 --- a/examples/http_crawl.cpp +++ b/examples/http_crawl.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/http_example.cpp b/examples/http_example.cpp index 55910fee0..038ac2e24 100644 --- a/examples/http_example.cpp +++ b/examples/http_example.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/http_server.cpp b/examples/http_server.cpp index d21fd18ad..7694d559b 100644 --- a/examples/http_server.cpp +++ b/examples/http_server.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/http_sync_server.hpp b/examples/http_sync_server.hpp index bd6df50d0..378775688 100644 --- a/examples/http_sync_server.hpp +++ b/examples/http_sync_server.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/mime_type.hpp b/examples/mime_type.hpp index d20aa605a..babffd5f2 100644 --- a/examples/mime_type.hpp +++ b/examples/mime_type.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/ssl/Jamfile.v2 b/examples/ssl/Jamfile.v2 index b35e16f23..45ab791f9 100644 --- a/examples/ssl/Jamfile.v2 +++ b/examples/ssl/Jamfile.v2 @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/ssl/http_ssl_example.cpp b/examples/ssl/http_ssl_example.cpp index ff6224c28..30c819404 100644 --- a/examples/ssl/http_ssl_example.cpp +++ b/examples/ssl/http_ssl_example.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/ssl/websocket_ssl_example.cpp b/examples/ssl/websocket_ssl_example.cpp index b83e045ba..bba99c7a2 100644 --- a/examples/ssl/websocket_ssl_example.cpp +++ b/examples/ssl/websocket_ssl_example.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/urls_large_data.cpp b/examples/urls_large_data.cpp index 819694f5a..61d68ba45 100644 --- a/examples/urls_large_data.cpp +++ b/examples/urls_large_data.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/urls_large_data.hpp b/examples/urls_large_data.hpp index 399644f0d..74147a8a2 100644 --- a/examples/urls_large_data.hpp +++ b/examples/urls_large_data.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/websocket_async_echo_server.hpp b/examples/websocket_async_echo_server.hpp index 3b0b9ae11..bd0c8481b 100644 --- a/examples/websocket_async_echo_server.hpp +++ b/examples/websocket_async_echo_server.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/websocket_echo.cpp b/examples/websocket_echo.cpp index bf7ac9cb6..e8171526f 100644 --- a/examples/websocket_echo.cpp +++ b/examples/websocket_echo.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/websocket_example.cpp b/examples/websocket_example.cpp index 1036e92cb..bda489be6 100644 --- a/examples/websocket_example.cpp +++ b/examples/websocket_example.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/examples/websocket_sync_echo_server.hpp b/examples/websocket_sync_echo_server.hpp index a4b0ba3a0..1f41b52ce 100644 --- a/examples/websocket_sync_echo_server.hpp +++ b/examples/websocket_sync_echo_server.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/doc_debug.hpp b/extras/beast/doc_debug.hpp index 616414963..5b5587f0d 100644 --- a/extras/beast/doc_debug.hpp +++ b/extras/beast/doc_debug.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/test/fail_counter.hpp b/extras/beast/test/fail_counter.hpp index aaaa7a16a..7bfe486bf 100644 --- a/extras/beast/test/fail_counter.hpp +++ b/extras/beast/test/fail_counter.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/test/fail_stream.hpp b/extras/beast/test/fail_stream.hpp index 47742d06c..8ec63dc52 100644 --- a/extras/beast/test/fail_stream.hpp +++ b/extras/beast/test/fail_stream.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -113,7 +113,7 @@ public: { async_completion< ReadHandler, void(error_code, std::size_t) - > completion(handler); + > completion{handler}; next_layer_.get_io_service().post( bind_handler(completion.handler, ec, 0)); return completion.result.get(); @@ -150,7 +150,7 @@ public: { async_completion< WriteHandler, void(error_code, std::size_t) - > completion(handler); + > completion{handler}; next_layer_.get_io_service().post( bind_handler(completion.handler, ec, 0)); return completion.result.get(); diff --git a/extras/beast/test/sig_wait.hpp b/extras/beast/test/sig_wait.hpp index a1071bdf2..cadd21660 100644 --- a/extras/beast/test/sig_wait.hpp +++ b/extras/beast/test/sig_wait.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/test/string_stream.hpp b/extras/beast/test/string_istream.hpp similarity index 80% rename from extras/beast/test/string_stream.hpp rename to extras/beast/test/string_istream.hpp index a8bd0b7ed..e7c32064e 100644 --- a/extras/beast/test/string_stream.hpp +++ b/extras/beast/test/string_istream.hpp @@ -1,16 +1,17 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef BEAST_TEST_STRING_STREAM_HPP -#define BEAST_TEST_STRING_STREAM_HPP +#ifndef BEAST_TEST_STRING_ISTREAM_HPP +#define BEAST_TEST_STRING_ISTREAM_HPP #include #include #include +#include #include #include #include @@ -24,16 +25,21 @@ namespace test { discarded, and when data is read it comes from a string provided at construction. */ -class string_stream +class string_istream { std::string s_; + boost::asio::const_buffer cb_; boost::asio::io_service& ios_; + std::size_t read_max_; public: - string_stream(boost::asio::io_service& ios, - std::string s) + string_istream(boost::asio::io_service& ios, + std::string s, std::size_t read_max = + (std::numeric_limits::max)()) : s_(std::move(s)) + , cb_(boost::asio::buffer(s_)) , ios_(ios) + , read_max_(read_max) { } @@ -60,9 +66,9 @@ public: error_code& ec) { auto const n = boost::asio::buffer_copy( - buffers, boost::asio::buffer(s_)); + buffers, prepare_buffer(read_max_, cb_)); if(n > 0) - s_.erase(0, n); + cb_ = cb_ + n; else ec = boost::asio::error::eof; return n; @@ -82,7 +88,7 @@ public: else ec = boost::asio::error::eof; async_completion completion(handler); + void(error_code, std::size_t)> completion{handler}; ios_.post(bind_handler( completion.handler, ec, n)); return completion.result.get(); @@ -114,7 +120,7 @@ public: WriteHandler&& handler) { async_completion completion(handler); + void(error_code, std::size_t)> completion{handler}; ios_.post(bind_handler(completion.handler, error_code{}, boost::asio::buffer_size(buffers))); return completion.result.get(); diff --git a/extras/beast/test/string_ostream.hpp b/extras/beast/test/string_ostream.hpp new file mode 100644 index 000000000..a939da7aa --- /dev/null +++ b/extras/beast/test/string_ostream.hpp @@ -0,0 +1,118 @@ +// +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_TEST_STRING_OSTREAM_HPP +#define BEAST_TEST_STRING_OSTREAM_HPP + +#include +#include +#include +#include +#include +#include + +namespace beast { +namespace test { + +class string_ostream +{ + boost::asio::io_service& ios_; + +public: + std::string str; + + explicit + string_ostream(boost::asio::io_service& ios) + : ios_(ios) + { + } + + boost::asio::io_service& + get_io_service() + { + return ios_; + } + + template + std::size_t + read_some(MutableBufferSequence const& buffers) + { + error_code ec; + auto const n = read_some(buffers, ec); + if(ec) + throw system_error{ec}; + return n; + } + + template + std::size_t + read_some(MutableBufferSequence const& buffers, + error_code& ec) + { + return 0; + } + + template + typename async_completion::result_type + async_read_some(MutableBufferSequence const& buffers, + ReadHandler&& handler) + { + async_completion completion{handler}; + ios_.post(bind_handler(completion.handler, + error_code{}, 0)); + return completion.result.get(); + } + + template + std::size_t + write_some(ConstBufferSequence const& buffers) + { + error_code ec; + auto const n = write_some(buffers, ec); + if(ec) + throw system_error{ec}; + return n; + } + + template + std::size_t + write_some( + ConstBufferSequence const& buffers, error_code&) + { + auto const n = buffer_size(buffers); + using boost::asio::buffer_size; + using boost::asio::buffer_cast; + str.reserve(str.size() + n); + for(auto const& buffer : buffers) + str.append(buffer_cast(buffer), + buffer_size(buffer)); + return n; + } + + template + typename async_completion< + WriteHandler, void(error_code)>::result_type + async_write_some(ConstBufferSequence const& buffers, + WriteHandler&& handler) + { + error_code ec; + auto const bytes_transferred = write_some(buffers, ec); + async_completion< + WriteHandler, void(error_code, std::size_t) + > completion{handler}; + get_io_service().post( + bind_handler(completion.handler, ec, bytes_transferred)); + return completion.result.get(); + } +}; + +} // test +} // beast + +#endif diff --git a/extras/beast/test/yield_to.hpp b/extras/beast/test/yield_to.hpp index fecd8d4bf..c6b3a8679 100644 --- a/extras/beast/test/yield_to.hpp +++ b/extras/beast/test/yield_to.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/amount.hpp b/extras/beast/unit_test/amount.hpp index ebe76efda..a045d4d75 100644 --- a/extras/beast/unit_test/amount.hpp +++ b/extras/beast/unit_test/amount.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/detail/const_container.hpp b/extras/beast/unit_test/detail/const_container.hpp index a4910f01e..ed613537d 100644 --- a/extras/beast/unit_test/detail/const_container.hpp +++ b/extras/beast/unit_test/detail/const_container.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/dstream.hpp b/extras/beast/unit_test/dstream.hpp index b3d26ca5e..c62c8060b 100644 --- a/extras/beast/unit_test/dstream.hpp +++ b/extras/beast/unit_test/dstream.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/global_suites.hpp b/extras/beast/unit_test/global_suites.hpp index f6e1ab2cf..90664da49 100644 --- a/extras/beast/unit_test/global_suites.hpp +++ b/extras/beast/unit_test/global_suites.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/main.cpp b/extras/beast/unit_test/main.cpp index 1da1de32b..93435ab6c 100644 --- a/extras/beast/unit_test/main.cpp +++ b/extras/beast/unit_test/main.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/match.hpp b/extras/beast/unit_test/match.hpp index 8e0e9b644..c41043f7b 100644 --- a/extras/beast/unit_test/match.hpp +++ b/extras/beast/unit_test/match.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/recorder.hpp b/extras/beast/unit_test/recorder.hpp index 72cc3ac73..f8587bcbf 100644 --- a/extras/beast/unit_test/recorder.hpp +++ b/extras/beast/unit_test/recorder.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/reporter.hpp b/extras/beast/unit_test/reporter.hpp index c521fc238..771a76df9 100644 --- a/extras/beast/unit_test/reporter.hpp +++ b/extras/beast/unit_test/reporter.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -245,7 +245,7 @@ on_case_begin(std::string const& name) { case_results_ = case_results(name); os_ << suite_results_.name << - (case_results_.name.empty() ? "" : + (case_results_.name.empty() ? "" : (" " + case_results_.name)) << std::endl; } diff --git a/extras/beast/unit_test/results.hpp b/extras/beast/unit_test/results.hpp index 12b2add93..6ae014af5 100644 --- a/extras/beast/unit_test/results.hpp +++ b/extras/beast/unit_test/results.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/runner.hpp b/extras/beast/unit_test/runner.hpp index c0091c450..a150edf65 100644 --- a/extras/beast/unit_test/runner.hpp +++ b/extras/beast/unit_test/runner.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/suite.hpp b/extras/beast/unit_test/suite.hpp index cf01ee0e1..721f49a44 100644 --- a/extras/beast/unit_test/suite.hpp +++ b/extras/beast/unit_test/suite.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -134,7 +134,7 @@ private: } /** Open a new testcase. - + A testcase is a series of evaluated test conditions. A test suite may have multiple test cases. A test is associated with the last opened testcase. When the test first runs, a default diff --git a/extras/beast/unit_test/suite_info.hpp b/extras/beast/unit_test/suite_info.hpp index 8e1d0f5ca..6baf2c47b 100644 --- a/extras/beast/unit_test/suite_info.hpp +++ b/extras/beast/unit_test/suite_info.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/suite_list.hpp b/extras/beast/unit_test/suite_list.hpp index 44bb4f908..e22817708 100644 --- a/extras/beast/unit_test/suite_list.hpp +++ b/extras/beast/unit_test/suite_list.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/extras/beast/unit_test/thread.hpp b/extras/beast/unit_test/thread.hpp index 0de8577a0..8f3263af3 100644 --- a/extras/beast/unit_test/thread.hpp +++ b/extras/beast/unit_test/thread.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core.hpp b/include/beast/core.hpp index a46ad0036..ed777e54b 100644 --- a/include/beast/core.hpp +++ b/include/beast/core.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -9,7 +9,6 @@ #define BEAST_CORE_HPP #include -#include #include #include #include diff --git a/include/beast/core/async_completion.hpp b/include/beast/core/async_completion.hpp index dd41e76e1..af5c67d2c 100644 --- a/include/beast/core/async_completion.hpp +++ b/include/beast/core/async_completion.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -38,7 +38,7 @@ namespace beast { async_initfn(..., CompletionHandler&& handler) { async_completion completion(handler); + void(error_code)> completion{handler}; ... return completion.result.get(); } diff --git a/include/beast/core/basic_streambuf.hpp b/include/beast/core/basic_streambuf.hpp deleted file mode 100644 index 9dac4c068..000000000 --- a/include/beast/core/basic_streambuf.hpp +++ /dev/null @@ -1,333 +0,0 @@ -// -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef BEAST_BASIC_STREAMBUF_HPP -#define BEAST_BASIC_STREAMBUF_HPP - -#include -#include -#include -#include -#include -#include -#include - -namespace beast { - -/** A @b `DynamicBuffer` that uses multiple buffers internally. - - The implementation uses a sequence of one or more character arrays - of varying sizes. Additional character array objects are appended to - the sequence to accommodate changes in the size of the character - sequence. - - @note Meets the requirements of @b DynamicBuffer. - - @tparam Allocator The allocator to use for managing memory. -*/ -template -class basic_streambuf -#if ! GENERATING_DOCS - : private detail::empty_base_optimization< - typename std::allocator_traits:: - template rebind_alloc> -#endif -{ -public: -#if GENERATING_DOCS - /// The type of allocator used. - using allocator_type = Allocator; -#else - using allocator_type = typename - std::allocator_traits:: - template rebind_alloc; -#endif - -private: - // Storage for the list of buffers representing the input - // and output sequences. The allocation for each element - // contains `element` followed by raw storage bytes. - class element; - - using alloc_traits = std::allocator_traits; - using list_type = typename boost::intrusive::make_list>::type; - using iterator = typename list_type::iterator; - using const_iterator = typename list_type::const_iterator; - - using size_type = typename std::allocator_traits::size_type; - using const_buffer = boost::asio::const_buffer; - using mutable_buffer = boost::asio::mutable_buffer; - - static_assert(std::is_base_of::iterator_category>::value, - "BidirectionalIterator requirements not met"); - - static_assert(std::is_base_of::iterator_category>::value, - "BidirectionalIterator requirements not met"); - - list_type list_; // list of allocated buffers - iterator out_; // element that contains out_pos_ - size_type alloc_size_; // min amount to allocate - size_type in_size_ = 0; // size of the input sequence - size_type in_pos_ = 0; // input offset in list_.front() - size_type out_pos_ = 0; // output offset in *out_ - size_type out_end_ = 0; // output end offset in list_.back() - -public: -#if GENERATING_DOCS - /// The type used to represent the input sequence as a list of buffers. - using const_buffers_type = implementation_defined; - - /// The type used to represent the output sequence as a list of buffers. - using mutable_buffers_type = implementation_defined; - -#else - class const_buffers_type; - - class mutable_buffers_type; - -#endif - - /// Destructor. - ~basic_streambuf(); - - /** Move constructor. - - The new object will have the input sequence of - the other stream buffer, and an empty output sequence. - - @note After the move, the moved-from object will have - an empty input and output sequence, with no internal - buffers allocated. - */ - basic_streambuf(basic_streambuf&&); - - /** Move constructor. - - The new object will have the input sequence of - the other stream buffer, and an empty output sequence. - - @note After the move, the moved-from object will have - an empty input and output sequence, with no internal - buffers allocated. - - @param alloc The allocator to associate with the - stream buffer. - */ - basic_streambuf(basic_streambuf&&, - allocator_type const& alloc); - - /** Move assignment. - - This object will have the input sequence of - the other stream buffer, and an empty output sequence. - - @note After the move, the moved-from object will have - an empty input and output sequence, with no internal - buffers allocated. - */ - basic_streambuf& - operator=(basic_streambuf&&); - - /** Copy constructor. - - This object will have a copy of the other stream - buffer's input sequence, and an empty output sequence. - */ - basic_streambuf(basic_streambuf const&); - - /** Copy constructor. - - This object will have a copy of the other stream - buffer's input sequence, and an empty output sequence. - - @param alloc The allocator to associate with the - stream buffer. - */ - basic_streambuf(basic_streambuf const&, - allocator_type const& alloc); - - /** Copy assignment. - - This object will have a copy of the other stream - buffer's input sequence, and an empty output sequence. - */ - basic_streambuf& operator=(basic_streambuf const&); - - /** Copy constructor. - - This object will have a copy of the other stream - buffer's input sequence, and an empty output sequence. - */ - template - basic_streambuf(basic_streambuf const&); - - /** Copy constructor. - - This object will have a copy of the other stream - buffer's input sequence, and an empty output sequence. - - @param alloc The allocator to associate with the - stream buffer. - */ - template - basic_streambuf(basic_streambuf const&, - allocator_type const& alloc); - - /** Copy assignment. - - This object will have a copy of the other stream - buffer's input sequence, and an empty output sequence. - */ - template - basic_streambuf& operator=(basic_streambuf const&); - - /** Construct a stream buffer. - - @param alloc_size The size of buffer to allocate. This is a - soft limit, calls to prepare for buffers exceeding this size - will allocate the larger size. The default allocation size - is 1KB (1024 bytes). - - @param alloc The allocator to use. If this parameter is - unspecified, a default constructed allocator will be used. - */ - explicit - basic_streambuf(std::size_t alloc_size = 1024, - Allocator const& alloc = allocator_type{}); - - /// Returns a copy of the associated allocator. - allocator_type - get_allocator() const - { - return this->member(); - } - - /** Returns the default allocation size. - - This is the smallest size that the stream buffer will allocate. - The size of the allocation can influence capacity, which will - affect algorithms that use capacity to efficiently read from - streams. - */ - std::size_t - alloc_size() const - { - return alloc_size_; - } - - /** Set the default allocation size. - - This is the smallest size that the stream buffer will allocate. - The size of the allocation can influence capacity, which will - affect algorithms that use capacity to efficiently read from - streams. - - @note This will not affect any already-existing allocations. - - @param n The number of bytes. - */ - void - alloc_size(std::size_t n) - { - alloc_size_ = n; - } - - /// Returns the size of the input sequence. - size_type - size() const - { - return in_size_; - } - - /// Returns the permitted maximum sum of the sizes of the input and output sequence. - size_type - max_size() const - { - return (std::numeric_limits::max)(); - } - - /// Returns the maximum sum of the sizes of the input sequence and output sequence the buffer can hold without requiring reallocation. - std::size_t - capacity() const; - - /** Get a list of buffers that represents the input sequence. - - @note These buffers remain valid across subsequent calls to `prepare`. - */ - const_buffers_type - data() const; - - /** Get a list of buffers that represents the output sequence, with the given size. - - @note Buffers representing the input sequence acquired prior to - this call remain valid. - */ - mutable_buffers_type - prepare(size_type n); - - /** Move bytes from the output sequence to the input sequence. - - @note Buffers representing the input sequence acquired prior to - this call remain valid. - */ - void - commit(size_type n); - - /// Remove bytes from the input sequence. - void - consume(size_type n); - - // Helper for boost::asio::read_until - template - friend - std::size_t - read_size_helper(basic_streambuf< - OtherAllocator> const& streambuf, std::size_t max_size); - -private: - void - clear(); - - void - move_assign(basic_streambuf& other, std::false_type); - - void - move_assign(basic_streambuf& other, std::true_type); - - void - copy_assign(basic_streambuf const& other, std::false_type); - - void - copy_assign(basic_streambuf const& other, std::true_type); - - void - delete_list(); - - void - debug_check() const; -}; - -/** Format output to a @ref basic_streambuf. - - @param streambuf The @ref basic_streambuf to write to. - - @param t The object to write. - - @return A reference to the @ref basic_streambuf. -*/ -template -basic_streambuf& -operator<<(basic_streambuf& streambuf, T const& t); - -} // beast - -#include - -#endif diff --git a/include/beast/core/bind_handler.hpp b/include/beast/core/bind_handler.hpp index b01365e77..a9094abb4 100644 --- a/include/beast/core/bind_handler.hpp +++ b/include/beast/core/bind_handler.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -15,21 +15,23 @@ namespace beast { -/** Bind parameters to a completion handler, creating a wrapped handler. +/** Bind parameters to a completion handler, creating a new handler. This function creates a new handler which, when invoked with no - parameters, calls the original handler with the list of bound arguments. - The passed handler and arguments are forwarded into the returned handler, - which provides the same `io_service` execution guarantees as the original - handler. + parameters, calls the original handler with the list of bound + arguments. The passed handler and arguments are forwarded into + the returned handler, which provides the same `io_service` + execution guarantees as the original handler. - Unlike `io_service::wrap`, the returned handler can be used in a - subsequent call to `io_service::post` instead of `io_service::dispatch`, - to ensure that the handler will not be invoked immediately by the - calling function. + Unlike `io_service::wrap`, the returned handler can be used in + a subsequent call to `io_service::post` instead of + `io_service::dispatch`, to ensure that the handler will not be + invoked immediately by the calling function. Example: + @code + template void do_cancel(AsyncReadStream& stream, ReadHandler&& handler) @@ -38,6 +40,7 @@ namespace beast { bind_handler(std::forward(handler), boost::asio::error::operation_aborted, 0)); } + @endcode @param handler The handler to wrap. @@ -45,22 +48,21 @@ namespace beast { @param args A list of arguments to bind to the handler. The arguments are forwarded into the returned object. */ -template +template #if GENERATING_DOCS implementation_defined #else detail::bound_handler< - typename std::decay::type, Args...> + typename std::decay::type, Args...> #endif -bind_handler(CompletionHandler&& handler, Args&&... args) +bind_handler(Handler&& handler, Args&&... args) { static_assert(is_CompletionHandler< - CompletionHandler, void(Args...)>::value, - "CompletionHandler requirements not met"); + Handler, void(Args...)>::value, + "Handler requirements not met"); return detail::bound_handler::type, Args...>(std::forward< - CompletionHandler>(handler), - std::forward(args)...); + Handler>::type, Args...>(std::forward< + Handler>(handler), std::forward(args)...); } } // beast diff --git a/include/beast/core/buffer_cat.hpp b/include/beast/core/buffer_cat.hpp index d8c24b44e..cd2062621 100644 --- a/include/beast/core/buffer_cat.hpp +++ b/include/beast/core/buffer_cat.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -24,8 +24,9 @@ namespace beast { This function returns a constant or mutable buffer sequence which, when iterated, efficiently concatenates the input buffer sequences. Copies of the arguments passed will be made; however, the returned - object does not take ownership of the underlying memory. The application - is still responsible for managing the lifetime of the referenced memory. + object does not take ownership of the underlying memory. The + application is still responsible for managing the lifetime of the + referenced memory. @param buffers The list of buffer sequences to concatenate. diff --git a/include/beast/core/buffer_concepts.hpp b/include/beast/core/buffer_concepts.hpp index addc3cdf3..5348724b0 100644 --- a/include/beast/core/buffer_concepts.hpp +++ b/include/beast/core/buffer_concepts.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/buffers_adapter.hpp b/include/beast/core/buffers_adapter.hpp index 23adee165..9dadf7f13 100644 --- a/include/beast/core/buffers_adapter.hpp +++ b/include/beast/core/buffers_adapter.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/consuming_buffers.hpp b/include/beast/core/consuming_buffers.hpp index 87c3b8416..8e09ac584 100644 --- a/include/beast/core/consuming_buffers.hpp +++ b/include/beast/core/consuming_buffers.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -30,12 +30,6 @@ namespace beast { is still responsible for managing its lifetime. @tparam BufferSequence The buffer sequence to wrap. - - @tparam ValueType The type of buffer of the final buffer sequence. This - can be different from the buffer type of the wrapped sequence. For - example, a `MutableBufferSequence` can be transformed into a - consumable `ConstBufferSequence`. Violations of buffer const safety - are not permitted, and will result in a compile error. */ template class consuming_buffers @@ -45,6 +39,7 @@ class consuming_buffers BufferSequence bs_; iter_type begin_; + iter_type end_; std::size_t skip_ = 0; template @@ -56,13 +51,23 @@ class consuming_buffers } public: - /// The type for each element in the list of buffers. + /** The type for each element in the list of buffers. + + If the buffers in the underlying sequence are convertible to + `boost::asio::mutable_buffer`, then this type will be + `boost::asio::mutable_buffer`, else this type will be + `boost::asio::const_buffer`. + */ +#if GENERATING_DOCS + using value_type = ...; +#else using value_type = typename std::conditional< std::is_convertible::value_type, boost::asio::mutable_buffer>::value, boost::asio::mutable_buffer, boost::asio::const_buffer>::type; +#endif #if GENERATING_DOCS /// A bidirectional iterator type that may be used to read elements. diff --git a/include/beast/core/detail/base64.hpp b/include/beast/core/detail/base64.hpp index 801562d51..407b79db3 100644 --- a/include/beast/core/detail/base64.hpp +++ b/include/beast/core/detail/base64.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/bind_handler.hpp b/include/beast/core/detail/bind_handler.hpp index f53b1efa4..d3cc3cdce 100644 --- a/include/beast/core/detail/bind_handler.hpp +++ b/include/beast/core/detail/bind_handler.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -42,7 +42,8 @@ public: template explicit - bound_handler(DeducedHandler&& handler, Args&&... args) + bound_handler( + DeducedHandler&& handler, Args&&... args) : h_(std::forward(handler)) , args_(std::forward(args)...) { @@ -102,9 +103,11 @@ public: } // beast #include + namespace std { template -void bind(beast::detail::bound_handler< +void +bind(beast::detail::bound_handler< Handler, Args...>, ...) = delete; } // std diff --git a/include/beast/core/detail/buffer_cat.hpp b/include/beast/core/detail/buffer_cat.hpp index e414b7ed4..b5dcd4aaf 100644 --- a/include/beast/core/detail/buffer_cat.hpp +++ b/include/beast/core/detail/buffer_cat.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/buffer_concepts.hpp b/include/beast/core/detail/buffer_concepts.hpp index 6a4ef13d6..6391de4c3 100644 --- a/include/beast/core/detail/buffer_concepts.hpp +++ b/include/beast/core/detail/buffer_concepts.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/ci_char_traits.hpp b/include/beast/core/detail/ci_char_traits.hpp index 0a388b7aa..7dfd0c18c 100644 --- a/include/beast/core/detail/ci_char_traits.hpp +++ b/include/beast/core/detail/ci_char_traits.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/clamp.hpp b/include/beast/core/detail/clamp.hpp index 7c158da10..21afeaaaf 100644 --- a/include/beast/core/detail/clamp.hpp +++ b/include/beast/core/detail/clamp.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/empty_base_optimization.hpp b/include/beast/core/detail/empty_base_optimization.hpp index 635f71ff1..a0ca44460 100644 --- a/include/beast/core/detail/empty_base_optimization.hpp +++ b/include/beast/core/detail/empty_base_optimization.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/get_lowest_layer.hpp b/include/beast/core/detail/get_lowest_layer.hpp index 33684936f..4b199ce66 100644 --- a/include/beast/core/detail/get_lowest_layer.hpp +++ b/include/beast/core/detail/get_lowest_layer.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/integer_sequence.hpp b/include/beast/core/detail/integer_sequence.hpp index 73389c53b..3a2fa418d 100644 --- a/include/beast/core/detail/integer_sequence.hpp +++ b/include/beast/core/detail/integer_sequence.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/is_call_possible.hpp b/include/beast/core/detail/is_call_possible.hpp index 247eb48f2..bafc2a33d 100644 --- a/include/beast/core/detail/is_call_possible.hpp +++ b/include/beast/core/detail/is_call_possible.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -26,8 +26,12 @@ std::false_type is_call_possible_test(C&& c, long, A&& ...a); /** Metafunction returns `true` if F callable as R(A...) + Example: + + @code is_call_possible + @endcode */ /** @{ */ template @@ -44,49 +48,6 @@ struct is_call_possible }; /** @} */ -namespace test { - -struct is_call_possible_udt1 -{ - void operator()(int) const; -}; - -struct is_call_possible_udt2 -{ - int operator()(int) const; -}; - -struct is_call_possible_udt3 -{ - int operator()(int); -}; - -#ifndef __INTELLISENSE__ -// VFALCO Fails to compile with Intellisense -static_assert(is_call_possible< - is_call_possible_udt1, void(int)>::value, ""); - -static_assert(! is_call_possible< - is_call_possible_udt1, void(void)>::value, ""); - -static_assert(is_call_possible< - is_call_possible_udt2, int(int)>::value, ""); - -static_assert(! is_call_possible< - is_call_possible_udt2, int(void)>::value, ""); - -static_assert(! is_call_possible< - is_call_possible_udt2, void(void)>::value, ""); - -static_assert(is_call_possible< - is_call_possible_udt3, int(int)>::value, ""); - -static_assert(! is_call_possible< - is_call_possible_udt3 const, int(int)>::value, ""); -#endif - -} // test - } // detail } // beast diff --git a/include/beast/core/detail/prepare_buffers.hpp b/include/beast/core/detail/prepare_buffers.hpp index 129417e68..4f9441c9b 100644 --- a/include/beast/core/detail/prepare_buffers.hpp +++ b/include/beast/core/detail/prepare_buffers.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/sha1.hpp b/include/beast/core/detail/sha1.hpp index 28a744ec2..7e8e6383b 100644 --- a/include/beast/core/detail/sha1.hpp +++ b/include/beast/core/detail/sha1.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -48,7 +48,7 @@ blk(std::uint32_t block[BLOCK_INTS], std::size_t i) } inline -void +void R0(std::uint32_t block[BLOCK_INTS], std::uint32_t v, std::uint32_t &w, std::uint32_t x, std::uint32_t y, std::uint32_t &z, std::size_t i) diff --git a/include/beast/core/detail/stream_concepts.hpp b/include/beast/core/detail/stream_concepts.hpp index 7dcf0806f..c51991eb0 100644 --- a/include/beast/core/detail/stream_concepts.hpp +++ b/include/beast/core/detail/stream_concepts.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/sync_ostream.hpp b/include/beast/core/detail/sync_ostream.hpp index 2d5b9e82e..5a4e0b47a 100644 --- a/include/beast/core/detail/sync_ostream.hpp +++ b/include/beast/core/detail/sync_ostream.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/type_traits.hpp b/include/beast/core/detail/type_traits.hpp index f50b3a3c0..4b6acbd44 100644 --- a/include/beast/core/detail/type_traits.hpp +++ b/include/beast/core/detail/type_traits.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/detail/write_dynabuf.hpp b/include/beast/core/detail/write_dynabuf.hpp index 85447f50a..dcef73afc 100644 --- a/include/beast/core/detail/write_dynabuf.hpp +++ b/include/beast/core/detail/write_dynabuf.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/dynabuf_readstream.hpp b/include/beast/core/dynabuf_readstream.hpp index 32c545cc2..44501a658 100644 --- a/include/beast/core/dynabuf_readstream.hpp +++ b/include/beast/core/dynabuf_readstream.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -179,13 +179,7 @@ public: return sb_; } - /** Access the internal buffer. - - The internal buffer is returned. It is possible for the - caller to break invariants with this function. For example, - by causing the internal buffer size to increase beyond - the caller defined maximum. - */ + /// Access the internal buffer DynamicBuffer const& buffer() const { @@ -213,8 +207,83 @@ public: capacity_ = size; } - /// Write the given data to the stream. Returns the number of bytes written. - /// Throws an exception on failure. + /** Read some data from the stream. + + This function is used to read data from the stream. + The function call will block until one or more bytes of + data has been read successfully, or until an error occurs. + + @param buffers One or more buffers into which the data will be read. + + @return The number of bytes read. + + @throws system_error Thrown on failure. + */ + template + std::size_t + read_some(MutableBufferSequence const& buffers); + + /** Read some data from the stream. + + This function is used to read data from the stream. + The function call will block until one or more bytes of + data has been read successfully, or until an error occurs. + + @param buffers One or more buffers into which the data will be read. + + @param ec Set to the error, if any occurred. + + @return The number of bytes read, or 0 on error. + */ + template + std::size_t + read_some(MutableBufferSequence const& buffers, + error_code& ec); + + /** Start an asynchronous read. + + This function is used to asynchronously read data from + the stream. The function call always returns immediately. + + @param buffers One or more buffers into which the data + will be read. Although the buffers object may be copied + as necessary, ownership of the underlying memory blocks + is retained by the caller, which must guarantee that they + remain valid until the handler is called. + + @param handler The handler to be called when the operation + completes. Copies will be made of the handler as required. + The equivalent function signature of the handler must be: + @code void handler( + error_code const& error, // result of operation + std::size_t bytes_transferred // number of bytes transferred + ); @endcode + Regardless of whether the asynchronous operation completes + immediately or not, the handler will not be invoked from within + this function. Invocation of the handler will be performed in a + manner equivalent to using `boost::asio::io_service::post`. + */ + template +#if GENERATING_DOCS + void_or_deduced +#else + typename async_completion::result_type +#endif + async_read_some(MutableBufferSequence const& buffers, + ReadHandler&& handler); + + /** Write some data to the stream. + + This function is used to write data to the stream. + The function call will block until one or more bytes of the + data has been written successfully, or until an error occurs. + + @param buffers One or more data buffers to be written to the stream. + + @return The number of bytes written. + + @throws system_error Thrown on failure. + */ template std::size_t write_some(ConstBufferSequence const& buffers) @@ -224,8 +293,18 @@ public: return next_layer_.write_some(buffers); } - /// Write the given data to the stream. Returns the number of bytes written, - /// or 0 if an error occurred. + /** Write some data to the stream. + + This function is used to write data to the stream. + The function call will block until one or more bytes of the + data has been written successfully, or until an error occurs. + + @param buffers One or more data buffers to be written to the stream. + + @param ec Set to the error, if any occurred. + + @return The number of bytes written. + */ template std::size_t write_some(ConstBufferSequence const& buffers, @@ -236,8 +315,29 @@ public: return next_layer_.write_some(buffers, ec); } - /// Start an asynchronous write. The data being written must be valid for the - /// lifetime of the asynchronous operation. + /** Start an asynchronous write. + + This function is used to asynchronously write data from + the stream. The function call always returns immediately. + + @param buffers One or more data buffers to be written to + the stream. Although the buffers object may be copied as + necessary, ownership of the underlying memory blocks is + retained by the caller, which must guarantee that they + remain valid until the handler is called. + + @param handler The handler to be called when the operation + completes. Copies will be made of the handler as required. + The equivalent function signature of the handler must be: + @code void handler( + error_code const& error, // result of operation + std::size_t bytes_transferred // number of bytes transferred + ); @endcode + Regardless of whether the asynchronous operation completes + immediately or not, the handler will not be invoked from within + this function. Invocation of the handler will be performed in a + manner equivalent to using `boost::asio::io_service::post`. + */ template #if GENERATING_DOCS void_or_deduced @@ -246,30 +346,6 @@ public: #endif async_write_some(ConstBufferSequence const& buffers, WriteHandler&& handler); - - /// Read some data from the stream. Returns the number of bytes read. - /// Throws an exception on failure. - template - std::size_t - read_some(MutableBufferSequence const& buffers); - - /// Read some data from the stream. Returns the number of bytes read - /// or 0 if an error occurred. - template - std::size_t - read_some(MutableBufferSequence const& buffers, - error_code& ec); - - /// Start an asynchronous read. The buffer into which the data will be read - /// must be valid for the lifetime of the asynchronous operation. - template -#if GENERATING_DOCS - void_or_deduced -#else - typename async_completion::result_type -#endif - async_read_some(MutableBufferSequence const& buffers, - ReadHandler&& handler); }; } // beast diff --git a/include/beast/core/error.hpp b/include/beast/core/error.hpp index d5dc92be0..f94e52b5c 100644 --- a/include/beast/core/error.hpp +++ b/include/beast/core/error.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/handler_alloc.hpp b/include/beast/core/handler_alloc.hpp index 814fee318..4037efc51 100644 --- a/include/beast/core/handler_alloc.hpp +++ b/include/beast/core/handler_alloc.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -28,28 +28,29 @@ namespace beast { @tparam T The type of objects allocated by the allocator. - @tparam CompletionHandler The type of handler. + @tparam Handler The type of handler. @note Memory allocated by this allocator must be freed before - the handler is invoked or undefined behavior results. + the handler is invoked or undefined behavior results. This behavior + is described as the "deallocate before invocation" Asio guarantee. */ #if GENERATING_DOCS -template +template class handler_alloc; #else -template +template class handler_alloc { private: // We want a partial template specialization as a friend // but that isn't allowed so we friend all versions. This - // should produce a compile error if CompletionHandler is not + // should produce a compile error if Handler is not // constructible from H. // template friend class handler_alloc; - CompletionHandler& h_; + Handler& h_; public: using value_type = T; @@ -58,7 +59,7 @@ public: template struct rebind { - using other = handler_alloc; + using other = handler_alloc; }; handler_alloc() = delete; @@ -73,7 +74,7 @@ public: remain valid for at least the lifetime of the allocator. */ explicit - handler_alloc(CompletionHandler& h) + handler_alloc(Handler& h) : h_(h) { } @@ -81,7 +82,7 @@ public: /// Copy constructor template handler_alloc( - handler_alloc const& other) + handler_alloc const& other) : h_(other.h_) { } @@ -118,7 +119,7 @@ public: friend bool operator==(handler_alloc const& lhs, - handler_alloc const& rhs) + handler_alloc const& rhs) { return true; } @@ -127,9 +128,9 @@ public: friend bool operator!=(handler_alloc const& lhs, - handler_alloc const& rhs) + handler_alloc const& rhs) { - return !(lhs == rhs); + return ! (lhs == rhs); } }; #endif diff --git a/include/beast/core/handler_concepts.hpp b/include/beast/core/handler_concepts.hpp index 33c43f075..2e3854d37 100644 --- a/include/beast/core/handler_concepts.hpp +++ b/include/beast/core/handler_concepts.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/handler_helpers.hpp b/include/beast/core/handler_helpers.hpp index ee3f7979b..2ff589ad4 100644 --- a/include/beast/core/handler_helpers.hpp +++ b/include/beast/core/handler_helpers.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -14,7 +14,7 @@ #include /* Calls to: - + * asio_handler_allocate * asio_handler_deallocate * asio_handler_invoke diff --git a/include/beast/core/handler_ptr.hpp b/include/beast/core/handler_ptr.hpp index 45285f48d..46dc5265c 100644 --- a/include/beast/core/handler_ptr.hpp +++ b/include/beast/core/handler_ptr.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/impl/buffers_adapter.ipp b/include/beast/core/impl/buffers_adapter.ipp index 309830f1e..286cfa86f 100644 --- a/include/beast/core/impl/buffers_adapter.ipp +++ b/include/beast/core/impl/buffers_adapter.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/impl/consuming_buffers.ipp b/include/beast/core/impl/consuming_buffers.ipp index dcfca362b..cebf1195c 100644 --- a/include/beast/core/impl/consuming_buffers.ipp +++ b/include/beast/core/impl/consuming_buffers.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/impl/dynabuf_readstream.ipp b/include/beast/core/impl/dynabuf_readstream.ipp index 3981c771d..5a0815baa 100644 --- a/include/beast/core/impl/dynabuf_readstream.ipp +++ b/include/beast/core/impl/dynabuf_readstream.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -242,7 +242,7 @@ async_read_some( "MutableBufferSequence requirements not met"); beast::async_completion< ReadHandler, void(error_code, std::size_t) - > completion(handler); + > completion{handler}; read_some_op{ completion.handler, *this, buffers}; diff --git a/include/beast/core/impl/handler_ptr.ipp b/include/beast/core/impl/handler_ptr.ipp index eb29e9984..2243d5df3 100644 --- a/include/beast/core/impl/handler_ptr.ipp +++ b/include/beast/core/impl/handler_ptr.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/impl/static_streambuf.ipp b/include/beast/core/impl/static_streambuf.ipp index 44c4e2610..90a483462 100644 --- a/include/beast/core/impl/static_streambuf.ipp +++ b/include/beast/core/impl/static_streambuf.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/impl/basic_streambuf.ipp b/include/beast/core/impl/streambuf.ipp similarity index 98% rename from include/beast/core/impl/basic_streambuf.ipp rename to include/beast/core/impl/streambuf.ipp index 710a5a1a7..ea39d7638 100644 --- a/include/beast/core/impl/basic_streambuf.ipp +++ b/include/beast/core/impl/streambuf.ipp @@ -1,12 +1,12 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef BEAST_IMPL_BASIC_STREAMBUF_IPP -#define BEAST_IMPL_BASIC_STREAMBUF_IPP +#ifndef BEAST_IMPL_STREAMBUF_IPP +#define BEAST_IMPL_STREAMBUF_IPP #include #include @@ -624,7 +624,7 @@ basic_streambuf::prepare(size_type n) -> auto const len = e.size() + sizeof(e); alloc_traits::destroy(this->member(), &e); alloc_traits::deallocate(this->member(), - reinterpret_cast(&e), len); + reinterpret_cast(&e), len); } return mutable_buffers_type(*this); } @@ -696,7 +696,7 @@ basic_streambuf::consume(size_type n) auto const len = e.size() + sizeof(e); alloc_traits::destroy(this->member(), &e); alloc_traits::deallocate(this->member(), - reinterpret_cast(&e), len); + reinterpret_cast(&e), len); debug_check(); } else @@ -808,7 +808,7 @@ basic_streambuf::delete_list() auto const n = e.size() + sizeof(e); alloc_traits::destroy(this->member(), &e); alloc_traits::deallocate(this->member(), - reinterpret_cast(&e), n); + reinterpret_cast(&e), n); } } diff --git a/include/beast/core/placeholders.hpp b/include/beast/core/placeholders.hpp index 2ba1a7af3..5272bb28e 100644 --- a/include/beast/core/placeholders.hpp +++ b/include/beast/core/placeholders.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -21,9 +21,9 @@ static auto const bytes_transferred (std::placeholders::_2); static auto const iterator (std::placeholders::_2); static auto const signal_number (std::placeholders::_2); } -} +} // placeholders -} -} +} // asio +} // beast #endif diff --git a/include/beast/core/prepare_buffer.hpp b/include/beast/core/prepare_buffer.hpp index 315ea3964..2d05aa316 100644 --- a/include/beast/core/prepare_buffer.hpp +++ b/include/beast/core/prepare_buffer.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -18,7 +18,7 @@ namespace beast { The returned buffer points to the same memory as the passed buffer, but with a size that is equal to or less than the size of the original buffer. - + @param n The size of the returned buffer. @param buffer The buffer to shorten. Ownership of the @@ -43,7 +43,7 @@ prepare_buffer(std::size_t n, The returned buffer points to the same memory as the passed buffer, but with a size that is equal to or less than the size of the original buffer. - + @param n The size of the returned buffer. @param buffer The buffer to shorten. Ownership of the diff --git a/include/beast/core/prepare_buffers.hpp b/include/beast/core/prepare_buffers.hpp index 971725fee..4f1d6f1aa 100644 --- a/include/beast/core/prepare_buffers.hpp +++ b/include/beast/core/prepare_buffers.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/static_streambuf.hpp b/include/beast/core/static_streambuf.hpp index 2323b3baa..748111b02 100644 --- a/include/beast/core/static_streambuf.hpp +++ b/include/beast/core/static_streambuf.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/static_string.hpp b/include/beast/core/static_string.hpp index 6a9ef1e6a..96e842ef1 100644 --- a/include/beast/core/static_string.hpp +++ b/include/beast/core/static_string.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/stream_concepts.hpp b/include/beast/core/stream_concepts.hpp index a93a7f10d..6e7765736 100644 --- a/include/beast/core/stream_concepts.hpp +++ b/include/beast/core/stream_concepts.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/streambuf.hpp b/include/beast/core/streambuf.hpp index 1726543f1..3683f68a9 100644 --- a/include/beast/core/streambuf.hpp +++ b/include/beast/core/streambuf.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -8,10 +8,312 @@ #ifndef BEAST_STREAMBUF_HPP #define BEAST_STREAMBUF_HPP -#include +#include +#include +#include +#include +#include +#include +#include namespace beast { +/** A @b `DynamicBuffer` that uses multiple buffers internally. + + The implementation uses a sequence of one or more character arrays + of varying sizes. Additional character array objects are appended to + the sequence to accommodate changes in the size of the character + sequence. + + @note Meets the requirements of @b DynamicBuffer. + + @tparam Allocator The allocator to use for managing memory. +*/ +template +class basic_streambuf +#if ! GENERATING_DOCS + : private detail::empty_base_optimization< + typename std::allocator_traits:: + template rebind_alloc> +#endif +{ +public: +#if GENERATING_DOCS + /// The type of allocator used. + using allocator_type = Allocator; +#else + using allocator_type = typename + std::allocator_traits:: + template rebind_alloc; +#endif + +private: + // Storage for the list of buffers representing the input + // and output sequences. The allocation for each element + // contains `element` followed by raw storage bytes. + class element; + + using alloc_traits = std::allocator_traits; + using list_type = typename boost::intrusive::make_list>::type; + using iterator = typename list_type::iterator; + using const_iterator = typename list_type::const_iterator; + + using size_type = typename std::allocator_traits::size_type; + using const_buffer = boost::asio::const_buffer; + using mutable_buffer = boost::asio::mutable_buffer; + + static_assert(std::is_base_of::iterator_category>::value, + "BidirectionalIterator requirements not met"); + + static_assert(std::is_base_of::iterator_category>::value, + "BidirectionalIterator requirements not met"); + + list_type list_; // list of allocated buffers + iterator out_; // element that contains out_pos_ + size_type alloc_size_; // min amount to allocate + size_type in_size_ = 0; // size of the input sequence + size_type in_pos_ = 0; // input offset in list_.front() + size_type out_pos_ = 0; // output offset in *out_ + size_type out_end_ = 0; // output end offset in list_.back() + +public: +#if GENERATING_DOCS + /// The type used to represent the input sequence as a list of buffers. + using const_buffers_type = implementation_defined; + + /// The type used to represent the output sequence as a list of buffers. + using mutable_buffers_type = implementation_defined; + +#else + class const_buffers_type; + + class mutable_buffers_type; + +#endif + + /// Destructor. + ~basic_streambuf(); + + /** Move constructor. + + The new object will have the input sequence of + the other stream buffer, and an empty output sequence. + + @note After the move, the moved-from object will have + an empty input and output sequence, with no internal + buffers allocated. + */ + basic_streambuf(basic_streambuf&&); + + /** Move constructor. + + The new object will have the input sequence of + the other stream buffer, and an empty output sequence. + + @note After the move, the moved-from object will have + an empty input and output sequence, with no internal + buffers allocated. + + @param alloc The allocator to associate with the + stream buffer. + */ + basic_streambuf(basic_streambuf&&, + allocator_type const& alloc); + + /** Move assignment. + + This object will have the input sequence of + the other stream buffer, and an empty output sequence. + + @note After the move, the moved-from object will have + an empty input and output sequence, with no internal + buffers allocated. + */ + basic_streambuf& + operator=(basic_streambuf&&); + + /** Copy constructor. + + This object will have a copy of the other stream + buffer's input sequence, and an empty output sequence. + */ + basic_streambuf(basic_streambuf const&); + + /** Copy constructor. + + This object will have a copy of the other stream + buffer's input sequence, and an empty output sequence. + + @param alloc The allocator to associate with the + stream buffer. + */ + basic_streambuf(basic_streambuf const&, + allocator_type const& alloc); + + /** Copy assignment. + + This object will have a copy of the other stream + buffer's input sequence, and an empty output sequence. + */ + basic_streambuf& operator=(basic_streambuf const&); + + /** Copy constructor. + + This object will have a copy of the other stream + buffer's input sequence, and an empty output sequence. + */ + template + basic_streambuf(basic_streambuf const&); + + /** Copy constructor. + + This object will have a copy of the other stream + buffer's input sequence, and an empty output sequence. + + @param alloc The allocator to associate with the + stream buffer. + */ + template + basic_streambuf(basic_streambuf const&, + allocator_type const& alloc); + + /** Copy assignment. + + This object will have a copy of the other stream + buffer's input sequence, and an empty output sequence. + */ + template + basic_streambuf& operator=(basic_streambuf const&); + + /** Construct a stream buffer. + + @param alloc_size The size of buffer to allocate. This is a + soft limit, calls to prepare for buffers exceeding this size + will allocate the larger size. The default allocation size + is 1KB (1024 bytes). + + @param alloc The allocator to use. If this parameter is + unspecified, a default constructed allocator will be used. + */ + explicit + basic_streambuf(std::size_t alloc_size = 1024, + Allocator const& alloc = allocator_type{}); + + /// Returns a copy of the associated allocator. + allocator_type + get_allocator() const + { + return this->member(); + } + + /** Returns the default allocation size. + + This is the smallest size that the stream buffer will allocate. + The size of the allocation can influence capacity, which will + affect algorithms that use capacity to efficiently read from + streams. + */ + std::size_t + alloc_size() const + { + return alloc_size_; + } + + /** Set the default allocation size. + + This is the smallest size that the stream buffer will allocate. + The size of the allocation can influence capacity, which will + affect algorithms that use capacity to efficiently read from + streams. + + @note This will not affect any already-existing allocations. + + @param n The number of bytes. + */ + void + alloc_size(std::size_t n) + { + alloc_size_ = n; + } + + /// Returns the size of the input sequence. + size_type + size() const + { + return in_size_; + } + + /// Returns the permitted maximum sum of the sizes of the input and output sequence. + size_type + max_size() const + { + return (std::numeric_limits::max)(); + } + + /// Returns the maximum sum of the sizes of the input sequence and output sequence the buffer can hold without requiring reallocation. + std::size_t + capacity() const; + + /** Get a list of buffers that represents the input sequence. + + @note These buffers remain valid across subsequent calls to `prepare`. + */ + const_buffers_type + data() const; + + /** Get a list of buffers that represents the output sequence, with the given size. + + @note Buffers representing the input sequence acquired prior to + this call remain valid. + */ + mutable_buffers_type + prepare(size_type n); + + /** Move bytes from the output sequence to the input sequence. + + @note Buffers representing the input sequence acquired prior to + this call remain valid. + */ + void + commit(size_type n); + + /// Remove bytes from the input sequence. + void + consume(size_type n); + + // Helper for boost::asio::read_until + template + friend + std::size_t + read_size_helper(basic_streambuf< + OtherAllocator> const& streambuf, std::size_t max_size); + +private: + void + clear(); + + void + move_assign(basic_streambuf& other, std::false_type); + + void + move_assign(basic_streambuf& other, std::true_type); + + void + copy_assign(basic_streambuf const& other, std::false_type); + + void + copy_assign(basic_streambuf const& other, std::true_type); + + void + delete_list(); + + void + debug_check() const; +}; + /** A @b `DynamicBuffer` that uses multiple buffers internally. The implementation uses a sequence of one or more character arrays @@ -23,6 +325,20 @@ namespace beast { */ using streambuf = basic_streambuf>; +/** Format output to a @ref basic_streambuf. + + @param streambuf The @ref basic_streambuf to write to. + + @param t The object to write. + + @return A reference to the @ref basic_streambuf. +*/ +template +basic_streambuf& +operator<<(basic_streambuf& streambuf, T const& t); + } // beast +#include + #endif diff --git a/include/beast/core/to_string.hpp b/include/beast/core/to_string.hpp index c415fd5cb..110022e0c 100644 --- a/include/beast/core/to_string.hpp +++ b/include/beast/core/to_string.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/core/write_dynabuf.hpp b/include/beast/core/write_dynabuf.hpp index e99c56f0e..54c365a53 100644 --- a/include/beast/core/write_dynabuf.hpp +++ b/include/beast/core/write_dynabuf.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http.hpp b/include/beast/http.hpp index ee475791b..dcb327918 100644 --- a/include/beast/http.hpp +++ b/include/beast/http.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/basic_dynabuf_body.hpp b/include/beast/http/basic_dynabuf_body.hpp index de2f43cde..cdae120aa 100644 --- a/include/beast/http/basic_dynabuf_body.hpp +++ b/include/beast/http/basic_dynabuf_body.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/basic_fields.hpp b/include/beast/http/basic_fields.hpp index 3bc957742..30913c8fe 100644 --- a/include/beast/http/basic_fields.hpp +++ b/include/beast/http/basic_fields.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/basic_parser_v1.hpp b/include/beast/http/basic_parser_v1.hpp index 70e9e06cb..939cf2c63 100644 --- a/include/beast/http/basic_parser_v1.hpp +++ b/include/beast/http/basic_parser_v1.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -35,7 +35,8 @@ enum parse_flag trailing = 16, upgrade = 32, skipbody = 64, - contentlength = 128 + contentlength = 128, + paused = 256 }; /** Body maximum size option. @@ -280,12 +281,12 @@ private: std::uint64_t content_length_; pmf_t cb_; state s_ : 8; - unsigned flags_ : 8; unsigned fs_ : 8; unsigned pos_ : 8; // position in field state unsigned http_major_ : 16; unsigned http_minor_ : 16; unsigned status_code_ : 16; + unsigned flags_ : 9; bool upgrade_ : 1; // true if parser exited for upgrade public: @@ -434,7 +435,7 @@ public: return s_ == s_restart || s_ == s_closed_complete || - s_ == s_body_pause; + (flags_ & parse_flag::paused); } /** Write a sequence of buffers to the parser. diff --git a/include/beast/http/chunk_encode.hpp b/include/beast/http/chunk_encode.hpp index cb2881b48..fabdd1b56 100644 --- a/include/beast/http/chunk_encode.hpp +++ b/include/beast/http/chunk_encode.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/concepts.hpp b/include/beast/http/concepts.hpp index f77777de3..9d43080cf 100644 --- a/include/beast/http/concepts.hpp +++ b/include/beast/http/concepts.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/detail/basic_fields.hpp b/include/beast/http/detail/basic_fields.hpp index a60b30f2b..3470c88fc 100644 --- a/include/beast/http/detail/basic_fields.hpp +++ b/include/beast/http/detail/basic_fields.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/detail/basic_parser_v1.hpp b/include/beast/http/detail/basic_parser_v1.hpp index 30f9e7bec..2df947d14 100644 --- a/include/beast/http/detail/basic_parser_v1.hpp +++ b/include/beast/http/detail/basic_parser_v1.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/detail/chunk_encode.hpp b/include/beast/http/detail/chunk_encode.hpp index e2ebb8123..f496dcfe8 100644 --- a/include/beast/http/detail/chunk_encode.hpp +++ b/include/beast/http/detail/chunk_encode.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/detail/rfc7230.hpp b/include/beast/http/detail/rfc7230.hpp index 191eaeedd..942a9e9f9 100644 --- a/include/beast/http/detail/rfc7230.hpp +++ b/include/beast/http/detail/rfc7230.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -288,7 +288,7 @@ increment() { /* param-list = *( OWS ";" OWS param ) - param = token OWS [ "=" OWS ( token / quoted-string ) ] + param = token OWS [ "=" OWS ( token / quoted-string ) ] quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE qdtext = HTAB / SP / "!" / %x23-5B ; '#'-'[' / %x5D-7E ; ']'-'~' / obs-text quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) diff --git a/include/beast/http/empty_body.hpp b/include/beast/http/empty_body.hpp index e497b87f2..a1efddc29 100644 --- a/include/beast/http/empty_body.hpp +++ b/include/beast/http/empty_body.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/fields.hpp b/include/beast/http/fields.hpp index fb80ad7f1..649fbf779 100644 --- a/include/beast/http/fields.hpp +++ b/include/beast/http/fields.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/header_parser_v1.hpp b/include/beast/http/header_parser_v1.hpp index 9caafa44e..40f532054 100644 --- a/include/beast/http/header_parser_v1.hpp +++ b/include/beast/http/header_parser_v1.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/impl/basic_fields.ipp b/include/beast/http/impl/basic_fields.ipp index 8c421e9ef..069087207 100644 --- a/include/beast/http/impl/basic_fields.ipp +++ b/include/beast/http/impl/basic_fields.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/impl/basic_parser_v1.ipp b/include/beast/http/impl/basic_parser_v1.ipp index 9757b92a1..9b1be47df 100644 --- a/include/beast/http/impl/basic_parser_v1.ipp +++ b/include/beast/http/impl/basic_parser_v1.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -45,6 +45,7 @@ namespace http { template basic_parser_v1:: basic_parser_v1() + : flags_(0) { init(); } @@ -61,12 +62,12 @@ basic_parser_v1(basic_parser_v1< , content_length_(other.content_length_) , cb_(nullptr) , s_(other.s_) - , flags_(other.flags_) , fs_(other.fs_) , pos_(other.pos_) , http_major_(other.http_major_) , http_minor_(other.http_minor_) , status_code_(other.status_code_) + , flags_(other.flags_) , upgrade_(other.upgrade_) { BOOST_ASSERT(! other.cb_); @@ -88,13 +89,14 @@ operator=(basic_parser_v1< content_length_ = other.content_length_; cb_ = nullptr; s_ = other.s_; - flags_ = other.flags_; fs_ = other.fs_; pos_ = other.pos_; http_major_ = other.http_major_; http_minor_ = other.http_minor_; status_code_ = other.status_code_; + flags_ = other.flags_; upgrade_ = other.upgrade_; + flags_ &= ~parse_flag::paused; return *this; } @@ -581,7 +583,7 @@ write(boost::asio::const_buffer const& buffer, error_code& ec) field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text - obs-fold = CRLF 1*( SP / HTAB ) + obs-fold = CRLF 1*( SP / HTAB ) ; obsolete line folding */ case s_header_value0: @@ -880,7 +882,7 @@ write(boost::asio::const_buffer const& buffer, error_code& ec) case h_connection_keep_alive: fs_ = h_connection_keep_alive_ows; break; - + case h_connection_upgrade: fs_ = h_connection_upgrade_ows; break; @@ -966,6 +968,7 @@ write(boost::asio::const_buffer const& buffer, error_code& ec) case body_what::pause: ++p; s_ = s_body_pause; + flags_ |= parse_flag::paused; return used(); } s_ = s_headers_done; diff --git a/include/beast/http/impl/message.ipp b/include/beast/http/impl/message.ipp index 3f7c05650..b15b89d64 100644 --- a/include/beast/http/impl/message.ipp +++ b/include/beast/http/impl/message.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/impl/parse.ipp b/include/beast/http/impl/parse.ipp index c2ddae8ba..17219fc30 100644 --- a/include/beast/http/impl/parse.ipp +++ b/include/beast/http/impl/parse.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -143,7 +143,7 @@ operator()(error_code ec, std::size_t bytes_transferred, bool again) { // read d.state = 2; - auto const size = + auto const size = read_size_helper(d.db, 65536); BOOST_ASSERT(size > 0); d.s.async_read_some( @@ -289,7 +289,7 @@ async_parse(AsyncReadStream& stream, static_assert(is_Parser::value, "Parser requirements not met"); beast::async_completion completion(handler); + void(error_code)> completion{handler}; detail::parse_op{ completion.handler, stream, dynabuf, parser}; diff --git a/include/beast/http/impl/parse_error.ipp b/include/beast/http/impl/parse_error.ipp index 83578ceb0..d7943a0e9 100644 --- a/include/beast/http/impl/parse_error.ipp +++ b/include/beast/http/impl/parse_error.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/impl/read.ipp b/include/beast/http/impl/read.ipp index e009170f3..3bcf27c7b 100644 --- a/include/beast/http/impl/read.ipp +++ b/include/beast/http/impl/read.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -183,7 +183,7 @@ async_read(AsyncReadStream& stream, DynamicBuffer& dynabuf, static_assert(is_DynamicBuffer::value, "DynamicBuffer requirements not met"); beast::async_completion completion(handler); + void(error_code)> completion{handler}; detail::read_header_op{completion.handler, @@ -375,7 +375,7 @@ async_read(AsyncReadStream& stream, DynamicBuffer& dynabuf, message>::value, "Reader requirements not met"); beast::async_completion completion(handler); + void(error_code)> completion{handler}; detail::read_op{completion.handler, diff --git a/include/beast/http/impl/rfc7230.ipp b/include/beast/http/impl/rfc7230.ipp index 4de3a0fa5..5ad65c28d 100644 --- a/include/beast/http/impl/rfc7230.ipp +++ b/include/beast/http/impl/rfc7230.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/impl/write.ipp b/include/beast/http/impl/write.ipp index 13a507847..7e97eebd4 100644 --- a/include/beast/http/impl/write.ipp +++ b/include/beast/http/impl/write.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -234,7 +234,7 @@ async_write(AsyncWriteStream& stream, static_assert(is_AsyncWriteStream::value, "AsyncWriteStream requirements not met"); beast::async_completion completion(handler); + void(error_code)> completion{handler}; streambuf sb; detail::write_start_line(sb, msg); detail::write_fields(sb, msg.fields); @@ -278,7 +278,7 @@ struct write_preparation w.init(ec); if(ec) return; - + write_start_line(sb, msg); write_fields(sb, msg.fields); beast::write(sb, "\r\n"); @@ -728,7 +728,7 @@ async_write(AsyncWriteStream& stream, message>::value, "Writer requirements not met"); beast::async_completion completion(handler); + void(error_code)> completion{handler}; detail::write_op{completion.handler, stream, msg}; return completion.result.get(); diff --git a/include/beast/http/message.hpp b/include/beast/http/message.hpp index 007b48746..51cd8ae6c 100644 --- a/include/beast/http/message.hpp +++ b/include/beast/http/message.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/parse.hpp b/include/beast/http/parse.hpp index ed7f4f44d..b99fb57fd 100644 --- a/include/beast/http/parse.hpp +++ b/include/beast/http/parse.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/parse_error.hpp b/include/beast/http/parse_error.hpp index 43a664683..3dfcc0372 100644 --- a/include/beast/http/parse_error.hpp +++ b/include/beast/http/parse_error.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/parser_v1.hpp b/include/beast/http/parser_v1.hpp index fbcd34018..a86ac0503 100644 --- a/include/beast/http/parser_v1.hpp +++ b/include/beast/http/parser_v1.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/read.hpp b/include/beast/http/read.hpp index 67610e658..598180362 100644 --- a/include/beast/http/read.hpp +++ b/include/beast/http/read.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/reason.hpp b/include/beast/http/reason.hpp index 14b9bf7ca..1cdeced92 100644 --- a/include/beast/http/reason.hpp +++ b/include/beast/http/reason.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/resume_context.hpp b/include/beast/http/resume_context.hpp index 67c8d513a..45da149be 100644 --- a/include/beast/http/resume_context.hpp +++ b/include/beast/http/resume_context.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/rfc7230.hpp b/include/beast/http/rfc7230.hpp index 15407d0f1..defca9bf0 100644 --- a/include/beast/http/rfc7230.hpp +++ b/include/beast/http/rfc7230.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/streambuf_body.hpp b/include/beast/http/streambuf_body.hpp index 68a4a4ec6..0e0186a91 100644 --- a/include/beast/http/streambuf_body.hpp +++ b/include/beast/http/streambuf_body.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/string_body.hpp b/include/beast/http/string_body.hpp index 5b8101c75..9fbd16047 100644 --- a/include/beast/http/string_body.hpp +++ b/include/beast/http/string_body.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/http/write.hpp b/include/beast/http/write.hpp index f27937bdc..d5d7e1f25 100644 --- a/include/beast/http/write.hpp +++ b/include/beast/http/write.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/version.hpp b/include/beast/version.hpp index 10d4028c0..42c085c0f 100644 --- a/include/beast/version.hpp +++ b/include/beast/version.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,6 +16,6 @@ // #define BEAST_VERSION 100000 -#define BEAST_VERSION_STRING "1.0.0-b26" +#define BEAST_VERSION_STRING "1.0.0-b28" #endif diff --git a/include/beast/websocket.hpp b/include/beast/websocket.hpp index d6eac4483..55ec413b1 100644 --- a/include/beast/websocket.hpp +++ b/include/beast/websocket.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/detail/debug.hpp b/include/beast/websocket/detail/debug.hpp index 847a64494..2437993eb 100644 --- a/include/beast/websocket/detail/debug.hpp +++ b/include/beast/websocket/detail/debug.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/detail/decorator.hpp b/include/beast/websocket/detail/decorator.hpp index 4be383da2..558ff9e35 100644 --- a/include/beast/websocket/detail/decorator.hpp +++ b/include/beast/websocket/detail/decorator.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/detail/endian.hpp b/include/beast/websocket/detail/endian.hpp index c4f21bd35..e9276089e 100644 --- a/include/beast/websocket/detail/endian.hpp +++ b/include/beast/websocket/detail/endian.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/detail/frame.hpp b/include/beast/websocket/detail/frame.hpp index 3fece7b13..c3def4f3a 100644 --- a/include/beast/websocket/detail/frame.hpp +++ b/include/beast/websocket/detail/frame.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/detail/hybi13.hpp b/include/beast/websocket/detail/hybi13.hpp index b7ecb66a1..ec09918b1 100644 --- a/include/beast/websocket/detail/hybi13.hpp +++ b/include/beast/websocket/detail/hybi13.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/detail/invokable.hpp b/include/beast/websocket/detail/invokable.hpp index e2a9a24bc..62e62492f 100644 --- a/include/beast/websocket/detail/invokable.hpp +++ b/include/beast/websocket/detail/invokable.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/detail/mask.hpp b/include/beast/websocket/detail/mask.hpp index 8fb1bcac7..fdb8e86f4 100644 --- a/include/beast/websocket/detail/mask.hpp +++ b/include/beast/websocket/detail/mask.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/detail/pmd_extension.hpp b/include/beast/websocket/detail/pmd_extension.hpp index 8bccb1c87..e7c087a3d 100644 --- a/include/beast/websocket/detail/pmd_extension.hpp +++ b/include/beast/websocket/detail/pmd_extension.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/detail/stream_base.hpp b/include/beast/websocket/detail/stream_base.hpp index b183fc46c..0a1e26797 100644 --- a/include/beast/websocket/detail/stream_base.hpp +++ b/include/beast/websocket/detail/stream_base.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -59,14 +59,14 @@ protected: std::size_t wr_buf_size_ = 4096; // write buffer size std::size_t rd_buf_size_ = 4096; // read buffer size opcode wr_opcode_ = opcode::text; // outgoing message type - pong_cb pong_cb_; // pong callback + ping_cb ping_cb_; // ping callback role_type role_; // server or client bool failed_; // the connection failed bool wr_close_; // sent close frame op* wr_block_; // op currenly writing - ping_data* pong_data_; // where to put pong payload + ping_data* ping_data_; // where to put the payload invokable rd_op_; // invoked after write completes invokable wr_op_; // invoked after read completes close_reason cr_; // set from received close frame @@ -212,7 +212,7 @@ open(role_type role) rd_.cont = false; wr_close_ = false; wr_block_ = nullptr; // should be nullptr on close anyway - pong_data_ = nullptr; // should be nullptr on close anyway + ping_data_ = nullptr; // should be nullptr on close anyway wr_.cont = false; wr_.buf_size = 0; diff --git a/include/beast/websocket/detail/utf8_checker.hpp b/include/beast/websocket/detail/utf8_checker.hpp index be4619ba7..d8b146040 100644 --- a/include/beast/websocket/detail/utf8_checker.hpp +++ b/include/beast/websocket/detail/utf8_checker.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/error.hpp b/include/beast/websocket/error.hpp index 12e1306de..b41e8d6d7 100644 --- a/include/beast/websocket/error.hpp +++ b/include/beast/websocket/error.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/impl/accept.ipp b/include/beast/websocket/impl/accept.ipp index 7c3683a57..877be120c 100644 --- a/include/beast/websocket/impl/accept.ipp +++ b/include/beast/websocket/impl/accept.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -106,7 +106,7 @@ public: template template -void +void stream::response_op:: operator()(error_code ec, bool again) { @@ -288,7 +288,7 @@ async_accept(ConstBufferSequence const& bs, AcceptHandler&& handler) "ConstBufferSequence requirements not met"); beast::async_completion< AcceptHandler, void(error_code) - > completion(handler); + > completion{handler}; accept_op{ completion.handler, *this, bs}; return completion.result.get(); @@ -306,7 +306,7 @@ async_accept(http::request const& req, "AsyncStream requirements requirements not met"); beast::async_completion< AcceptHandler, void(error_code) - > completion(handler); + > completion{handler}; reset(); response_op{ completion.handler, *this, req, diff --git a/include/beast/websocket/impl/close.ipp b/include/beast/websocket/impl/close.ipp index 8af2c926c..0ad5992b9 100644 --- a/include/beast/websocket/impl/close.ipp +++ b/include/beast/websocket/impl/close.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -106,7 +106,7 @@ public: template template -void +void stream::close_op:: operator()(error_code ec, std::size_t) { @@ -118,7 +118,7 @@ operator()(error_code ec, std::size_t) template template -void +void stream::close_op:: operator()(error_code ec, bool again) { @@ -197,7 +197,7 @@ async_close(close_reason const& cr, CloseHandler&& handler) "AsyncStream requirements not met"); beast::async_completion< CloseHandler, void(error_code) - > completion(handler); + > completion{handler}; close_op{ completion.handler, *this, cr}; return completion.result.get(); diff --git a/include/beast/websocket/impl/error.ipp b/include/beast/websocket/impl/error.ipp index 19c497a4d..a31d20205 100644 --- a/include/beast/websocket/impl/error.ipp +++ b/include/beast/websocket/impl/error.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/impl/handshake.ipp b/include/beast/websocket/impl/handshake.ipp index 1397b52f7..11ea56181 100644 --- a/include/beast/websocket/impl/handshake.ipp +++ b/include/beast/websocket/impl/handshake.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -158,7 +158,7 @@ async_handshake(boost::string_ref const& host, "AsyncStream requirements not met"); beast::async_completion< HandshakeHandler, void(error_code) - > completion(handler); + > completion{handler}; handshake_op{ completion.handler, *this, host, resource}; return completion.result.get(); diff --git a/include/beast/websocket/impl/ping.ipp b/include/beast/websocket/impl/ping.ipp index 1fbf3eb8d..73990cce5 100644 --- a/include/beast/websocket/impl/ping.ipp +++ b/include/beast/websocket/impl/ping.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -103,7 +103,7 @@ public: template template -void +void stream::ping_op:: operator()(error_code ec, std::size_t) { @@ -195,7 +195,7 @@ async_ping(ping_data const& payload, WriteHandler&& handler) "AsyncStream requirements requirements not met"); beast::async_completion< WriteHandler, void(error_code) - > completion(handler); + > completion{handler}; ping_op{ completion.handler, *this, opcode::ping, payload}; @@ -213,7 +213,7 @@ async_pong(ping_data const& payload, WriteHandler&& handler) "AsyncStream requirements requirements not met"); beast::async_completion< WriteHandler, void(error_code) - > completion(handler); + > completion{handler}; ping_op{ completion.handler, *this, opcode::pong, payload}; diff --git a/include/beast/websocket/impl/read.ipp b/include/beast/websocket/impl/read.ipp index b495e3047..6e65beea6 100644 --- a/include/beast/websocket/impl/read.ipp +++ b/include/beast/websocket/impl/read.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -427,9 +427,11 @@ operator()(error_code ec, case do_control: if(d.fh.op == opcode::ping) { - ping_data data; - detail::read(data, d.fb.data()); + ping_data payload; + detail::read(payload, d.fb.data()); d.fb.reset(); + if(d.ws.ping_cb_) + d.ws.ping_cb_(false, payload); if(d.ws.wr_close_) { // ignore ping when closing @@ -437,7 +439,7 @@ operator()(error_code ec, break; } d.ws.template write_ping( - d.fb, opcode::pong, data); + d.fb, opcode::pong, payload); if(d.ws.wr_block_) { // suspend @@ -455,8 +457,8 @@ operator()(error_code ec, code = close_code::none; ping_data payload; detail::read(payload, d.fb.data()); - if(d.ws.pong_cb_) - d.ws.pong_cb_(payload); + if(d.ws.ping_cb_) + d.ws.ping_cb_(true, payload); d.fb.reset(); d.state = do_read_fh; break; @@ -671,7 +673,7 @@ async_read_frame(frame_info& fi, static_assert(beast::is_DynamicBuffer::value, "DynamicBuffer requirements not met"); beast::async_completion< - ReadHandler, void(error_code)> completion(handler); + ReadHandler, void(error_code)> completion{handler}; read_frame_op{ completion.handler, *this, fi, dynabuf}; return completion.result.get(); @@ -762,11 +764,13 @@ read_frame(frame_info& fi, DynamicBuffer& dynabuf, error_code& ec) // Process control frame if(fh.op == opcode::ping) { - ping_data data; - detail::read(data, fb.data()); + ping_data payload; + detail::read(payload, fb.data()); fb.reset(); + if(ping_cb_) + ping_cb_(false, payload); write_ping( - fb, opcode::pong, data); + fb, opcode::pong, payload); boost::asio::write(stream_, fb.data(), ec); failed_ = ec != 0; if(failed_) @@ -777,8 +781,8 @@ read_frame(frame_info& fi, DynamicBuffer& dynabuf, error_code& ec) { ping_data payload; detail::read(payload, fb.data()); - if(pong_cb_) - pong_cb_(payload); + if(ping_cb_) + ping_cb_(true, payload); continue; } BOOST_ASSERT(fh.op == opcode::close); @@ -1075,7 +1079,7 @@ async_read(opcode& op, "DynamicBuffer requirements not met"); beast::async_completion< ReadHandler, void(error_code) - > completion(handler); + > completion{handler}; read_op{ completion.handler, *this, op, dynabuf}; return completion.result.get(); diff --git a/include/beast/websocket/impl/ssl.ipp b/include/beast/websocket/impl/ssl.ipp index 76f6f4fc9..fc7353043 100644 --- a/include/beast/websocket/impl/ssl.ipp +++ b/include/beast/websocket/impl/ssl.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/impl/stream.ipp b/include/beast/websocket/impl/stream.ipp index a8c2ff615..fa932ffc7 100644 --- a/include/beast/websocket/impl/stream.ipp +++ b/include/beast/websocket/impl/stream.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -76,7 +76,7 @@ reset() wr_close_ = false; wr_.cont = false; wr_block_ = nullptr; // should be nullptr on close anyway - pong_data_ = nullptr; // should be nullptr on close anyway + ping_data_ = nullptr; // should be nullptr on close anyway stream_.buffer().consume( stream_.buffer().size()); diff --git a/include/beast/websocket/impl/teardown.ipp b/include/beast/websocket/impl/teardown.ipp index f12706524..cc8a46e36 100644 --- a/include/beast/websocket/impl/teardown.ipp +++ b/include/beast/websocket/impl/teardown.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/impl/write.ipp b/include/beast/websocket/impl/write.ipp index 1f8ea1d06..a278bbd56 100644 --- a/include/beast/websocket/impl/write.ipp +++ b/include/beast/websocket/impl/write.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -516,7 +516,7 @@ async_write_frame(bool fin, "ConstBufferSequence requirements not met"); beast::async_completion< WriteHandler, void(error_code) - > completion(handler); + > completion{handler}; write_frame_op{completion.handler, *this, fin, bs}; @@ -864,7 +864,7 @@ async_write(ConstBufferSequence const& bs, WriteHandler&& handler) ConstBufferSequence>::value, "ConstBufferSequence requirements not met"); beast::async_completion< - WriteHandler, void(error_code)> completion(handler); + WriteHandler, void(error_code)> completion{handler}; write_op{ completion.handler, *this, bs}; return completion.result.get(); diff --git a/include/beast/websocket/option.hpp b/include/beast/websocket/option.hpp index e656d0649..7d7ca602c 100644 --- a/include/beast/websocket/option.hpp +++ b/include/beast/websocket/option.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -188,7 +188,7 @@ struct message_type namespace detail { -using pong_cb = std::function; +using ping_cb = std::function; } // detail @@ -209,13 +209,13 @@ struct permessage_deflate bool client_enable = false; /** Maximum server window bits to offer - + @note Due to a bug in ZLib, this value must be greater than 8. */ int server_max_window_bits = 15; /** Maximum client window bits to offer - + @note Due to a bug in ZLib, this value must be greater than 8. */ int client_max_window_bits = 15; @@ -233,48 +233,55 @@ struct permessage_deflate int memLevel = 4; }; -/** Pong callback option. +/** Ping callback option. - Sets the callback to be invoked whenever a pong is received - during a call to @ref beast::websocket::stream::read, - @ref beast::websocket::stream::read_frame, - @ref beast::websocket::stream::async_read, or - @ref beast::websocket::stream::async_read_frame. + Sets the callback to be invoked whenever a ping or pong is + received during a call to one of the following functions: - Unlike completion handlers, the callback will be invoked for - each received pong during a call to any synchronous or - asynchronous read function. The operation is passive, with - no associated error code, and triggered by reads. + @li @ref beast::websocket::stream::read + @li @ref beast::websocket::stream::read_frame + @li @ref beast::websocket::stream::async_read + @li @ref beast::websocket::stream::async_read_frame + + Unlike completion handlers, the callback will be invoked + for each received ping and pong during a call to any + synchronous or asynchronous read function. The operation is + passive, with no associated error code, and triggered by reads. The signature of the callback must be: @code - void callback( + void + callback( + bool is_pong, // `true` if this is a pong ping_data const& payload // Payload of the pong frame ); @endcode - If the read operation receiving a pong frame is an asynchronous - operation, the callback will be invoked using the same method as - that used to invoke the final handler. + The value of `is_pong` will be `true` if a pong control frame + is received, and `false` if a ping control frame is received. + + If the read operation receiving a ping or pong frame is an + asynchronous operation, the callback will be invoked using + the same method as that used to invoke the final handler. @note Objects of this type are used with @ref beast::websocket::stream::set_option. - To remove the pong callback, construct the option with - no parameters: `set_option(pong_callback{})` + To remove the ping callback, construct the option with + no parameters: `set_option(ping_callback{})` */ #if GENERATING_DOCS -using pong_callback = implementation_defined; +using ping_callback = implementation_defined; #else -struct pong_callback +struct ping_callback { - detail::pong_cb value; + detail::ping_cb value; - pong_callback() = default; - pong_callback(pong_callback&&) = default; - pong_callback(pong_callback const&) = default; + ping_callback() = default; + ping_callback(ping_callback&&) = default; + ping_callback(ping_callback const&) = default; explicit - pong_callback(detail::pong_cb f) + ping_callback(detail::ping_cb f) : value(std::move(f)) { } diff --git a/include/beast/websocket/rfc6455.hpp b/include/beast/websocket/rfc6455.hpp index 22e43b2c5..de72e9c25 100644 --- a/include/beast/websocket/rfc6455.hpp +++ b/include/beast/websocket/rfc6455.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/ssl.hpp b/include/beast/websocket/ssl.hpp index ef94ed9a7..394929595 100644 --- a/include/beast/websocket/ssl.hpp +++ b/include/beast/websocket/ssl.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/websocket/stream.hpp b/include/beast/websocket/stream.hpp index 8c1c3cde5..24fb12919 100644 --- a/include/beast/websocket/stream.hpp +++ b/include/beast/websocket/stream.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -225,11 +225,11 @@ public: o = pmd_opts_; } - /// Set the pong callback + /// Set the ping callback void - set_option(pong_callback o) + set_option(ping_callback o) { - pong_cb_ = std::move(o.value); + ping_cb_ = std::move(o.value); } /// Set the read buffer size @@ -1118,13 +1118,17 @@ public: the message type, and the input area of the stream buffer will hold all the message payload bytes (which may be zero in length). - Control frames encountered while reading frame or message data - are handled automatically. Pings are replied to automatically, - pongs are routed to the pong callback if the option is set, - and close frames initiate the WebSocket close procedure. When a - close frame is received, this call will eventually return - @ref error::closed. Because of the need to handle control frames, - read operations can cause writes to take place. + During reads, the implementation handles control frames as + follows: + + @li A pong frame is sent when a ping frame is received. + + @li The @ref ping_callback is invoked when a ping frame + or pong frame is received. + + @li The WebSocket close procedure is started if a close frame + is received. In this case, the operation will eventually + complete with the error set to @ref error::closed. @param op A value to receive the message type. This object must remain valid until the handler is called. @@ -1154,13 +1158,17 @@ public: the message type, and the input area of the stream buffer will hold all the message payload bytes (which may be zero in length). - Control frames encountered while reading frame or message data - are handled automatically. Pings are replied to automatically, - pongs are routed to the pong callback if the option is set, - and close frames initiate the WebSocket close procedure. When a - close frame is received, this call will eventually return - @ref error::closed. Because of the need to handle control frames, - read operations can cause writes to take place. + During reads, the implementation handles control frames as + follows: + + @li The @ref ping_callback is invoked when a ping frame + or pong frame is received. + + @li A pong frame is sent when a ping frame is received. + + @li The WebSocket close procedure is started if a close frame + is received. In this case, the operation will eventually + complete with the error set to @ref error::closed. @param op A value to receive the message type. This object must remain valid until the handler is called. @@ -1195,15 +1203,23 @@ public: the message type, and the input area of the stream buffer will hold all the message payload bytes (which may be zero in length). - Control frames encountered while reading frame or message data - are handled automatically. Pings are replied to automatically, - pongs are routed to the pong callback if the option is set, - and close frames initiate the WebSocket close procedure. When a - close frame is received, this call will eventually return - @ref error::closed. Because of the need to handle control - frames, these read operations can cause writes to take place. - Despite this, calls to `async_read` and `async_read_frame` - only count as read operations. + During reads, the implementation handles control frames as + follows: + + @li The @ref ping_callback is invoked when a ping frame + or pong frame is received. + + @li A pong frame is sent when a ping frame is received. + + @li The WebSocket close procedure is started if a close frame + is received. In this case, the operation will eventually + complete with the error set to @ref error::closed. + + Because of the need to handle control frames, read operations + can cause writes to take place. These writes are managed + transparently; callers can still have one active asynchronous + read and asynchronous write operation pending simultaneously + (a user initiated call to @ref async_close counts as a write). @param op A value to receive the message type. This object must remain valid until the handler is called. @@ -1247,20 +1263,24 @@ public: This call is implemented in terms of one or more calls to the stream's `read_some` and `write_some` operations. - Upon success, fi is filled out to reflect the message payload - contents. op is set to binary or text, and the fin flag + Upon success, `fi` is filled out to reflect the message payload + contents. `op` is set to binary or text, and the `fin` flag indicates if all the message data has been read in. To read the - entire message, callers should repeat the read_frame operation - until fi.fin is true. A message with no payload will have - fi.fin == true, and zero bytes placed into the stream buffer. + entire message, callers should keep calling @ref read_frame + until `fi.fin == true`. A message with no payload will have + `fi.fin == true`, and zero bytes placed into the stream buffer. - Control frames encountered while reading frame or message data - are handled automatically. Pings are replied to automatically, - pongs are routed to the pong callback if the option is set, - and close frames initiate the WebSocket close procedure. When a - close frame is received, this call will eventually return - @ref error::closed. Because of the need to handle control frames, - read operations can cause writes to take place. + During reads, the implementation handles control frames as + follows: + + @li The @ref ping_callback is invoked when a ping frame + or pong frame is received. + + @li A pong frame is sent when a ping frame is received. + + @li The WebSocket close procedure is started if a close frame + is received. In this case, the operation will eventually + complete with the error set to @ref error::closed. @param fi An object to store metadata about the message. @@ -1286,20 +1306,24 @@ public: This call is implemented in terms of one or more calls to the stream's `read_some` and `write_some` operations. - Upon success, fi is filled out to reflect the message payload - contents. op is set to binary or text, and the fin flag + Upon success, `fi` is filled out to reflect the message payload + contents. `op` is set to binary or text, and the `fin` flag indicates if all the message data has been read in. To read the - entire message, callers should repeat the read_frame operation - until fi.fin is true. A message with no payload will have - fi.fin == true, and zero bytes placed into the stream buffer. + entire message, callers should keep calling @ref read_frame + until `fi.fin == true`. A message with no payload will have + `fi.fin == true`, and zero bytes placed into the stream buffer. - Control frames encountered while reading frame or message data - are handled automatically. Pings are replied to automatically, - pongs are routed to the pong callback if the option is set, - and close frames initiate the WebSocket close procedure. When a - close frame is received, this call will eventually return - @ref error::closed. Because of the need to handle control frames, - read operations can cause writes to take place. + During reads, the implementation handles control frames as + follows: + + @li The @ref ping_callback is invoked when a ping frame + or pong frame is received. + + @li A pong frame is sent when a ping frame is received. + + @li The WebSocket close procedure is started if a close frame + is received. In this case, the operation will eventually + complete with the error set to @ref error::closed. @param fi An object to store metadata about the message. @@ -1329,25 +1353,31 @@ public: ensure that the stream performs no other reads until this operation completes. - Upon a successful completion, fi is filled out to reflect the - message payload contents. op is set to binary or text, and the - fin flag indicates if all the message data has been read in. - To read the entire message, callers should repeat the - read_frame operation until fi.fin is true. A message with no - payload will have fi.fin == true, and zero bytes placed into - the stream buffer. + Upon a successful completion, `fi` is filled out to reflect the + message payload contents. `op` is set to binary or text, and the + `fin` flag indicates if all the message data has been read in. + To read the entire message, callers should keep calling + @ref read_frame until `fi.fin == true`. A message with no payload + will have `fi.fin == true`, and zero bytes placed into the stream + buffer. - Control frames encountered while reading frame or message data - are handled automatically. Pings are replied to automatically, - pongs are routed to the pong callback if the option is set, - and close frames initiate the WebSocket close procedure. When a - close frame is received, this call will eventually return - @ref error::closed. Because of the need to handle control frames, - read operations can cause writes to take place. These writes are - managed transparently; callers can still have one active - asynchronous read and asynchronous write operation pending - simultaneously (a user initiated call to @ref async_close - counts as a write). + During reads, the implementation handles control frames as + follows: + + @li The @ref ping_callback is invoked when a ping frame + or pong frame is received. + + @li A pong frame is sent when a ping frame is received. + + @li The WebSocket close procedure is started if a close frame + is received. In this case, the operation will eventually + complete with the error set to @ref error::closed. + + Because of the need to handle control frames, read operations + can cause writes to take place. These writes are managed + transparently; callers can still have one active asynchronous + read and asynchronous write operation pending simultaneously + (a user initiated call to @ref async_close counts as a write). @param fi An object to store metadata about the message. This object must remain valid until the handler is called. diff --git a/include/beast/websocket/teardown.hpp b/include/beast/websocket/teardown.hpp index 3682a18f8..6666d8f5b 100644 --- a/include/beast/websocket/teardown.hpp +++ b/include/beast/websocket/teardown.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,7 +16,7 @@ namespace beast { namespace websocket { /** Tag type used to find @ref beast::websocket::teardown and @ref beast::websocket::async_teardown overloads - + Overloads of @ref beast::websocket::teardown and @ref beast::websocket::async_teardown for user defined types must take a value of type @ref teardown_tag in the first diff --git a/include/beast/zlib.hpp b/include/beast/zlib.hpp index c2173d127..80e3cf07b 100644 --- a/include/beast/zlib.hpp +++ b/include/beast/zlib.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/zlib/deflate_stream.hpp b/include/beast/zlib/deflate_stream.hpp index 06256d2eb..31fd57351 100644 --- a/include/beast/zlib/deflate_stream.hpp +++ b/include/beast/zlib/deflate_stream.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -128,7 +128,7 @@ public: { doClear(); } - + /** Returns the upper limit on the size of a compressed block. This function makes a conservative estimate of the maximum number @@ -171,7 +171,7 @@ public: the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. - + In each call, one or both of these actions are performed: @li Compress more input starting at `zs.next_in` and update @@ -371,12 +371,12 @@ deflate_upper_bound(std::size_t bytes); They are coded as constants here for a reason--if the #define's are changed, then this function needs to be changed as well. The return value for 15 and 8 only works for those exact settings. - + For any setting other than those defaults for windowBits and memLevel, the value returned is a conservative worst case for the maximum expansion resulting from using fixed blocks instead of stored blocks, which deflate can emit on compressed data for some combinations of the parameters. - + This function could be more sophisticated to provide closer upper bounds for every combination of windowBits and memLevel. But even the conservative upper bound of about 14% expansion does not seem onerous for output buffer diff --git a/include/beast/zlib/detail/bitstream.hpp b/include/beast/zlib/detail/bitstream.hpp index 9c470cf89..c7ae1a945 100644 --- a/include/beast/zlib/detail/bitstream.hpp +++ b/include/beast/zlib/detail/bitstream.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -144,7 +144,7 @@ fill_8(FwdIt& it) { v_ += static_cast(*it++) << n_; n_ += 8; -} +} template inline @@ -156,7 +156,7 @@ fill_16(FwdIt& it) n_ += 8; v_ += static_cast(*it++) << n_; n_ += 8; -} +} template inline @@ -193,7 +193,7 @@ rewind(BidirIt& it) auto len = n_ >> 3; it = std::prev(it, len); n_ &= 7; - v_ &= (1U << n_) - 1; + v_ &= (1U << n_) - 1; } } // detail diff --git a/include/beast/zlib/detail/deflate_stream.hpp b/include/beast/zlib/detail/deflate_stream.hpp index c7cceb3ea..50358076c 100644 --- a/include/beast/zlib/detail/deflate_stream.hpp +++ b/include/beast/zlib/detail/deflate_stream.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -112,7 +112,7 @@ protected: // Number of literal bytes 0..255 static std::uint16_t constexpr literals = 256; - + // Number of Literal or Length codes, including the END_BLOCK code static std::uint16_t constexpr lCodes = literals + 1 + lengthCodes; @@ -184,7 +184,7 @@ protected: // Describes a single value and its code string. struct ct_data { - std::uint16_t fc; // frequency count or bit string + std::uint16_t fc; // frequency count or bit string std::uint16_t dl; // parent node in tree or length of bit string bool @@ -648,7 +648,7 @@ protected: static unsigned bi_reverse(unsigned code, int len); - + template static void diff --git a/include/beast/zlib/detail/inflate_stream.hpp b/include/beast/zlib/detail/inflate_stream.hpp index 5b748fbe3..fb2d4ce07 100644 --- a/include/beast/zlib/detail/inflate_stream.hpp +++ b/include/beast/zlib/detail/inflate_stream.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -762,7 +762,7 @@ inflate_table( std::uint16_t offs[15+1]; // offsets in table for each length // Length codes 257..285 base - static std::uint16_t constexpr lbase[31] = { + static std::uint16_t constexpr lbase[31] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; diff --git a/include/beast/zlib/detail/ranges.hpp b/include/beast/zlib/detail/ranges.hpp index 045a4dc6d..094bd4563 100644 --- a/include/beast/zlib/detail/ranges.hpp +++ b/include/beast/zlib/detail/ranges.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/zlib/detail/window.hpp b/include/beast/zlib/detail/window.hpp index 8fe1e6efc..2a277710b 100644 --- a/include/beast/zlib/detail/window.hpp +++ b/include/beast/zlib/detail/window.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/zlib/error.hpp b/include/beast/zlib/error.hpp index 05864a517..489d09220 100644 --- a/include/beast/zlib/error.hpp +++ b/include/beast/zlib/error.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/zlib/impl/error.ipp b/include/beast/zlib/impl/error.ipp index 736c8b209..f5cf12082 100644 --- a/include/beast/zlib/impl/error.ipp +++ b/include/beast/zlib/impl/error.ipp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/zlib/inflate_stream.hpp b/include/beast/zlib/inflate_stream.hpp index 8c9b2166f..6f2b49e90 100644 --- a/include/beast/zlib/inflate_stream.hpp +++ b/include/beast/zlib/inflate_stream.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/include/beast/zlib/zlib.hpp b/include/beast/zlib/zlib.hpp index ac5520c7f..e038998f3 100644 --- a/include/beast/zlib/zlib.hpp +++ b/include/beast/zlib/zlib.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -149,7 +149,7 @@ enum class Strategy filtered, /** Huffman-only strategy. - + This strategy only performs Huffman encoding, without doing any string matching. */ diff --git a/test/Jamfile b/test/Jamfile index 5ffb5d59a..6f275a396 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -1,5 +1,5 @@ # -# Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,7 +16,6 @@ compile zlib.cpp : : ; unit-test core-tests : ../extras/beast/unit_test/main.cpp core/async_completion.cpp - core/basic_streambuf.cpp core/bind_handler.cpp core/buffer_cat.cpp core/buffer_concepts.cpp @@ -29,6 +28,7 @@ unit-test core-tests : core/handler_concepts.cpp core/handler_ptr.cpp core/placeholders.cpp + core/prepare_buffer.cpp core/prepare_buffers.cpp core/static_streambuf.cpp core/static_string.cpp @@ -39,6 +39,7 @@ unit-test core-tests : core/base64.cpp core/empty_base_optimization.cpp core/get_lowest_layer.cpp + core/is_call_possible.cpp core/sha1.cpp ; diff --git a/test/core.cpp b/test/core.cpp index d342588e2..ea704e038 100644 --- a/test/core.cpp +++ b/test/core.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt index 1ef6f5a7e..2d575cd8a 100644 --- a/test/core/CMakeLists.txt +++ b/test/core/CMakeLists.txt @@ -10,7 +10,6 @@ add_executable (core-tests ../../extras/beast/unit_test/main.cpp buffer_test.hpp async_completion.cpp - basic_streambuf.cpp bind_handler.cpp buffer_cat.cpp buffer_concepts.cpp @@ -23,6 +22,7 @@ add_executable (core-tests handler_concepts.cpp handler_ptr.cpp placeholders.cpp + prepare_buffer.cpp prepare_buffers.cpp static_streambuf.cpp static_string.cpp @@ -33,6 +33,7 @@ add_executable (core-tests base64.cpp empty_base_optimization.cpp get_lowest_layer.cpp + is_call_possible.cpp sha1.cpp ) diff --git a/test/core/async_completion.cpp b/test/core/async_completion.cpp index 4b9fbed6d..15e0d7dbc 100644 --- a/test/core/async_completion.cpp +++ b/test/core/async_completion.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/base64.cpp b/test/core/base64.cpp index c667b3b1a..606f8b13e 100644 --- a/test/core/base64.cpp +++ b/test/core/base64.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/basic_streambuf.cpp b/test/core/basic_streambuf.cpp deleted file mode 100644 index 00b468dd7..000000000 --- a/test/core/basic_streambuf.cpp +++ /dev/null @@ -1,480 +0,0 @@ -// -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -// Test that header file is self-contained. -#include - -#include "buffer_test.hpp" -#include -#include -#include -#include -#include -#include -#include -#include - -namespace beast { - -struct test_allocator_info -{ - std::size_t ncopy = 0; - std::size_t nmove = 0; - std::size_t nselect = 0; -}; - -template -class test_allocator; - -template -struct test_allocator_base -{ -}; - -template -struct test_allocator_base -{ - static - test_allocator - select_on_container_copy_construction( - test_allocator const& a) - { - return test_allocator{}; - } -}; - -template -class test_allocator : public test_allocator_base< - T, Assign, Move, Swap, Select> -{ - std::size_t id_; - std::shared_ptr info_; - - template - friend class test_allocator; - -public: - using value_type = T; - using propagate_on_container_copy_assignment = - std::integral_constant; - using propagate_on_container_move_assignment = - std::integral_constant; - using propagate_on_container_swap = - std::integral_constant; - - template - struct rebind - { - using other = test_allocator< - U, Assign, Move, Swap, Select>; - }; - - test_allocator() - : id_([] - { - static std::atomic< - std::size_t> sid(0); - return ++sid; - }()) - , info_(std::make_shared()) - { - } - - test_allocator(test_allocator const& u) noexcept - : id_(u.id_) - , info_(u.info_) - { - ++info_->ncopy; - } - - template - test_allocator(test_allocator< - U, Assign, Move, Swap, Select> const& u) noexcept - : id_(u.id_) - , info_(u.info_) - { - ++info_->ncopy; - } - - test_allocator(test_allocator&& t) - : id_(t.id_) - , info_(t.info_) - { - ++info_->nmove; - } - - value_type* - allocate(std::size_t n) - { - return static_cast( - ::operator new (n*sizeof(value_type))); - } - - void - deallocate(value_type* p, std::size_t) noexcept - { - ::operator delete(p); - } - - std::size_t - id() const - { - return id_; - } - - test_allocator_info const* - operator->() const - { - return info_.get(); - } -}; - -class basic_streambuf_test : public beast::unit_test::suite -{ -public: - template - static - bool - eq(basic_streambuf const& sb1, - basic_streambuf const& sb2) - { - return to_string(sb1.data()) == to_string(sb2.data()); - } - - template - void - expect_size(std::size_t n, ConstBufferSequence const& buffers) - { - BEAST_EXPECT(test::size_pre(buffers) == n); - BEAST_EXPECT(test::size_post(buffers) == n); - BEAST_EXPECT(test::size_rev_pre(buffers) == n); - BEAST_EXPECT(test::size_rev_post(buffers) == n); - } - - template - static - void - self_assign(U& u, V&& v) - { - u = std::forward(v); - } - - void testSpecialMembers() - { - using boost::asio::buffer; - using boost::asio::buffer_cast; - using boost::asio::buffer_size; - std::string const s = "Hello, world"; - BEAST_EXPECT(s.size() == 12); - for(std::size_t i = 1; i < 12; ++i) { - for(std::size_t x = 1; x < 4; ++x) { - for(std::size_t y = 1; y < 4; ++y) { - std::size_t z = s.size() - (x + y); - { - streambuf sb(i); - sb.commit(buffer_copy(sb.prepare(x), buffer(s.data(), x))); - sb.commit(buffer_copy(sb.prepare(y), buffer(s.data()+x, y))); - sb.commit(buffer_copy(sb.prepare(z), buffer(s.data()+x+y, z))); - BEAST_EXPECT(to_string(sb.data()) == s); - { - streambuf sb2(sb); - BEAST_EXPECT(eq(sb, sb2)); - } - { - streambuf sb2; - sb2 = sb; - BEAST_EXPECT(eq(sb, sb2)); - } - { - streambuf sb2(std::move(sb)); - BEAST_EXPECT(to_string(sb2.data()) == s); - expect_size(0, sb.data()); - sb = std::move(sb2); - BEAST_EXPECT(to_string(sb.data()) == s); - expect_size(0, sb2.data()); - } - self_assign(sb, sb); - BEAST_EXPECT(to_string(sb.data()) == s); - self_assign(sb, std::move(sb)); - BEAST_EXPECT(to_string(sb.data()) == s); - } - }}} - try - { - streambuf sb0(0); - fail(); - } - catch(std::exception const&) - { - pass(); - } - } - - void testAllocator() - { - // VFALCO This needs work - { - using alloc_type = - test_allocator; - using sb_type = basic_streambuf; - sb_type sb; - BEAST_EXPECT(sb.get_allocator().id() == 1); - } - { - using alloc_type = - test_allocator; - using sb_type = basic_streambuf; - sb_type sb; - BEAST_EXPECT(sb.get_allocator().id() == 2); - sb_type sb2(sb); - BEAST_EXPECT(sb2.get_allocator().id() == 2); - sb_type sb3(sb, alloc_type{}); - } - } - - void - testPrepare() - { - using boost::asio::buffer_size; - { - streambuf sb(2); - BEAST_EXPECT(buffer_size(sb.prepare(5)) == 5); - BEAST_EXPECT(buffer_size(sb.prepare(8)) == 8); - BEAST_EXPECT(buffer_size(sb.prepare(7)) == 7); - } - { - streambuf sb(2); - sb.prepare(2); - BEAST_EXPECT(test::buffer_count(sb.prepare(5)) == 2); - BEAST_EXPECT(test::buffer_count(sb.prepare(8)) == 3); - BEAST_EXPECT(test::buffer_count(sb.prepare(4)) == 2); - } - } - - void testCommit() - { - using boost::asio::buffer_size; - streambuf sb(2); - sb.prepare(2); - sb.prepare(5); - sb.commit(1); - expect_size(1, sb.data()); - } - - void testConsume() - { - using boost::asio::buffer_size; - streambuf sb(1); - expect_size(5, sb.prepare(5)); - sb.commit(3); - expect_size(3, sb.data()); - sb.consume(1); - expect_size(2, sb.data()); - } - - void testMatrix() - { - using boost::asio::buffer; - using boost::asio::buffer_cast; - using boost::asio::buffer_size; - std::string const s = "Hello, world"; - BEAST_EXPECT(s.size() == 12); - for(std::size_t i = 1; i < 12; ++i) { - for(std::size_t x = 1; x < 4; ++x) { - for(std::size_t y = 1; y < 4; ++y) { - for(std::size_t t = 1; t < 4; ++ t) { - for(std::size_t u = 1; u < 4; ++ u) { - std::size_t z = s.size() - (x + y); - std::size_t v = s.size() - (t + u); - { - streambuf sb(i); - { - auto d = sb.prepare(z); - BEAST_EXPECT(buffer_size(d) == z); - } - { - auto d = sb.prepare(0); - BEAST_EXPECT(buffer_size(d) == 0); - } - { - auto d = sb.prepare(y); - BEAST_EXPECT(buffer_size(d) == y); - } - { - auto d = sb.prepare(x); - BEAST_EXPECT(buffer_size(d) == x); - sb.commit(buffer_copy(d, buffer(s.data(), x))); - } - BEAST_EXPECT(sb.size() == x); - BEAST_EXPECT(buffer_size(sb.data()) == sb.size()); - { - auto d = sb.prepare(x); - BEAST_EXPECT(buffer_size(d) == x); - } - { - auto d = sb.prepare(0); - BEAST_EXPECT(buffer_size(d) == 0); - } - { - auto d = sb.prepare(z); - BEAST_EXPECT(buffer_size(d) == z); - } - { - auto d = sb.prepare(y); - BEAST_EXPECT(buffer_size(d) == y); - sb.commit(buffer_copy(d, buffer(s.data()+x, y))); - } - sb.commit(1); - BEAST_EXPECT(sb.size() == x + y); - BEAST_EXPECT(buffer_size(sb.data()) == sb.size()); - { - auto d = sb.prepare(x); - BEAST_EXPECT(buffer_size(d) == x); - } - { - auto d = sb.prepare(y); - BEAST_EXPECT(buffer_size(d) == y); - } - { - auto d = sb.prepare(0); - BEAST_EXPECT(buffer_size(d) == 0); - } - { - auto d = sb.prepare(z); - BEAST_EXPECT(buffer_size(d) == z); - sb.commit(buffer_copy(d, buffer(s.data()+x+y, z))); - } - sb.commit(2); - BEAST_EXPECT(sb.size() == x + y + z); - BEAST_EXPECT(buffer_size(sb.data()) == sb.size()); - BEAST_EXPECT(to_string(sb.data()) == s); - sb.consume(t); - { - auto d = sb.prepare(0); - BEAST_EXPECT(buffer_size(d) == 0); - } - BEAST_EXPECT(to_string(sb.data()) == s.substr(t, std::string::npos)); - sb.consume(u); - BEAST_EXPECT(to_string(sb.data()) == s.substr(t + u, std::string::npos)); - sb.consume(v); - BEAST_EXPECT(to_string(sb.data()) == ""); - sb.consume(1); - { - auto d = sb.prepare(0); - BEAST_EXPECT(buffer_size(d) == 0); - } - } - }}}}} - } - - void testIterators() - { - using boost::asio::buffer_size; - streambuf sb(1); - sb.prepare(1); - sb.commit(1); - sb.prepare(2); - sb.commit(2); - expect_size(3, sb.data()); - sb.prepare(1); - expect_size(3, sb.prepare(3)); - sb.commit(2); - BEAST_EXPECT(test::buffer_count(sb.data()) == 4); - } - - void testOutputStream() - { - streambuf sb; - sb << "x"; - BEAST_EXPECT(to_string(sb.data()) == "x"); - } - - void testCapacity() - { - using boost::asio::buffer_size; - { - streambuf sb{10}; - BEAST_EXPECT(sb.alloc_size() == 10); - BEAST_EXPECT(read_size_helper(sb, 1) == 1); - BEAST_EXPECT(read_size_helper(sb, 10) == 10); - BEAST_EXPECT(read_size_helper(sb, 20) == 20); - BEAST_EXPECT(read_size_helper(sb, 1000) == 512); - sb.prepare(3); - sb.commit(3); - BEAST_EXPECT(read_size_helper(sb, 10) == 7); - BEAST_EXPECT(read_size_helper(sb, 1000) == 7); - } - { - streambuf sb(1000); - BEAST_EXPECT(sb.alloc_size() == 1000); - BEAST_EXPECT(read_size_helper(sb, 1) == 1); - BEAST_EXPECT(read_size_helper(sb, 1000) == 1000); - BEAST_EXPECT(read_size_helper(sb, 2000) == 1000); - sb.prepare(3); - BEAST_EXPECT(read_size_helper(sb, 1) == 1); - BEAST_EXPECT(read_size_helper(sb, 1000) == 1000); - BEAST_EXPECT(read_size_helper(sb, 2000) == 1000); - sb.commit(3); - BEAST_EXPECT(read_size_helper(sb, 1) == 1); - BEAST_EXPECT(read_size_helper(sb, 1000) == 997); - BEAST_EXPECT(read_size_helper(sb, 2000) == 997); - sb.consume(2); - BEAST_EXPECT(read_size_helper(sb, 1) == 1); - BEAST_EXPECT(read_size_helper(sb, 1000) == 997); - BEAST_EXPECT(read_size_helper(sb, 2000) == 997); - } - { - streambuf sb{2}; - BEAST_EXPECT(sb.alloc_size() == 2); - BEAST_EXPECT(test::buffer_count(sb.prepare(2)) == 1); - BEAST_EXPECT(test::buffer_count(sb.prepare(3)) == 2); - BEAST_EXPECT(buffer_size(sb.prepare(5)) == 5); - BEAST_EXPECT(read_size_helper(sb, 10) == 6); - } - { - auto avail = - [](streambuf const& sb) - { - return sb.capacity() - sb.size(); - }; - streambuf sb{100}; - BEAST_EXPECT(sb.alloc_size() == 100); - BEAST_EXPECT(avail(sb) == 0); - sb.prepare(100); - BEAST_EXPECT(avail(sb) == 100); - sb.commit(100); - BEAST_EXPECT(avail(sb) == 0); - sb.consume(100); - BEAST_EXPECT(avail(sb) == 0); - sb.alloc_size(200); - BEAST_EXPECT(sb.alloc_size() == 200); - sb.prepare(1); - BEAST_EXPECT(avail(sb) == 200); - } - } - - void run() override - { - testSpecialMembers(); - testAllocator(); - testPrepare(); - testCommit(); - testConsume(); - testMatrix(); - testIterators(); - testOutputStream(); - testCapacity(); - } -}; - -BEAST_DEFINE_TESTSUITE(basic_streambuf,core,beast); - -} // beast diff --git a/test/core/bind_handler.cpp b/test/core/bind_handler.cpp index 84c009734..9299cb9e9 100644 --- a/test/core/bind_handler.cpp +++ b/test/core/bind_handler.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -16,15 +16,17 @@ namespace beast { class bind_handler_test : public unit_test::suite { public: - static void foo (int) + void + callback(int v) { + BEAST_EXPECT(v == 42); } void run() { - auto f (bind_handler ( - std::bind (&foo, std::placeholders::_1), - 42)); + auto f = bind_handler(std::bind( + &bind_handler_test::callback, this, + std::placeholders::_1), 42); f(); pass(); } diff --git a/test/core/buffer_cat.cpp b/test/core/buffer_cat.cpp index 413386222..688b315c8 100644 --- a/test/core/buffer_cat.cpp +++ b/test/core/buffer_cat.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -240,7 +240,7 @@ public: ! detail::is_all_ConstBufferSequence< const_buffers_1, mutable_buffers_1, int >::value, ""); - + // Ensure that concatenating mutable buffer // sequences results in a mutable buffer sequence static_assert(std::is_same< diff --git a/test/core/buffer_concepts.cpp b/test/core/buffer_concepts.cpp index 2a827fa1e..6a3476f67 100644 --- a/test/core/buffer_concepts.cpp +++ b/test/core/buffer_concepts.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/buffer_test.hpp b/test/core/buffer_test.hpp index 5f1add9c7..d6160cdcd 100644 --- a/test/core/buffer_test.hpp +++ b/test/core/buffer_test.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/buffers_adapter.cpp b/test/core/buffers_adapter.cpp index 551478ed5..9f8054c6f 100644 --- a/test/core/buffers_adapter.cpp +++ b/test/core/buffers_adapter.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/clamp.cpp b/test/core/clamp.cpp index e63f526b8..24fd20a6d 100644 --- a/test/core/clamp.cpp +++ b/test/core/clamp.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/consuming_buffers.cpp b/test/core/consuming_buffers.cpp index 71630b0a2..d4a1dc475 100644 --- a/test/core/consuming_buffers.cpp +++ b/test/core/consuming_buffers.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/dynabuf_readstream.cpp b/test/core/dynabuf_readstream.cpp index 59e404983..1293e5236 100644 --- a/test/core/dynabuf_readstream.cpp +++ b/test/core/dynabuf_readstream.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include @@ -54,7 +54,7 @@ public: for(n = 0; n < limit; ++n) { test::fail_stream< - test::string_stream> fs(n, ios_, ", world!"); + test::string_istream> fs(n, ios_, ", world!"); dynabuf_readstream< decltype(fs)&, streambuf> srs(fs); srs.buffer().commit(buffer_copy( @@ -72,7 +72,7 @@ public: for(n = 0; n < limit; ++n) { test::fail_stream< - test::string_stream> fs(n, ios_, ", world!"); + test::string_istream> fs(n, ios_, ", world!"); dynabuf_readstream< decltype(fs)&, streambuf> srs(fs); srs.capacity(3); @@ -91,7 +91,7 @@ public: for(n = 0; n < limit; ++n) { test::fail_stream< - test::string_stream> fs(n, ios_, ", world!"); + test::string_istream> fs(n, ios_, ", world!"); dynabuf_readstream< decltype(fs)&, streambuf> srs(fs); srs.buffer().commit(buffer_copy( @@ -110,7 +110,7 @@ public: for(n = 0; n < limit; ++n) { test::fail_stream< - test::string_stream> fs(n, ios_, ", world!"); + test::string_istream> fs(n, ios_, ", world!"); dynabuf_readstream< decltype(fs)&, streambuf> srs(fs); srs.capacity(3); diff --git a/test/core/empty_base_optimization.cpp b/test/core/empty_base_optimization.cpp index 8049266ae..e62700854 100644 --- a/test/core/empty_base_optimization.cpp +++ b/test/core/empty_base_optimization.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/error.cpp b/test/core/error.cpp index 17afdedc2..266f59907 100644 --- a/test/core/error.cpp +++ b/test/core/error.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/get_lowest_layer.cpp b/test/core/get_lowest_layer.cpp index 1ffc28173..11538a83e 100644 --- a/test/core/get_lowest_layer.cpp +++ b/test/core/get_lowest_layer.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/handler_alloc.cpp b/test/core/handler_alloc.cpp index 620a409b3..c657d5fb3 100644 --- a/test/core/handler_alloc.cpp +++ b/test/core/handler_alloc.cpp @@ -1,28 +1,49 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Test that header file is self-contained. -#include +#include #include -#include +#include namespace beast { -class to_string_test : public beast::unit_test::suite +class handler_alloc_test : public beast::unit_test::suite { public: - void run() + struct handler { - BEAST_EXPECT(to_string(boost::asio::const_buffers_1("x", 1)) == "x"); + void + operator()() const + { + } + }; + + void + run() override + { + handler h; + handler h2; + handler_alloc a1{h}; + handler_alloc a2{h2}; + BEAST_EXPECT(a2 == a1); + auto a3 = a1; + BEAST_EXPECT(a3 == a1); + { + std::vector> v(a1); + v.reserve(32); + v.resize(10); + } } }; -BEAST_DEFINE_TESTSUITE(to_string,core,beast); +BEAST_DEFINE_TESTSUITE(handler_alloc,core,beast); } // beast diff --git a/test/core/handler_concepts.cpp b/test/core/handler_concepts.cpp index 1e44de488..ba3c3a555 100644 --- a/test/core/handler_concepts.cpp +++ b/test/core/handler_concepts.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/handler_ptr.cpp b/test/core/handler_ptr.cpp index 8cd2a8d62..f40bc158a 100644 --- a/test/core/handler_ptr.cpp +++ b/test/core/handler_ptr.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -7,3 +7,74 @@ // Test that header file is self-contained. #include + +#include +#include +#include + +namespace beast { + +class handler_ptr_test : public beast::unit_test::suite +{ +public: + struct handler + { + handler() = default; + handler(handler const&) = default; + + void + operator()(bool& b) const + { + b = true; + } + }; + + struct T + { + T(handler&) + { + } + + ~T() + { + } + }; + + struct U + { + U(handler&) + { + throw std::exception{}; + } + }; + + void + run() override + { + handler h; + handler_ptr p1{h}; + handler_ptr p2{p1}; + try + { + handler_ptr p3{h}; + fail(); + } + catch(std::exception const&) + { + pass(); + } + catch(...) + { + fail(); + } + handler_ptr p4{std::move(h)}; + bool b = false; + p4.invoke(std::ref(b)); + BEAST_EXPECT(b); + } +}; + +BEAST_DEFINE_TESTSUITE(handler_ptr,core,beast); + +} // beast + diff --git a/test/core/is_call_possible.cpp b/test/core/is_call_possible.cpp new file mode 100644 index 000000000..5849793dd --- /dev/null +++ b/test/core/is_call_possible.cpp @@ -0,0 +1,56 @@ +// +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +// Test that header file is self-contained. +#include + +namespace beast { +namespace detail { +namespace { + +struct is_call_possible_udt1 +{ + void operator()(int) const; +}; + +struct is_call_possible_udt2 +{ + int operator()(int) const; +}; + +struct is_call_possible_udt3 +{ + int operator()(int); +}; + +#ifndef __INTELLISENSE__ +// VFALCO Fails to compile with Intellisense +static_assert(is_call_possible< + is_call_possible_udt1, void(int)>::value, ""); + +static_assert(! is_call_possible< + is_call_possible_udt1, void(void)>::value, ""); + +static_assert(is_call_possible< + is_call_possible_udt2, int(int)>::value, ""); + +static_assert(! is_call_possible< + is_call_possible_udt2, int(void)>::value, ""); + +static_assert(! is_call_possible< + is_call_possible_udt2, void(void)>::value, ""); + +static_assert(is_call_possible< + is_call_possible_udt3, int(int)>::value, ""); + +static_assert(! is_call_possible< + is_call_possible_udt3 const, int(int)>::value, ""); +#endif + +} +} // detail +} // beast diff --git a/test/core/placeholders.cpp b/test/core/placeholders.cpp index 6fa365640..1f4955d5b 100644 --- a/test/core/placeholders.cpp +++ b/test/core/placeholders.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/prepare_buffer.cpp b/test/core/prepare_buffer.cpp new file mode 100644 index 000000000..989ce0c4d --- /dev/null +++ b/test/core/prepare_buffer.cpp @@ -0,0 +1,9 @@ +// +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +// Test that header file is self-contained. +#include diff --git a/test/core/prepare_buffers.cpp b/test/core/prepare_buffers.cpp index 44debdfa6..b9d481e3d 100644 --- a/test/core/prepare_buffers.cpp +++ b/test/core/prepare_buffers.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/sha1.cpp b/test/core/sha1.cpp index 7c4443c31..d85b2e2cb 100644 --- a/test/core/sha1.cpp +++ b/test/core/sha1.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/static_streambuf.cpp b/test/core/static_streambuf.cpp index eba5a6584..0add8c4dc 100644 --- a/test/core/static_streambuf.cpp +++ b/test/core/static_streambuf.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/static_string.cpp b/test/core/static_string.cpp index 0511cc3e8..cfac29bf8 100644 --- a/test/core/static_string.cpp +++ b/test/core/static_string.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/stream_concepts.cpp b/test/core/stream_concepts.cpp index afc91ed08..f9d590409 100644 --- a/test/core/stream_concepts.cpp +++ b/test/core/stream_concepts.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/streambuf.cpp b/test/core/streambuf.cpp index 3f46658d3..eb295161f 100644 --- a/test/core/streambuf.cpp +++ b/test/core/streambuf.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -8,9 +8,475 @@ // Test that header file is self-contained. #include +#include "buffer_test.hpp" #include +#include +#include +#include +#include +#include +#include +#include + namespace beast { static_assert(is_DynamicBuffer::value, ""); +struct test_allocator_info +{ + std::size_t ncopy = 0; + std::size_t nmove = 0; + std::size_t nselect = 0; +}; + +template +class test_allocator; + +template +struct test_allocator_base +{ +}; + +template +struct test_allocator_base +{ + static + test_allocator + select_on_container_copy_construction( + test_allocator const& a) + { + return test_allocator{}; + } +}; + +template +class test_allocator : public test_allocator_base< + T, Assign, Move, Swap, Select> +{ + std::size_t id_; + std::shared_ptr info_; + + template + friend class test_allocator; + +public: + using value_type = T; + using propagate_on_container_copy_assignment = + std::integral_constant; + using propagate_on_container_move_assignment = + std::integral_constant; + using propagate_on_container_swap = + std::integral_constant; + + template + struct rebind + { + using other = test_allocator< + U, Assign, Move, Swap, Select>; + }; + + test_allocator() + : id_([] + { + static std::atomic< + std::size_t> sid(0); + return ++sid; + }()) + , info_(std::make_shared()) + { + } + + test_allocator(test_allocator const& u) noexcept + : id_(u.id_) + , info_(u.info_) + { + ++info_->ncopy; + } + + template + test_allocator(test_allocator< + U, Assign, Move, Swap, Select> const& u) noexcept + : id_(u.id_) + , info_(u.info_) + { + ++info_->ncopy; + } + + test_allocator(test_allocator&& t) + : id_(t.id_) + , info_(t.info_) + { + ++info_->nmove; + } + + value_type* + allocate(std::size_t n) + { + return static_cast( + ::operator new (n*sizeof(value_type))); + } + + void + deallocate(value_type* p, std::size_t) noexcept + { + ::operator delete(p); + } + + std::size_t + id() const + { + return id_; + } + + test_allocator_info const* + operator->() const + { + return info_.get(); + } +}; + +class basic_streambuf_test : public beast::unit_test::suite +{ +public: + template + static + bool + eq(basic_streambuf const& sb1, + basic_streambuf const& sb2) + { + return to_string(sb1.data()) == to_string(sb2.data()); + } + + template + void + expect_size(std::size_t n, ConstBufferSequence const& buffers) + { + BEAST_EXPECT(test::size_pre(buffers) == n); + BEAST_EXPECT(test::size_post(buffers) == n); + BEAST_EXPECT(test::size_rev_pre(buffers) == n); + BEAST_EXPECT(test::size_rev_post(buffers) == n); + } + + template + static + void + self_assign(U& u, V&& v) + { + u = std::forward(v); + } + + void testSpecialMembers() + { + using boost::asio::buffer; + using boost::asio::buffer_cast; + using boost::asio::buffer_size; + std::string const s = "Hello, world"; + BEAST_EXPECT(s.size() == 12); + for(std::size_t i = 1; i < 12; ++i) { + for(std::size_t x = 1; x < 4; ++x) { + for(std::size_t y = 1; y < 4; ++y) { + std::size_t z = s.size() - (x + y); + { + streambuf sb(i); + sb.commit(buffer_copy(sb.prepare(x), buffer(s.data(), x))); + sb.commit(buffer_copy(sb.prepare(y), buffer(s.data()+x, y))); + sb.commit(buffer_copy(sb.prepare(z), buffer(s.data()+x+y, z))); + BEAST_EXPECT(to_string(sb.data()) == s); + { + streambuf sb2(sb); + BEAST_EXPECT(eq(sb, sb2)); + } + { + streambuf sb2; + sb2 = sb; + BEAST_EXPECT(eq(sb, sb2)); + } + { + streambuf sb2(std::move(sb)); + BEAST_EXPECT(to_string(sb2.data()) == s); + expect_size(0, sb.data()); + sb = std::move(sb2); + BEAST_EXPECT(to_string(sb.data()) == s); + expect_size(0, sb2.data()); + } + self_assign(sb, sb); + BEAST_EXPECT(to_string(sb.data()) == s); + self_assign(sb, std::move(sb)); + BEAST_EXPECT(to_string(sb.data()) == s); + } + }}} + try + { + streambuf sb0(0); + fail(); + } + catch(std::exception const&) + { + pass(); + } + } + + void testAllocator() + { + // VFALCO This needs work + { + using alloc_type = + test_allocator; + using sb_type = basic_streambuf; + sb_type sb; + BEAST_EXPECT(sb.get_allocator().id() == 1); + } + { + using alloc_type = + test_allocator; + using sb_type = basic_streambuf; + sb_type sb; + BEAST_EXPECT(sb.get_allocator().id() == 2); + sb_type sb2(sb); + BEAST_EXPECT(sb2.get_allocator().id() == 2); + sb_type sb3(sb, alloc_type{}); + } + } + + void + testPrepare() + { + using boost::asio::buffer_size; + { + streambuf sb(2); + BEAST_EXPECT(buffer_size(sb.prepare(5)) == 5); + BEAST_EXPECT(buffer_size(sb.prepare(8)) == 8); + BEAST_EXPECT(buffer_size(sb.prepare(7)) == 7); + } + { + streambuf sb(2); + sb.prepare(2); + BEAST_EXPECT(test::buffer_count(sb.prepare(5)) == 2); + BEAST_EXPECT(test::buffer_count(sb.prepare(8)) == 3); + BEAST_EXPECT(test::buffer_count(sb.prepare(4)) == 2); + } + } + + void testCommit() + { + using boost::asio::buffer_size; + streambuf sb(2); + sb.prepare(2); + sb.prepare(5); + sb.commit(1); + expect_size(1, sb.data()); + } + + void testConsume() + { + using boost::asio::buffer_size; + streambuf sb(1); + expect_size(5, sb.prepare(5)); + sb.commit(3); + expect_size(3, sb.data()); + sb.consume(1); + expect_size(2, sb.data()); + } + + void testMatrix() + { + using boost::asio::buffer; + using boost::asio::buffer_cast; + using boost::asio::buffer_size; + std::string const s = "Hello, world"; + BEAST_EXPECT(s.size() == 12); + for(std::size_t i = 1; i < 12; ++i) { + for(std::size_t x = 1; x < 4; ++x) { + for(std::size_t y = 1; y < 4; ++y) { + for(std::size_t t = 1; t < 4; ++ t) { + for(std::size_t u = 1; u < 4; ++ u) { + std::size_t z = s.size() - (x + y); + std::size_t v = s.size() - (t + u); + { + streambuf sb(i); + { + auto d = sb.prepare(z); + BEAST_EXPECT(buffer_size(d) == z); + } + { + auto d = sb.prepare(0); + BEAST_EXPECT(buffer_size(d) == 0); + } + { + auto d = sb.prepare(y); + BEAST_EXPECT(buffer_size(d) == y); + } + { + auto d = sb.prepare(x); + BEAST_EXPECT(buffer_size(d) == x); + sb.commit(buffer_copy(d, buffer(s.data(), x))); + } + BEAST_EXPECT(sb.size() == x); + BEAST_EXPECT(buffer_size(sb.data()) == sb.size()); + { + auto d = sb.prepare(x); + BEAST_EXPECT(buffer_size(d) == x); + } + { + auto d = sb.prepare(0); + BEAST_EXPECT(buffer_size(d) == 0); + } + { + auto d = sb.prepare(z); + BEAST_EXPECT(buffer_size(d) == z); + } + { + auto d = sb.prepare(y); + BEAST_EXPECT(buffer_size(d) == y); + sb.commit(buffer_copy(d, buffer(s.data()+x, y))); + } + sb.commit(1); + BEAST_EXPECT(sb.size() == x + y); + BEAST_EXPECT(buffer_size(sb.data()) == sb.size()); + { + auto d = sb.prepare(x); + BEAST_EXPECT(buffer_size(d) == x); + } + { + auto d = sb.prepare(y); + BEAST_EXPECT(buffer_size(d) == y); + } + { + auto d = sb.prepare(0); + BEAST_EXPECT(buffer_size(d) == 0); + } + { + auto d = sb.prepare(z); + BEAST_EXPECT(buffer_size(d) == z); + sb.commit(buffer_copy(d, buffer(s.data()+x+y, z))); + } + sb.commit(2); + BEAST_EXPECT(sb.size() == x + y + z); + BEAST_EXPECT(buffer_size(sb.data()) == sb.size()); + BEAST_EXPECT(to_string(sb.data()) == s); + sb.consume(t); + { + auto d = sb.prepare(0); + BEAST_EXPECT(buffer_size(d) == 0); + } + BEAST_EXPECT(to_string(sb.data()) == s.substr(t, std::string::npos)); + sb.consume(u); + BEAST_EXPECT(to_string(sb.data()) == s.substr(t + u, std::string::npos)); + sb.consume(v); + BEAST_EXPECT(to_string(sb.data()) == ""); + sb.consume(1); + { + auto d = sb.prepare(0); + BEAST_EXPECT(buffer_size(d) == 0); + } + } + }}}}} + } + + void testIterators() + { + using boost::asio::buffer_size; + streambuf sb(1); + sb.prepare(1); + sb.commit(1); + sb.prepare(2); + sb.commit(2); + expect_size(3, sb.data()); + sb.prepare(1); + expect_size(3, sb.prepare(3)); + sb.commit(2); + BEAST_EXPECT(test::buffer_count(sb.data()) == 4); + } + + void testOutputStream() + { + streambuf sb; + sb << "x"; + BEAST_EXPECT(to_string(sb.data()) == "x"); + } + + void testCapacity() + { + using boost::asio::buffer_size; + { + streambuf sb{10}; + BEAST_EXPECT(sb.alloc_size() == 10); + BEAST_EXPECT(read_size_helper(sb, 1) == 1); + BEAST_EXPECT(read_size_helper(sb, 10) == 10); + BEAST_EXPECT(read_size_helper(sb, 20) == 20); + BEAST_EXPECT(read_size_helper(sb, 1000) == 512); + sb.prepare(3); + sb.commit(3); + BEAST_EXPECT(read_size_helper(sb, 10) == 7); + BEAST_EXPECT(read_size_helper(sb, 1000) == 7); + } + { + streambuf sb(1000); + BEAST_EXPECT(sb.alloc_size() == 1000); + BEAST_EXPECT(read_size_helper(sb, 1) == 1); + BEAST_EXPECT(read_size_helper(sb, 1000) == 1000); + BEAST_EXPECT(read_size_helper(sb, 2000) == 1000); + sb.prepare(3); + BEAST_EXPECT(read_size_helper(sb, 1) == 1); + BEAST_EXPECT(read_size_helper(sb, 1000) == 1000); + BEAST_EXPECT(read_size_helper(sb, 2000) == 1000); + sb.commit(3); + BEAST_EXPECT(read_size_helper(sb, 1) == 1); + BEAST_EXPECT(read_size_helper(sb, 1000) == 997); + BEAST_EXPECT(read_size_helper(sb, 2000) == 997); + sb.consume(2); + BEAST_EXPECT(read_size_helper(sb, 1) == 1); + BEAST_EXPECT(read_size_helper(sb, 1000) == 997); + BEAST_EXPECT(read_size_helper(sb, 2000) == 997); + } + { + streambuf sb{2}; + BEAST_EXPECT(sb.alloc_size() == 2); + BEAST_EXPECT(test::buffer_count(sb.prepare(2)) == 1); + BEAST_EXPECT(test::buffer_count(sb.prepare(3)) == 2); + BEAST_EXPECT(buffer_size(sb.prepare(5)) == 5); + BEAST_EXPECT(read_size_helper(sb, 10) == 6); + } + { + auto avail = + [](streambuf const& sb) + { + return sb.capacity() - sb.size(); + }; + streambuf sb{100}; + BEAST_EXPECT(sb.alloc_size() == 100); + BEAST_EXPECT(avail(sb) == 0); + sb.prepare(100); + BEAST_EXPECT(avail(sb) == 100); + sb.commit(100); + BEAST_EXPECT(avail(sb) == 0); + sb.consume(100); + BEAST_EXPECT(avail(sb) == 0); + sb.alloc_size(200); + BEAST_EXPECT(sb.alloc_size() == 200); + sb.prepare(1); + BEAST_EXPECT(avail(sb) == 200); + } + } + + void run() override + { + testSpecialMembers(); + testAllocator(); + testPrepare(); + testCommit(); + testConsume(); + testMatrix(); + testIterators(); + testOutputStream(); + testCapacity(); + } +}; + +BEAST_DEFINE_TESTSUITE(basic_streambuf,core,beast); + } // beast diff --git a/test/core/to_string.cpp b/test/core/to_string.cpp index 660e643f4..e449dd33a 100644 --- a/test/core/to_string.cpp +++ b/test/core/to_string.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -8,3 +8,21 @@ // Test that header file is self-contained. #include +#include +#include + +namespace beast { + +class to_string_test : public beast::unit_test::suite +{ +public: + void run() + { + BEAST_EXPECT(to_string(boost::asio::const_buffers_1("x", 1)) == "x"); + } +}; + +BEAST_DEFINE_TESTSUITE(to_string,core,beast); + +} // beast + diff --git a/test/core/write_dynabuf.cpp b/test/core/write_dynabuf.cpp index 137ea350d..36a65a6c6 100644 --- a/test/core/write_dynabuf.cpp +++ b/test/core/write_dynabuf.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/core/zlib.cpp b/test/core/zlib.cpp index f18e5c335..cb963dcec 100644 --- a/test/core/zlib.cpp +++ b/test/core/zlib.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http.cpp b/test/http.cpp index a3811b4a9..66854b432 100644 --- a/test/http.cpp +++ b/test/http.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/basic_dynabuf_body.cpp b/test/http/basic_dynabuf_body.cpp index 31fbd7736..a8a449c21 100644 --- a/test/http/basic_dynabuf_body.cpp +++ b/test/http/basic_dynabuf_body.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/basic_fields.cpp b/test/http/basic_fields.cpp index 622d2f789..9948bd63a 100644 --- a/test/http/basic_fields.cpp +++ b/test/http/basic_fields.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/basic_parser_v1.cpp b/test/http/basic_parser_v1.cpp index 5cbe1c19b..5c88a98de 100644 --- a/test/http/basic_parser_v1.cpp +++ b/test/http/basic_parser_v1.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/chunk_encode.cpp b/test/http/chunk_encode.cpp index cff31cbda..9bbe68f36 100644 --- a/test/http/chunk_encode.cpp +++ b/test/http/chunk_encode.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -20,7 +20,7 @@ public: struct final_chunk { std::string s; - + final_chunk() = default; explicit diff --git a/test/http/concepts.cpp b/test/http/concepts.cpp index e540397bd..9bc87107c 100644 --- a/test/http/concepts.cpp +++ b/test/http/concepts.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/empty_body.cpp b/test/http/empty_body.cpp index 1ae539778..fa190ed38 100644 --- a/test/http/empty_body.cpp +++ b/test/http/empty_body.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/fail_parser.hpp b/test/http/fail_parser.hpp index 3cb049600..656516332 100644 --- a/test/http/fail_parser.hpp +++ b/test/http/fail_parser.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/fields.cpp b/test/http/fields.cpp index 4a0f5fa81..8ac52d5bf 100644 --- a/test/http/fields.cpp +++ b/test/http/fields.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/header_parser_v1.cpp b/test/http/header_parser_v1.cpp index 61a35c2be..8200fe8c1 100644 --- a/test/http/header_parser_v1.cpp +++ b/test/http/header_parser_v1.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/message.cpp b/test/http/message.cpp index 47216b236..3b1c711af 100644 --- a/test/http/message.cpp +++ b/test/http/message.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/message_fuzz.hpp b/test/http/message_fuzz.hpp index d76ebedcf..c0780a08d 100644 --- a/test/http/message_fuzz.hpp +++ b/test/http/message_fuzz.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/nodejs_parser.cpp b/test/http/nodejs_parser.cpp index a216ec0d0..633872fa9 100644 --- a/test/http/nodejs_parser.cpp +++ b/test/http/nodejs_parser.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/nodejs_parser.hpp b/test/http/nodejs_parser.hpp index a9611e557..83ee3665a 100644 --- a/test/http/nodejs_parser.hpp +++ b/test/http/nodejs_parser.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -834,7 +834,7 @@ private: // VFALCO TODO return expect_body_ return true; } - + bool on_response(int, std::string const&, int, int, bool, bool, std::false_type) diff --git a/test/http/parse.cpp b/test/http/parse.cpp index 5033f4528..b15e9e436 100644 --- a/test/http/parse.cpp +++ b/test/http/parse.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/parse_error.cpp b/test/http/parse_error.cpp index 626c8e504..ea23bc1a1 100644 --- a/test/http/parse_error.cpp +++ b/test/http/parse_error.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/parser_bench.cpp b/test/http/parser_bench.cpp index a51d4822d..768d267d7 100644 --- a/test/http/parser_bench.cpp +++ b/test/http/parser_bench.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/parser_v1.cpp b/test/http/parser_v1.cpp index d9e5259ea..20c207d7d 100644 --- a/test/http/parser_v1.cpp +++ b/test/http/parser_v1.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -25,64 +25,8 @@ class parser_v1_test , public test::enable_yield_to { public: - void testRegressions() - { - using boost::asio::buffer; - - // consecutive empty header values - { - error_code ec; - parser_v1 p; - std::string const s = - "GET / HTTP/1.1\r\n" - "X1:\r\n" - "X2:\r\n" - "X3:x\r\n" - "\r\n"; - p.write(buffer(s), ec); - if(! BEAST_EXPECTS(! ec, ec.message())) - return; - BEAST_EXPECT(p.complete()); - auto const msg = p.release(); - BEAST_EXPECT(msg.fields.exists("X1")); - BEAST_EXPECT(msg.fields["X1"] == ""); - BEAST_EXPECT(msg.fields.exists("X2")); - BEAST_EXPECT(msg.fields["X2"] == ""); - BEAST_EXPECT(msg.fields.exists("X3")); - BEAST_EXPECT(msg.fields["X3"] == "x"); - } - } - - void testWithBody() - { - test::string_stream ss{ios_, - "GET / HTTP/1.1\r\n" - "User-Agent: test\r\n" - "Content-Length: 1\r\n" - "\r\n" - "*"}; - streambuf rb; - header_parser_v1 p0; - parse(ss, rb, p0); - request_header const& reqh = p0.get(); - BEAST_EXPECT(reqh.method == "GET"); - BEAST_EXPECT(reqh.url == "/"); - BEAST_EXPECT(reqh.version == 11); - BEAST_EXPECT(reqh.fields["User-Agent"] == "test"); - BEAST_EXPECT(reqh.fields["Content-Length"] == "1"); - parser_v1 p = - with_body(p0); - BEAST_EXPECT(p.get().method == "GET"); - BEAST_EXPECT(p.get().url == "/"); - BEAST_EXPECT(p.get().version == 11); - BEAST_EXPECT(p.get().fields["User-Agent"] == "test"); - BEAST_EXPECT(p.get().fields["Content-Length"] == "1"); - parse(ss, rb, p); - request req = p.release(); - BEAST_EXPECT(req.body == "*"); - } - - void run() override + void + testParse() { using boost::asio::buffer; { @@ -138,9 +82,75 @@ public: BEAST_EXPECT(! ec); BEAST_EXPECT(p.complete()); } + } - testRegressions(); + void + testWithBody() + { + std::string const raw = + "GET / HTTP/1.1\r\n" + "User-Agent: test\r\n" + "Content-Length: 1\r\n" + "\r\n" + "*"; + test::string_istream ss{ + ios_, raw, raw.size() - 1}; + + streambuf rb; + header_parser_v1 p0; + parse(ss, rb, p0); + request_header const& reqh = p0.get(); + BEAST_EXPECT(reqh.method == "GET"); + BEAST_EXPECT(reqh.url == "/"); + BEAST_EXPECT(reqh.version == 11); + BEAST_EXPECT(reqh.fields["User-Agent"] == "test"); + BEAST_EXPECT(reqh.fields["Content-Length"] == "1"); + parser_v1 p = + with_body(p0); + BEAST_EXPECT(p.get().method == "GET"); + BEAST_EXPECT(p.get().url == "/"); + BEAST_EXPECT(p.get().version == 11); + BEAST_EXPECT(p.get().fields["User-Agent"] == "test"); + BEAST_EXPECT(p.get().fields["Content-Length"] == "1"); + parse(ss, rb, p); + request req = p.release(); + BEAST_EXPECT(req.body == "*"); + } + + void + testRegressions() + { + using boost::asio::buffer; + + // consecutive empty header values + { + error_code ec; + parser_v1 p; + std::string const s = + "GET / HTTP/1.1\r\n" + "X1:\r\n" + "X2:\r\n" + "X3:x\r\n" + "\r\n"; + p.write(buffer(s), ec); + if(! BEAST_EXPECTS(! ec, ec.message())) + return; + BEAST_EXPECT(p.complete()); + auto const msg = p.release(); + BEAST_EXPECT(msg.fields.exists("X1")); + BEAST_EXPECT(msg.fields["X1"] == ""); + BEAST_EXPECT(msg.fields.exists("X2")); + BEAST_EXPECT(msg.fields["X2"] == ""); + BEAST_EXPECT(msg.fields.exists("X3")); + BEAST_EXPECT(msg.fields["X3"] == "x"); + } + } + + void run() override + { + testParse(); testWithBody(); + testRegressions(); } }; diff --git a/test/http/read.cpp b/test/http/read.cpp index bce7a86ed..bd4cde264 100644 --- a/test/http/read.cpp +++ b/test/http/read.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -95,7 +95,7 @@ public: sb.prepare(len), buffer(s, len))); test::fail_counter fc(n); test::fail_stream< - test::string_stream> fs{fc, ios_, ""}; + test::string_istream> fs{fc, ios_, ""}; fail_parser p(fc); error_code ec; parse(fs, sb, p, ec); @@ -110,7 +110,7 @@ public: sb.commit(buffer_copy( sb.prepare(pre), buffer(s, pre))); test::fail_counter fc(n); - test::fail_stream fs{ + test::fail_stream fs{ fc, ios_, std::string{s + pre, len - pre}}; fail_parser p(fc); error_code ec; @@ -126,7 +126,7 @@ public: sb.prepare(len), buffer(s, len))); test::fail_counter fc(n); test::fail_stream< - test::string_stream> fs{fc, ios_, ""}; + test::string_istream> fs{fc, ios_, ""}; fail_parser p(fc); error_code ec; async_parse(fs, sb, p, do_yield[ec]); @@ -141,7 +141,7 @@ public: sb.commit(buffer_copy( sb.prepare(pre), buffer(s, pre))); test::fail_counter fc(n); - test::fail_stream fs{ + test::fail_stream fs{ fc, ios_, std::string{s + pre, len - pre}}; fail_parser p(fc); error_code ec; @@ -156,7 +156,7 @@ public: sb.commit(buffer_copy( sb.prepare(len), buffer(s, len))); test::fail_counter fc{n}; - test::string_stream ss{ios_, s}; + test::string_istream ss{ios_, s}; parser_v1 p{fc}; error_code ec; parse(ss, sb, p, ec); @@ -171,7 +171,7 @@ public: try { streambuf sb; - test::string_stream ss(ios_, "GET / X"); + test::string_istream ss(ios_, "GET / X"); parser_v1 p; parse(ss, sb, p); fail(); @@ -251,7 +251,7 @@ public: for(n = 0; n < limit; ++n) { - test::fail_stream fs{n, ios_, + test::fail_stream fs{n, ios_, "GET / HTTP/1.1\r\n" "Host: localhost\r\n" "User-Agent: test\r\n" @@ -273,7 +273,7 @@ public: for(n = 0; n < limit; ++n) { - test::fail_stream fs(n, ios_, + test::fail_stream fs(n, ios_, "GET / HTTP/1.1\r\n" "Host: localhost\r\n" "User-Agent: test\r\n" @@ -297,7 +297,7 @@ public: for(n = 0; n < limit; ++n) { - test::fail_stream fs(n, ios_, + test::fail_stream fs(n, ios_, "GET / HTTP/1.1\r\n" "Host: localhost\r\n" "User-Agent: test\r\n" @@ -319,7 +319,7 @@ public: for(n = 0; n < limit; ++n) { - test::fail_stream fs(n, ios_, + test::fail_stream fs(n, ios_, "GET / HTTP/1.1\r\n" "Host: localhost\r\n" "User-Agent: test\r\n" @@ -337,7 +337,7 @@ public: for(n = 0; n < limit; ++n) { - test::fail_stream fs(n, ios_, + test::fail_stream fs(n, ios_, "GET / HTTP/1.1\r\n" "Host: localhost\r\n" "User-Agent: test\r\n" @@ -358,7 +358,7 @@ public: { { streambuf sb; - test::string_stream ss(ios_, ""); + test::string_istream ss(ios_, ""); parser_v1 p; error_code ec; parse(ss, sb, p, ec); @@ -366,7 +366,7 @@ public: } { streambuf sb; - test::string_stream ss(ios_, ""); + test::string_istream ss(ios_, ""); parser_v1 p; error_code ec; async_parse(ss, sb, p, do_yield[ec]); diff --git a/test/http/reason.cpp b/test/http/reason.cpp index e4d6efe82..c5987d359 100644 --- a/test/http/reason.cpp +++ b/test/http/reason.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/resume_context.cpp b/test/http/resume_context.cpp index 02c9f11d0..0809b6217 100644 --- a/test/http/resume_context.cpp +++ b/test/http/resume_context.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/rfc7230.cpp b/test/http/rfc7230.cpp index a1a6e8aeb..1e486bfa5 100644 --- a/test/http/rfc7230.cpp +++ b/test/http/rfc7230.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/streambuf_body.cpp b/test/http/streambuf_body.cpp index e2ed38116..2b5ed5f7a 100644 --- a/test/http/streambuf_body.cpp +++ b/test/http/streambuf_body.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -33,7 +33,7 @@ public: "Content-Length: 3\r\n" "\r\n" "xyz"; - test::string_stream ss(ios_, s); + test::string_istream ss(ios_, s); parser_v1 p; streambuf sb; parse(ss, sb, p); diff --git a/test/http/string_body.cpp b/test/http/string_body.cpp index 43e2e0f73..4b84a939b 100644 --- a/test/http/string_body.cpp +++ b/test/http/string_body.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/http/write.cpp b/test/http/write.cpp index 09a087b36..10eeb92c0 100644 --- a/test/http/write.cpp +++ b/test/http/write.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -31,68 +32,6 @@ class write_test , public test::enable_yield_to { public: - class string_write_stream - { - boost::asio::io_service& ios_; - - public: - std::string str; - - explicit - string_write_stream(boost::asio::io_service& ios) - : ios_(ios) - { - } - - boost::asio::io_service& - get_io_service() - { - return ios_; - } - - template - std::size_t - write_some(ConstBufferSequence const& buffers) - { - error_code ec; - auto const n = write_some(buffers, ec); - if(ec) - throw system_error{ec}; - return n; - } - - template - std::size_t - write_some( - ConstBufferSequence const& buffers, error_code&) - { - auto const n = buffer_size(buffers); - using boost::asio::buffer_size; - using boost::asio::buffer_cast; - str.reserve(str.size() + n); - for(auto const& buffer : buffers) - str.append(buffer_cast(buffer), - buffer_size(buffer)); - return n; - } - - template - typename async_completion< - WriteHandler, void(error_code)>::result_type - async_write_some(ConstBufferSequence const& buffers, - WriteHandler&& handler) - { - error_code ec; - auto const bytes_transferred = write_some(buffers, ec); - async_completion< - WriteHandler, void(error_code, std::size_t) - > completion(handler); - get_io_service().post( - bind_handler(completion.handler, ec, bytes_transferred)); - return completion.result.get(); - } - }; - struct unsized_body { using value_type = std::string; @@ -225,7 +164,7 @@ public: std::string str(message const& m) { - string_write_stream ss(ios_); + test::string_ostream ss(ios_); write(ss, m); return ss.str; } @@ -240,7 +179,7 @@ public: m.url = "/"; m.fields.insert("User-Agent", "test"); error_code ec; - string_write_stream ss{ios_}; + test::string_ostream ss{ios_}; async_write(ss, m, do_yield[ec]); if(BEAST_EXPECTS(! ec, ec.message())) BEAST_EXPECT(ss.str == @@ -256,7 +195,7 @@ public: m.fields.insert("Server", "test"); m.fields.insert("Content-Length", "5"); error_code ec; - string_write_stream ss{ios_}; + test::string_ostream ss{ios_}; async_write(ss, m, do_yield[ec]); if(BEAST_EXPECTS(! ec, ec.message())) BEAST_EXPECT(ss.str == @@ -279,7 +218,7 @@ public: m.fields.insert("Content-Length", "5"); m.body = "*****"; error_code ec; - string_write_stream ss{ios_}; + test::string_ostream ss{ios_}; async_write(ss, m, do_yield[ec]); if(BEAST_EXPECTS(! ec, ec.message())) BEAST_EXPECT(ss.str == @@ -298,7 +237,7 @@ public: m.fields.insert("Transfer-Encoding", "chunked"); m.body = "*****"; error_code ec; - string_write_stream ss(ios_); + test::string_ostream ss(ios_); async_write(ss, m, do_yield[ec]); if(BEAST_EXPECTS(! ec, ec.message())) BEAST_EXPECT(ss.str == @@ -322,7 +261,7 @@ public: { test::fail_counter fc(n); test::fail_stream< - string_write_stream> fs(fc, ios_); + test::string_ostream> fs(fc, ios_); message m( std::piecewise_construct, std::forward_as_tuple(fc, ios_)); @@ -355,7 +294,7 @@ public: { test::fail_counter fc(n); test::fail_stream< - string_write_stream> fs(fc, ios_); + test::string_ostream> fs(fc, ios_); message m( std::piecewise_construct, std::forward_as_tuple(fc, ios_)); @@ -390,7 +329,7 @@ public: { test::fail_counter fc(n); test::fail_stream< - string_write_stream> fs(fc, ios_); + test::string_ostream> fs(fc, ios_); message m( std::piecewise_construct, std::forward_as_tuple(fc, ios_)); @@ -425,7 +364,7 @@ public: { test::fail_counter fc(n); test::fail_stream< - string_write_stream> fs(fc, ios_); + test::string_ostream> fs(fc, ios_); message m( std::piecewise_construct, std::forward_as_tuple(fc, ios_)); @@ -455,7 +394,7 @@ public: { test::fail_counter fc(n); test::fail_stream< - string_write_stream> fs(fc, ios_); + test::string_ostream> fs(fc, ios_); message m( std::piecewise_construct, std::forward_as_tuple(fc, ios_)); @@ -547,7 +486,7 @@ public: m.fields.insert("User-Agent", "test"); m.body = "*"; prepare(m); - string_write_stream ss(ios_); + test::string_ostream ss(ios_); error_code ec; write(ss, m, ec); BEAST_EXPECT(ec == boost::asio::error::eof); @@ -584,7 +523,7 @@ public: m.fields.insert("User-Agent", "test"); m.body = "*"; prepare(m, connection::close); - string_write_stream ss(ios_); + test::string_ostream ss(ios_); error_code ec; write(ss, m, ec); BEAST_EXPECT(ec == boost::asio::error::eof); @@ -621,7 +560,7 @@ public: m.fields.insert("User-Agent", "test"); m.body = "*"; prepare(m); - string_write_stream ss(ios_); + test::string_ostream ss(ios_); error_code ec; write(ss, m, ec); BEAST_EXPECT(ss.str == diff --git a/test/version.cpp b/test/version.cpp index b69090855..f4f10f9db 100644 --- a/test/version.cpp +++ b/test/version.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/websocket.cpp b/test/websocket.cpp index f14aed1cd..d1be7b299 100644 --- a/test/websocket.cpp +++ b/test/websocket.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/websocket/error.cpp b/test/websocket/error.cpp index a46b4c3a2..9c02468cf 100644 --- a/test/websocket/error.cpp +++ b/test/websocket/error.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/websocket/frame.cpp b/test/websocket/frame.cpp index eb690f65a..13d2c5103 100644 --- a/test/websocket/frame.cpp +++ b/test/websocket/frame.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/websocket/mask.cpp b/test/websocket/mask.cpp index 34bcb2d46..83472556b 100644 --- a/test/websocket/mask.cpp +++ b/test/websocket/mask.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/websocket/option.cpp b/test/websocket/option.cpp index 07190cca1..e0cd2ee50 100644 --- a/test/websocket/option.cpp +++ b/test/websocket/option.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/websocket/rfc6455.cpp b/test/websocket/rfc6455.cpp index d7ad90685..c34daf312 100644 --- a/test/websocket/rfc6455.cpp +++ b/test/websocket/rfc6455.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/websocket/stream.cpp b/test/websocket/stream.cpp index 632567666..d02dd2f4b 100644 --- a/test/websocket/stream.cpp +++ b/test/websocket/stream.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -172,7 +172,7 @@ public: req.fields.insert("Sec-WebSocket-Key", "dGhlIHNhbXBsZSBub25jZQ=="); req.fields.insert("Sec-WebSocket-Version", "13"); stream> ws(n, ios_, ""); + test::string_istream>> ws(n, ios_, ""); try { ws.accept(req); @@ -186,7 +186,7 @@ public: } { // valid - stream ws(ios_, + stream ws(ios_, "GET / HTTP/1.1\r\n" "Host: localhost:80\r\n" "Upgrade: WebSocket\r\n" @@ -207,7 +207,7 @@ public: } { // invalid - stream ws(ios_, + stream ws(ios_, "GET / HTTP/1.0\r\n" "\r\n" ); @@ -230,7 +230,7 @@ public: { for(std::size_t i = 0; i < s.size(); ++i) { - stream ws(ios_, + stream ws(ios_, s.substr(i, s.size() - i)); ws.set_option(keep_alive{true}); try @@ -339,7 +339,7 @@ public: auto const check = [&](std::string const& s) { - stream ws(ios_, s); + stream ws(ios_, s); try { ws.handshake("localhost:80", "/"); @@ -1062,9 +1062,10 @@ public: // send ping and message bool pong = false; - ws.set_option(pong_callback{ - [&](ping_data const& payload) + ws.set_option(ping_callback{ + [&](bool is_pong, ping_data const& payload) { + BEAST_EXPECT(is_pong); BEAST_EXPECT(! pong); pong = true; BEAST_EXPECT(payload == ""); @@ -1081,12 +1082,13 @@ public: BEAST_EXPECT(op == opcode::binary); BEAST_EXPECT(to_string(db.data()) == "Hello"); } - ws.set_option(pong_callback{}); + ws.set_option(ping_callback{}); // send ping and fragmented message - ws.set_option(pong_callback{ - [&](ping_data const& payload) + ws.set_option(ping_callback{ + [&](bool is_pong, ping_data const& payload) { + BEAST_EXPECT(is_pong); BEAST_EXPECT(payload == "payload"); }}); ws.ping("payload"); @@ -1101,7 +1103,7 @@ public: BEAST_EXPECT(pong == 1); BEAST_EXPECT(to_string(db.data()) == "Hello, World!"); } - ws.set_option(pong_callback{}); + ws.set_option(ping_callback{}); // send pong c.pong(ws, ""); diff --git a/test/websocket/teardown.cpp b/test/websocket/teardown.cpp index 324acbe3e..e0985f7bf 100644 --- a/test/websocket/teardown.cpp +++ b/test/websocket/teardown.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/websocket/utf8_checker.cpp b/test/websocket/utf8_checker.cpp index 3e4055dfe..20dc3f37c 100644 --- a/test/websocket/utf8_checker.cpp +++ b/test/websocket/utf8_checker.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/websocket/websocket_async_echo_server.hpp b/test/websocket/websocket_async_echo_server.hpp index 61f0b9f84..4932e35e5 100644 --- a/test/websocket/websocket_async_echo_server.hpp +++ b/test/websocket/websocket_async_echo_server.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/websocket/websocket_sync_echo_server.hpp b/test/websocket/websocket_sync_echo_server.hpp index adaa16338..8f1dbf075 100644 --- a/test/websocket/websocket_sync_echo_server.hpp +++ b/test/websocket/websocket_sync_echo_server.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/zlib.cpp b/test/zlib.cpp index 9254354a4..10db45cb1 100644 --- a/test/zlib.cpp +++ b/test/zlib.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/zlib/deflate_stream.cpp b/test/zlib/deflate_stream.cpp index 613606c70..a82765925 100644 --- a/test/zlib/deflate_stream.cpp +++ b/test/zlib/deflate_stream.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/zlib/error.cpp b/test/zlib/error.cpp index 247b1ecf6..8623a38ed 100644 --- a/test/zlib/error.cpp +++ b/test/zlib/error.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/zlib/inflate_stream.cpp b/test/zlib/inflate_stream.cpp index df72860d1..31f14ac58 100644 --- a/test/zlib/inflate_stream.cpp +++ b/test/zlib/inflate_stream.cpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/test/zlib/ztest.hpp b/test/zlib/ztest.hpp index bbdcd5e6b..e07347eea 100644 --- a/test/zlib/ztest.hpp +++ b/test/zlib/ztest.hpp @@ -1,5 +1,5 @@ // -// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)