mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 05:17:26 +02:00
Boost prep
This commit is contained in:
103
.travis.yml
103
.travis.yml
@ -11,8 +11,6 @@ env:
|
|||||||
# to boost's .tar.gz.
|
# to boost's .tar.gz.
|
||||||
- LCOV_ROOT=$HOME/lcov
|
- LCOV_ROOT=$HOME/lcov
|
||||||
- VALGRIND_ROOT=$HOME/valgrind-install
|
- VALGRIND_ROOT=$HOME/valgrind-install
|
||||||
- BOOST_ROOT=$HOME/boost_1_58_0
|
|
||||||
- BOOST_URL='http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.gz'
|
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
@ -36,11 +34,14 @@ matrix:
|
|||||||
# gcc coverage
|
# gcc coverage
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env:
|
env:
|
||||||
|
- TOOLSET=gcc
|
||||||
|
- COMPILER=g++-6
|
||||||
|
- CXXSTD=c++11
|
||||||
- GCC_VER=6
|
- GCC_VER=6
|
||||||
- VARIANT=coverage
|
- VARIANT=coverage
|
||||||
- ADDRESS_MODEL=64
|
- ADDRESS_MODEL=64
|
||||||
- DO_VALGRIND=false
|
- DO_VALGRIND=false
|
||||||
- BUILD_SYSTEM=cmake
|
#- BUILD_SYSTEM=cmake
|
||||||
- PATH=$PWD/cmake/bin:$PATH
|
- PATH=$PWD/cmake/bin:$PATH
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
@ -55,6 +56,9 @@ matrix:
|
|||||||
# older GCC, release
|
# older GCC, release
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env:
|
env:
|
||||||
|
- TOOLSET=gcc
|
||||||
|
- COMPILER=g++-4.8
|
||||||
|
- CXXSTD=c++11
|
||||||
- GCC_VER=4.8
|
- GCC_VER=4.8
|
||||||
- VARIANT=release
|
- VARIANT=release
|
||||||
- DO_VALGRIND=false
|
- DO_VALGRIND=false
|
||||||
@ -71,11 +75,14 @@ matrix:
|
|||||||
# later GCC
|
# later GCC
|
||||||
- compiler: gcc
|
- compiler: gcc
|
||||||
env:
|
env:
|
||||||
|
- TOOLSET=gcc
|
||||||
|
- COMPILER=g++-5
|
||||||
|
- CXXSTD=c++11
|
||||||
- GCC_VER=5
|
- GCC_VER=5
|
||||||
- VARIANT=release
|
- VARIANT=release
|
||||||
- DO_VALGRIND=true
|
- DO_VALGRIND=true
|
||||||
- ADDRESS_MODEL=64
|
- ADDRESS_MODEL=64
|
||||||
- BUILD_SYSTEM=cmake
|
#- BUILD_SYSTEM=cmake
|
||||||
- PATH=$PWD/cmake/bin:$PATH
|
- PATH=$PWD/cmake/bin:$PATH
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
@ -90,13 +97,16 @@ matrix:
|
|||||||
# clang ubsan+asan
|
# clang ubsan+asan
|
||||||
- compiler: clang
|
- compiler: clang
|
||||||
env:
|
env:
|
||||||
|
- TOOLSET=clang
|
||||||
|
- COMPILER=clang++
|
||||||
|
- CXXSTD=c++11
|
||||||
- GCC_VER=5
|
- GCC_VER=5
|
||||||
- VARIANT=ubasan
|
- VARIANT=ubasan
|
||||||
- CLANG_VER=3.8
|
- CLANG_VER=3.8
|
||||||
- DO_VALGRIND=false
|
- DO_VALGRIND=false
|
||||||
- ADDRESS_MODEL=64
|
- ADDRESS_MODEL=64
|
||||||
- UBSAN_OPTIONS='print_stacktrace=1'
|
- UBSAN_OPTIONS='print_stacktrace=1'
|
||||||
- BUILD_SYSTEM=cmake
|
#- BUILD_SYSTEM=cmake
|
||||||
- PATH=$PWD/cmake/bin:$PATH
|
- PATH=$PWD/cmake/bin:$PATH
|
||||||
- PATH=$PWD/llvm-$LLVM_VERSION/bin:$PATH
|
- PATH=$PWD/llvm-$LLVM_VERSION/bin:$PATH
|
||||||
addons:
|
addons:
|
||||||
@ -111,7 +121,6 @@ matrix:
|
|||||||
|
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- $BOOST_ROOT
|
|
||||||
- $VALGRIND_ROOT
|
- $VALGRIND_ROOT
|
||||||
- llvm-$LLVM_VERSION
|
- llvm-$LLVM_VERSION
|
||||||
- cmake
|
- cmake
|
||||||
@ -119,8 +128,88 @@ cache:
|
|||||||
before_install: &base_before_install
|
before_install: &base_before_install
|
||||||
- scripts/install-dependencies.sh
|
- scripts/install-dependencies.sh
|
||||||
|
|
||||||
|
install:
|
||||||
|
- export BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||||
|
- cd ..
|
||||||
|
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||||
|
- cd boost-root
|
||||||
|
- export BOOST_ROOT="`pwd`"
|
||||||
|
- export PATH="`pwd`":$PATH
|
||||||
|
- git submodule update --init tools/build
|
||||||
|
- git submodule update --init tools/boostdep
|
||||||
|
- git submodule update --init libs/config
|
||||||
|
- git submodule update --init libs/any
|
||||||
|
- git submodule update --init libs/asio
|
||||||
|
- git submodule update --init libs/algorithm
|
||||||
|
- git submodule update --init libs/array
|
||||||
|
- git submodule update --init libs/assert
|
||||||
|
- git submodule update --init libs/atomic
|
||||||
|
- git submodule update --init libs/bind
|
||||||
|
- git submodule update --init libs/chrono
|
||||||
|
- git submodule update --init libs/concept_check
|
||||||
|
- git submodule update --init libs/config
|
||||||
|
- git submodule update --init libs/container
|
||||||
|
- git submodule update --init libs/context
|
||||||
|
- git submodule update --init libs/conversion
|
||||||
|
- git submodule update --init libs/core
|
||||||
|
- git submodule update --init libs/coroutine
|
||||||
|
- git submodule update --init libs/date_time
|
||||||
|
- git submodule update --init libs/detail
|
||||||
|
- git submodule update --init libs/endian
|
||||||
|
- git submodule update --init libs/exception
|
||||||
|
- git submodule update --init libs/filesystem
|
||||||
|
- git submodule update --init libs/foreach
|
||||||
|
- git submodule update --init libs/function
|
||||||
|
- git submodule update --init libs/function_types
|
||||||
|
- git submodule update --init libs/functional
|
||||||
|
- git submodule update --init libs/fusion
|
||||||
|
- git submodule update --init libs/integer
|
||||||
|
- git submodule update --init libs/intrusive
|
||||||
|
- git submodule update --init libs/io
|
||||||
|
- git submodule update --init libs/iostreams
|
||||||
|
- git submodule update --init libs/iterator
|
||||||
|
- git submodule update --init libs/lambda
|
||||||
|
- git submodule update --init libs/lexical_cast
|
||||||
|
- git submodule update --init libs/locale
|
||||||
|
- git submodule update --init libs/logic
|
||||||
|
- git submodule update --init libs/math
|
||||||
|
- git submodule update --init libs/move
|
||||||
|
- git submodule update --init libs/mpl
|
||||||
|
- git submodule update --init libs/numeric/conversion
|
||||||
|
- git submodule update --init libs/optional
|
||||||
|
- git submodule update --init libs/pool
|
||||||
|
- git submodule update --init libs/predef
|
||||||
|
- git submodule update --init libs/preprocessor
|
||||||
|
- git submodule update --init libs/program_options
|
||||||
|
- git submodule update --init libs/proto
|
||||||
|
- git submodule update --init libs/random
|
||||||
|
- git submodule update --init libs/range
|
||||||
|
- git submodule update --init libs/ratio
|
||||||
|
- git submodule update --init libs/rational
|
||||||
|
- git submodule update --init libs/regex
|
||||||
|
- git submodule update --init libs/serialization
|
||||||
|
- git submodule update --init libs/smart_ptr
|
||||||
|
- git submodule update --init libs/static_assert
|
||||||
|
- git submodule update --init libs/system
|
||||||
|
- git submodule update --init libs/thread
|
||||||
|
- git submodule update --init libs/throw_exception
|
||||||
|
- git submodule update --init libs/tokenizer
|
||||||
|
- git submodule update --init libs/tti
|
||||||
|
- git submodule update --init libs/tuple
|
||||||
|
- git submodule update --init libs/type_index
|
||||||
|
- git submodule update --init libs/type_traits
|
||||||
|
- git submodule update --init libs/typeof
|
||||||
|
- git submodule update --init libs/unordered
|
||||||
|
- git submodule update --init libs/utility
|
||||||
|
- git submodule update --init libs/variant
|
||||||
|
- git submodule update --init libs/winapi
|
||||||
|
- rm -rf libs/beast
|
||||||
|
- mkdir libs/beast
|
||||||
|
- cp -r $TRAVIS_BUILD_DIR/* libs/beast
|
||||||
|
- ./bootstrap.sh
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- travis_retry scripts/build-and-test.sh
|
- travis_retry libs/beast/scripts/build-and-test.sh
|
||||||
|
|
||||||
after_script:
|
after_script:
|
||||||
- cat nohup.out || echo "nohup.out already deleted"
|
- cat nohup.out || echo "nohup.out already deleted"
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
Version 86:
|
||||||
|
|
||||||
|
* Boost prep
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Version 85:
|
Version 85:
|
||||||
|
|
||||||
* Fix test failure
|
* Fix test failure
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
cmake_minimum_required (VERSION 3.5.2)
|
cmake_minimum_required (VERSION 3.5.2)
|
||||||
|
|
||||||
@ -53,6 +60,11 @@ endif()
|
|||||||
|
|
||||||
option (Boost_USE_STATIC_LIBS "Use static libraries for boost" ON)
|
option (Boost_USE_STATIC_LIBS "Use static libraries for boost" ON)
|
||||||
|
|
||||||
|
add_definitions (-DBOOST_ASIO_DISABLE_BOOST_ARRAY=1)
|
||||||
|
add_definitions (-DBOOST_ASIO_DISABLE_BOOST_BIND=1)
|
||||||
|
add_definitions (-DBOOST_ASIO_DISABLE_BOOST_DATE_TIME=1)
|
||||||
|
add_definitions (-DBOOST_ASIO_DISABLE_BOOST_REGEX=1)
|
||||||
|
|
||||||
set(BOOST_COMPONENTS system)
|
set(BOOST_COMPONENTS system)
|
||||||
if (Beast_BUILD_EXAMPLES OR Beast_BUILD_TESTS)
|
if (Beast_BUILD_EXAMPLES OR Beast_BUILD_TESTS)
|
||||||
list(APPEND BOOST_COMPONENTS coroutine context filesystem program_options thread)
|
list(APPEND BOOST_COMPONENTS coroutine context filesystem program_options thread)
|
||||||
@ -82,10 +94,10 @@ endif()
|
|||||||
find_package(OpenSSL)
|
find_package(OpenSSL)
|
||||||
|
|
||||||
if (OPENSSL_FOUND)
|
if (OPENSSL_FOUND)
|
||||||
add_definitions (-DBEAST_USE_OPENSSL=1)
|
add_definitions (-DBOOST_BEAST_USE_OPENSSL=1)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
add_definitions (-DBEAST_USE_OPENSSL=0)
|
add_definitions (-DBOOST_BEAST_USE_OPENSSL=0)
|
||||||
message("OpenSSL not found.")
|
message("OpenSSL not found.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -116,18 +128,18 @@ endfunction()
|
|||||||
if ("${VARIANT}" STREQUAL "coverage")
|
if ("${VARIANT}" STREQUAL "coverage")
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
else()
|
else()
|
||||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 -fprofile-arcs -ftest-coverage")
|
set (CMAKE_BUILD_TYPE DEBUG)
|
||||||
set (CMAKE_BUILD_TYPE RELWITHDEBINFO)
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 --coverage")
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov")
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
elseif ("${VARIANT}" STREQUAL "ubasan")
|
elseif ("${VARIANT}" STREQUAL "ubasan")
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
else()
|
else()
|
||||||
set (CMAKE_CXX_FLAGS
|
|
||||||
"${CMAKE_CXX_FLAGS} -DBEAST_NO_SLOW_TESTS=1 -msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/scripts/blacklist.supp")
|
|
||||||
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined")
|
|
||||||
set (CMAKE_BUILD_TYPE RELWITHDEBINFO)
|
set (CMAKE_BUILD_TYPE RELWITHDEBINFO)
|
||||||
|
set (CMAKE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} -DBOOST_BEAST_NO_SLOW_TESTS=1 -msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/scripts/blacklist.supp")
|
||||||
|
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
elseif ("${VARIANT}" STREQUAL "debug")
|
elseif ("${VARIANT}" STREQUAL "debug")
|
||||||
@ -165,9 +177,9 @@ if (OPENSSL_FOUND)
|
|||||||
include_directories (${OPENSSL_INCLUDE_DIR})
|
include_directories (${OPENSSL_INCLUDE_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
file(GLOB_RECURSE BEAST_INCLUDES
|
file(GLOB_RECURSE BOOST_BEAST_INCLUDES
|
||||||
${PROJECT_SOURCE_DIR}/include/beast/*.hpp
|
${PROJECT_SOURCE_DIR}/include/boost/beast/*.hpp
|
||||||
${PROJECT_SOURCE_DIR}/include/beast/*.ipp
|
${PROJECT_SOURCE_DIR}/include/boost/beast/*.ipp
|
||||||
)
|
)
|
||||||
|
|
||||||
file(GLOB_RECURSE COMMON_INCLUDES
|
file(GLOB_RECURSE COMMON_INCLUDES
|
||||||
@ -179,8 +191,8 @@ file(GLOB_RECURSE EXAMPLE_INCLUDES
|
|||||||
)
|
)
|
||||||
|
|
||||||
file(GLOB_RECURSE EXTRAS_INCLUDES
|
file(GLOB_RECURSE EXTRAS_INCLUDES
|
||||||
${PROJECT_SOURCE_DIR}/extras/beast/*.hpp
|
${PROJECT_SOURCE_DIR}/extras/boost/beast/*.hpp
|
||||||
${PROJECT_SOURCE_DIR}/extras/beast/*.ipp
|
${PROJECT_SOURCE_DIR}/extras/boost/beast/*.ipp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (Beast_BUILD_TESTS)
|
if (Beast_BUILD_TESTS)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
#
|
#
|
||||||
# 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
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
import os ;
|
import os ;
|
||||||
import feature ;
|
import feature ;
|
||||||
@ -53,17 +55,17 @@ if [ os.name ] = MACOSX
|
|||||||
}
|
}
|
||||||
|
|
||||||
variant coverage :
|
variant coverage :
|
||||||
release
|
debug
|
||||||
:
|
:
|
||||||
<cxxflags>"-msse4.2 -fprofile-arcs -ftest-coverage"
|
<cxxflags>"-msse4.2 --coverage"
|
||||||
<linkflags>"-lgcov"
|
<linkflags>"--coverage"
|
||||||
;
|
;
|
||||||
|
|
||||||
variant ubasan
|
variant ubasan
|
||||||
:
|
:
|
||||||
release
|
release
|
||||||
:
|
:
|
||||||
<cxxflags>"-msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=scripts/blacklist.supp"
|
<cxxflags>"-msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fsanitize-blacklist=libs/beast/scripts/blacklist.supp"
|
||||||
<linkflags>"-fsanitize=address,undefined"
|
<linkflags>"-fsanitize=address,undefined"
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -72,7 +74,6 @@ project beast
|
|||||||
<implicit-dependency>/boost//headers
|
<implicit-dependency>/boost//headers
|
||||||
<include>.
|
<include>.
|
||||||
<include>./extras
|
<include>./extras
|
||||||
<include>./include
|
|
||||||
#<use>/boost//headers
|
#<use>/boost//headers
|
||||||
<library>/boost/system//boost_system
|
<library>/boost/system//boost_system
|
||||||
<library>/boost/coroutine//boost_coroutine
|
<library>/boost/coroutine//boost_coroutine
|
||||||
@ -83,6 +84,10 @@ project beast
|
|||||||
<threading>multi
|
<threading>multi
|
||||||
<runtime-link>shared
|
<runtime-link>shared
|
||||||
<debug-symbols>on
|
<debug-symbols>on
|
||||||
|
<define>BOOST_ASIO_DISABLE_BOOST_ARRAY=1
|
||||||
|
<define>BOOST_ASIO_DISABLE_BOOST_BIND=1
|
||||||
|
<define>BOOST_ASIO_DISABLE_BOOST_DATE_TIME=1
|
||||||
|
<define>BOOST_ASIO_DISABLE_BOOST_REGEX=1
|
||||||
<toolset>gcc:<cxxflags>-std=c++11
|
<toolset>gcc:<cxxflags>-std=c++11
|
||||||
<toolset>gcc:<cxxflags>-Wno-unused-parameter
|
<toolset>gcc:<cxxflags>-Wno-unused-parameter
|
||||||
<toolset>gcc:<cxxflags>-Wno-unused-variable # Temporary until we can figure out -isystem
|
<toolset>gcc:<cxxflags>-Wno-unused-variable # Temporary until we can figure out -isystem
|
||||||
@ -108,8 +113,4 @@ project beast
|
|||||||
<os>NT,<toolset>gcc-cygwin:<define>__USE_W32_SOCKETS
|
<os>NT,<toolset>gcc-cygwin:<define>__USE_W32_SOCKETS
|
||||||
: usage-requirements
|
: usage-requirements
|
||||||
:
|
:
|
||||||
build-dir bin
|
|
||||||
;
|
;
|
||||||
|
|
||||||
build-project test ;
|
|
||||||
build-project example ;
|
|
@ -22,9 +22,8 @@ install:
|
|||||||
# - git checkout boost-1.64.0
|
# - git checkout boost-1.64.0
|
||||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\beast\
|
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\beast\
|
||||||
- git submodule update --init tools/build
|
- git submodule update --init tools/build
|
||||||
- git submodule update --init libs/config
|
|
||||||
- git submodule update --init tools/boostdep
|
- git submodule update --init tools/boostdep
|
||||||
# - python tools/boostdep/depinst/depinst.py beast
|
- git submodule update --init libs/config
|
||||||
- git submodule update --init libs/any
|
- git submodule update --init libs/any
|
||||||
- git submodule update --init libs/asio
|
- git submodule update --init libs/asio
|
||||||
- git submodule update --init libs/algorithm
|
- git submodule update --init libs/algorithm
|
||||||
@ -64,7 +63,6 @@ install:
|
|||||||
- git submodule update --init libs/mpl
|
- git submodule update --init libs/mpl
|
||||||
- git submodule update --init libs/numeric/conversion
|
- git submodule update --init libs/numeric/conversion
|
||||||
- git submodule update --init libs/optional
|
- git submodule update --init libs/optional
|
||||||
# - git submodule update --init libs/phoenix
|
|
||||||
- git submodule update --init libs/pool
|
- git submodule update --init libs/pool
|
||||||
- git submodule update --init libs/predef
|
- git submodule update --init libs/predef
|
||||||
- git submodule update --init libs/preprocessor
|
- git submodule update --init libs/preprocessor
|
||||||
@ -77,7 +75,6 @@ install:
|
|||||||
- git submodule update --init libs/regex
|
- git submodule update --init libs/regex
|
||||||
- git submodule update --init libs/serialization
|
- git submodule update --init libs/serialization
|
||||||
- git submodule update --init libs/smart_ptr
|
- git submodule update --init libs/smart_ptr
|
||||||
# - git submodule update --init libs/spirit
|
|
||||||
- git submodule update --init libs/static_assert
|
- git submodule update --init libs/static_assert
|
||||||
- git submodule update --init libs/system
|
- git submodule update --init libs/system
|
||||||
- git submodule update --init libs/thread
|
- git submodule update --init libs/thread
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
add_subdirectory (echo-op)
|
add_subdirectory (echo-op)
|
||||||
add_subdirectory (http-client)
|
add_subdirectory (http-client)
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
build-project echo-op ;
|
build-project echo-op ;
|
||||||
build-project http-client ;
|
build-project http-client ;
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_COMMON_DETECT_SSL_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_COMMON_DETECT_SSL_HPP
|
||||||
#define BEAST_EXAMPLE_COMMON_DETECT_SSL_HPP
|
#define BOOST_BEAST_EXAMPLE_COMMON_DETECT_SSL_HPP
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
@ -19,7 +21,7 @@
|
|||||||
|
|
||||||
//[example_core_detect_ssl_1
|
//[example_core_detect_ssl_1
|
||||||
|
|
||||||
#include <beast.hpp>
|
#include <boost/beast.hpp>
|
||||||
#include <boost/logic/tribool.hpp>
|
#include <boost/logic/tribool.hpp>
|
||||||
|
|
||||||
/** Return `true` if a buffer contains a TLS/SSL client handshake.
|
/** Return `true` if a buffer contains a TLS/SSL client handshake.
|
||||||
@ -50,7 +52,7 @@ is_ssl_handshake(ConstBufferSequence const& buffers);
|
|||||||
|
|
||||||
//]
|
//]
|
||||||
|
|
||||||
using namespace beast;
|
using namespace boost::beast;
|
||||||
|
|
||||||
//[example_core_detect_ssl_2
|
//[example_core_detect_ssl_2
|
||||||
|
|
||||||
@ -263,8 +265,8 @@ async_detect_ssl(
|
|||||||
// uses the result and handler specializations associated with
|
// uses the result and handler specializations associated with
|
||||||
// the completion token to help customize the return value.
|
// the completion token to help customize the return value.
|
||||||
//
|
//
|
||||||
beast::async_completion<
|
boost::beast::async_completion<
|
||||||
CompletionToken, void(beast::error_code, boost::tribool)> init{token};
|
CompletionToken, void(boost::beast::error_code, boost::tribool)> init{token};
|
||||||
|
|
||||||
// Create the composed operation and launch it. This is a constructor
|
// Create the composed operation and launch it. This is a constructor
|
||||||
// call followed by invocation of operator(). We use handler_type
|
// call followed by invocation of operator(). We use handler_type
|
||||||
@ -275,7 +277,7 @@ async_detect_ssl(
|
|||||||
detect_ssl_op<AsyncReadStream, DynamicBuffer, handler_type<
|
detect_ssl_op<AsyncReadStream, DynamicBuffer, handler_type<
|
||||||
CompletionToken, void(error_code, boost::tribool)>>{
|
CompletionToken, void(error_code, boost::tribool)>>{
|
||||||
stream, buffer, init.completion_handler}(
|
stream, buffer, init.completion_handler}(
|
||||||
beast::error_code{}, 0);
|
boost::beast::error_code{}, 0);
|
||||||
|
|
||||||
// This hook lets the caller see a return value when appropriate.
|
// This hook lets the caller see a return value when appropriate.
|
||||||
// For example this might return std::future<error_code, boost::tribool> if
|
// For example this might return std::future<error_code, boost::tribool> if
|
||||||
@ -381,7 +383,7 @@ public:
|
|||||||
// Our main entry point. This will get called as our
|
// Our main entry point. This will get called as our
|
||||||
// intermediate operations complete. Definition below.
|
// intermediate operations complete. Definition below.
|
||||||
//
|
//
|
||||||
void operator()(beast::error_code ec, std::size_t bytes_transferred);
|
void operator()(boost::beast::error_code ec, std::size_t bytes_transferred);
|
||||||
};
|
};
|
||||||
|
|
||||||
//]
|
//]
|
||||||
@ -398,7 +400,7 @@ template<
|
|||||||
class Handler>
|
class Handler>
|
||||||
void
|
void
|
||||||
detect_ssl_op<AsyncStream, DynamicBuffer, Handler>::
|
detect_ssl_op<AsyncStream, DynamicBuffer, Handler>::
|
||||||
operator()(beast::error_code ec, std::size_t bytes_transferred)
|
operator()(boost::beast::error_code ec, std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
// Execute the state machine
|
// Execute the state machine
|
||||||
switch(step_)
|
switch(step_)
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_COMMON_HELPERS_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_COMMON_HELPERS_HPP
|
||||||
#define BEAST_EXAMPLE_COMMON_HELPERS_HPP
|
#define BOOST_BEAST_EXAMPLE_COMMON_HELPERS_HPP
|
||||||
|
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <boost/asio/signal_set.hpp>
|
#include <boost/asio/signal_set.hpp>
|
||||||
|
@ -4,20 +4,22 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_COMMON_MIME_TYPES_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_COMMON_MIME_TYPES_HPP
|
||||||
#define BEAST_EXAMPLE_COMMON_MIME_TYPES_HPP
|
#define BOOST_BEAST_EXAMPLE_COMMON_MIME_TYPES_HPP
|
||||||
|
|
||||||
#include <beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
// Return a reasonable mime type based on the extension of a file.
|
// Return a reasonable mime type based on the extension of a file.
|
||||||
//
|
//
|
||||||
template<class = void>
|
template<class = void>
|
||||||
beast::string_view
|
boost::beast::string_view
|
||||||
mime_type(boost::filesystem::path const& path)
|
mime_type(boost::filesystem::path const& path)
|
||||||
{
|
{
|
||||||
using beast::iequals;
|
using boost::beast::iequals;
|
||||||
auto const ext = path.extension().string();
|
auto const ext = path.extension().string();
|
||||||
if(iequals(ext, ".txt")) return "text/plain";
|
if(iequals(ext, ".txt")) return "text/plain";
|
||||||
if(iequals(ext, ".htm")) return "text/html";
|
if(iequals(ext, ".htm")) return "text/html";
|
||||||
|
@ -4,12 +4,14 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_COMMON_RFC7231_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_COMMON_RFC7231_HPP
|
||||||
#define BEAST_EXAMPLE_COMMON_RFC7231_HPP
|
#define BOOST_BEAST_EXAMPLE_COMMON_RFC7231_HPP
|
||||||
|
|
||||||
#include <beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
#include <beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
|
|
||||||
namespace rfc7231 {
|
namespace rfc7231 {
|
||||||
|
|
||||||
@ -27,11 +29,11 @@ namespace rfc7231 {
|
|||||||
*/
|
*/
|
||||||
template<class Body, class Allocator>
|
template<class Body, class Allocator>
|
||||||
bool
|
bool
|
||||||
is_expect_100_continue(beast::http::request<
|
is_expect_100_continue(boost::beast::http::request<
|
||||||
Body, beast::http::basic_fields<Allocator>> const& req)
|
Body, boost::beast::http::basic_fields<Allocator>> const& req)
|
||||||
{
|
{
|
||||||
return beast::iequals(
|
return boost::beast::iequals(
|
||||||
req[beast::http::field::expect], "100-continue");
|
req[boost::beast::http::field::expect], "100-continue");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // rfc7231
|
} // rfc7231
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP
|
||||||
#define BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP
|
#define BOOST_BEAST_EXAMPLE_COMMON_ROOT_CERTIFICATES_HPP
|
||||||
|
|
||||||
#include <boost/asio/ssl.hpp>
|
#include <boost/asio/ssl.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_COMMON_SESSION_ALLOC_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_COMMON_SESSION_ALLOC_HPP
|
||||||
#define BEAST_EXAMPLE_COMMON_SESSION_ALLOC_HPP
|
#define BOOST_BEAST_EXAMPLE_COMMON_SESSION_ALLOC_HPP
|
||||||
|
|
||||||
#include <boost/asio/handler_alloc_hook.hpp>
|
#include <boost/asio/handler_alloc_hook.hpp>
|
||||||
#include <boost/asio/handler_continuation_hook.hpp>
|
#include <boost/asio/handler_continuation_hook.hpp>
|
||||||
@ -18,7 +20,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
#include "extras/beast/unit_test/dstream.hpp"
|
#include "extras/boost/beast/unit_test/dstream.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<class Context>
|
template<class Context>
|
||||||
|
@ -4,12 +4,14 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_COMMON_SSL_STREAM_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_COMMON_SSL_STREAM_HPP
|
||||||
#define BEAST_EXAMPLE_COMMON_SSL_STREAM_HPP
|
#define BOOST_BEAST_EXAMPLE_COMMON_SSL_STREAM_HPP
|
||||||
|
|
||||||
// This include is necessary to work with `ssl::stream` and `beast::websocket::stream`
|
// This include is necessary to work with `ssl::stream` and `boost::beast::websocket::stream`
|
||||||
#include <beast/websocket/ssl.hpp>
|
#include <boost/beast/websocket/ssl.hpp>
|
||||||
|
|
||||||
#include <boost/asio/ip/tcp.hpp>
|
#include <boost/asio/ip/tcp.hpp>
|
||||||
#include <boost/asio/ssl/stream.hpp>
|
#include <boost/asio/ssl/stream.hpp>
|
||||||
@ -292,42 +294,42 @@ public:
|
|||||||
template<class SyncStream>
|
template<class SyncStream>
|
||||||
friend
|
friend
|
||||||
void
|
void
|
||||||
teardown(beast::websocket::teardown_tag,
|
teardown(boost::beast::websocket::teardown_tag,
|
||||||
ssl_stream<SyncStream>& stream,
|
ssl_stream<SyncStream>& stream,
|
||||||
boost::system::error_code& ec);
|
boost::system::error_code& ec);
|
||||||
|
|
||||||
template<class AsyncStream, class TeardownHandler>
|
template<class AsyncStream, class TeardownHandler>
|
||||||
friend
|
friend
|
||||||
void
|
void
|
||||||
async_teardown(beast::websocket::teardown_tag,
|
async_teardown(boost::beast::websocket::teardown_tag,
|
||||||
ssl_stream<AsyncStream>& stream, TeardownHandler&& handler);
|
ssl_stream<AsyncStream>& stream, TeardownHandler&& handler);
|
||||||
};
|
};
|
||||||
|
|
||||||
// These hooks are used to inform beast::websocket::stream on
|
// These hooks are used to inform boost::beast::websocket::stream on
|
||||||
// how to tear down the connection as part of the WebSocket
|
// how to tear down the connection as part of the WebSocket
|
||||||
// protocol specifications
|
// protocol specifications
|
||||||
|
|
||||||
template<class SyncStream>
|
template<class SyncStream>
|
||||||
inline
|
inline
|
||||||
void
|
void
|
||||||
teardown(beast::websocket::teardown_tag,
|
teardown(boost::beast::websocket::teardown_tag,
|
||||||
ssl_stream<SyncStream>& stream,
|
ssl_stream<SyncStream>& stream,
|
||||||
boost::system::error_code& ec)
|
boost::system::error_code& ec)
|
||||||
{
|
{
|
||||||
// Just forward it to the wrapped ssl::stream
|
// Just forward it to the wrapped ssl::stream
|
||||||
using beast::websocket::teardown;
|
using boost::beast::websocket::teardown;
|
||||||
teardown(beast::websocket::teardown_tag{}, *stream.p_, ec);
|
teardown(boost::beast::websocket::teardown_tag{}, *stream.p_, ec);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class AsyncStream, class TeardownHandler>
|
template<class AsyncStream, class TeardownHandler>
|
||||||
inline
|
inline
|
||||||
void
|
void
|
||||||
async_teardown(beast::websocket::teardown_tag,
|
async_teardown(boost::beast::websocket::teardown_tag,
|
||||||
ssl_stream<AsyncStream>& stream, TeardownHandler&& handler)
|
ssl_stream<AsyncStream>& stream, TeardownHandler&& handler)
|
||||||
{
|
{
|
||||||
// Just forward it to the wrapped ssl::stream
|
// Just forward it to the wrapped ssl::stream
|
||||||
using beast::websocket::async_teardown;
|
using boost::beast::websocket::async_teardown;
|
||||||
async_teardown(beast::websocket::teardown_tag{},
|
async_teardown(boost::beast::websocket::teardown_tag{},
|
||||||
*stream.p_, std::forward<TeardownHandler>(handler));
|
*stream.p_, std::forward<TeardownHandler>(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,16 +4,18 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_COMMON_WRITE_MSG_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_COMMON_WRITE_MSG_HPP
|
||||||
#define BEAST_EXAMPLE_COMMON_WRITE_MSG_HPP
|
#define BOOST_BEAST_EXAMPLE_COMMON_WRITE_MSG_HPP
|
||||||
|
|
||||||
#include <beast/core/async_result.hpp>
|
#include <boost/beast/core/async_result.hpp>
|
||||||
#include <beast/core/handler_ptr.hpp>
|
#include <boost/beast/core/handler_ptr.hpp>
|
||||||
#include <beast/core/type_traits.hpp>
|
#include <boost/beast/core/type_traits.hpp>
|
||||||
#include <beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
#include <beast/http/write.hpp>
|
#include <boost/beast/http/write.hpp>
|
||||||
#include <beast/http/type_traits.hpp>
|
#include <boost/beast/http/type_traits.hpp>
|
||||||
#include <boost/asio/handler_alloc_hook.hpp>
|
#include <boost/asio/handler_alloc_hook.hpp>
|
||||||
#include <boost/asio/handler_continuation_hook.hpp>
|
#include <boost/asio/handler_continuation_hook.hpp>
|
||||||
#include <boost/asio/handler_invoke_hook.hpp>
|
#include <boost/asio/handler_invoke_hook.hpp>
|
||||||
@ -44,15 +46,15 @@ class write_msg_op
|
|||||||
// operation takes ownership of the message and destroys
|
// operation takes ownership of the message and destroys
|
||||||
// it when it is done.
|
// it when it is done.
|
||||||
//
|
//
|
||||||
beast::http::message<isRequest, Body, Fields> msg;
|
boost::beast::http::message<isRequest, Body, Fields> msg;
|
||||||
|
|
||||||
// Serializer for the message
|
// Serializer for the message
|
||||||
beast::http::serializer<isRequest, Body, Fields> sr;
|
boost::beast::http::serializer<isRequest, Body, Fields> sr;
|
||||||
|
|
||||||
data(
|
data(
|
||||||
Handler& handler,
|
Handler& handler,
|
||||||
AsyncWriteStream& stream_,
|
AsyncWriteStream& stream_,
|
||||||
beast::http::message<isRequest, Body, Fields>&& msg_)
|
boost::beast::http::message<isRequest, Body, Fields>&& msg_)
|
||||||
: stream(stream_)
|
: stream(stream_)
|
||||||
, msg(std::move(msg_))
|
, msg(std::move(msg_))
|
||||||
, sr(msg)
|
, sr(msg)
|
||||||
@ -67,7 +69,7 @@ class write_msg_op
|
|||||||
// and it also helps to meet Asio's deallocate-before-invocation
|
// and it also helps to meet Asio's deallocate-before-invocation
|
||||||
// guarantee.
|
// guarantee.
|
||||||
//
|
//
|
||||||
beast::handler_ptr<data, Handler> d_;
|
boost::beast::handler_ptr<data, Handler> d_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Asio can move and copy the handler, we support both
|
// Asio can move and copy the handler, we support both
|
||||||
@ -99,16 +101,16 @@ public:
|
|||||||
operator()()
|
operator()()
|
||||||
{
|
{
|
||||||
auto& d = *d_;
|
auto& d = *d_;
|
||||||
beast::http::async_write(
|
boost::beast::http::async_write(
|
||||||
d.stream, d.sr, std::move(*this));
|
d.stream, d.sr, std::move(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Completion handler
|
// Completion handler
|
||||||
//
|
//
|
||||||
// This gets called when beast::http::async_write completes
|
// This gets called when boost::beast::http::async_write completes
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
operator()(beast::error_code ec)
|
operator()(boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
d_.invoke(ec);
|
d_.invoke(ec);
|
||||||
}
|
}
|
||||||
@ -196,27 +198,27 @@ template<
|
|||||||
class AsyncWriteStream,
|
class AsyncWriteStream,
|
||||||
bool isRequest, class Body, class Fields,
|
bool isRequest, class Body, class Fields,
|
||||||
class WriteHandler>
|
class WriteHandler>
|
||||||
beast::async_return_type<WriteHandler, void(beast::error_code)>
|
boost::beast::async_return_type<WriteHandler, void(boost::beast::error_code)>
|
||||||
async_write_msg(
|
async_write_msg(
|
||||||
AsyncWriteStream& stream,
|
AsyncWriteStream& stream,
|
||||||
beast::http::message<isRequest, Body, Fields>&& msg,
|
boost::beast::http::message<isRequest, Body, Fields>&& msg,
|
||||||
WriteHandler&& handler)
|
WriteHandler&& handler)
|
||||||
{
|
{
|
||||||
static_assert(
|
static_assert(
|
||||||
beast::is_async_write_stream<AsyncWriteStream>::value,
|
boost::beast::is_async_write_stream<AsyncWriteStream>::value,
|
||||||
"AsyncWriteStream requirements not met");
|
"AsyncWriteStream requirements not met");
|
||||||
|
|
||||||
static_assert(beast::http::is_body<Body>::value,
|
static_assert(boost::beast::http::is_body<Body>::value,
|
||||||
"Body requirements not met");
|
"Body requirements not met");
|
||||||
|
|
||||||
static_assert(beast::http::is_body_reader<Body>::value,
|
static_assert(boost::beast::http::is_body_reader<Body>::value,
|
||||||
"BodyReader requirements not met");
|
"BodyReader requirements not met");
|
||||||
|
|
||||||
beast::async_completion<WriteHandler, void(beast::error_code)> init{handler};
|
boost::beast::async_completion<WriteHandler, void(boost::beast::error_code)> init{handler};
|
||||||
|
|
||||||
::detail::write_msg_op<
|
::detail::write_msg_op<
|
||||||
AsyncWriteStream,
|
AsyncWriteStream,
|
||||||
beast::handler_type<WriteHandler, void(beast::error_code)>,
|
boost::beast::handler_type<WriteHandler, void(boost::beast::error_code)>,
|
||||||
isRequest, Body, Fields>{
|
isRequest, Body, Fields>{
|
||||||
init.completion_handler,
|
init.completion_handler,
|
||||||
stream,
|
stream,
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include <beast.hpp>
|
#include <boost/beast.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
/* This file contains the functions and classes found in the documentation
|
/* This file contains the functions and classes found in the documentation
|
||||||
@ -15,7 +17,8 @@
|
|||||||
building a network application.
|
building a network application.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// The documentation assumes the beast::http namespace
|
// The documentation assumes the boost::beast::http namespace
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace http {
|
namespace http {
|
||||||
|
|
||||||
@ -1234,3 +1237,4 @@ print_chunked_body(
|
|||||||
|
|
||||||
} // http
|
} // http
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
GroupSources(include/beast beast)
|
GroupSources(include/boost/beast beast)
|
||||||
|
|
||||||
GroupSources(example/echo-op "/")
|
GroupSources(example/echo-op "/")
|
||||||
|
|
||||||
add_executable (echo-op
|
add_executable (echo-op
|
||||||
${BEAST_INCLUDES}
|
${BOOST_BEAST_INCLUDES}
|
||||||
|
Jamfile
|
||||||
echo_op.cpp
|
echo_op.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
exe echo-op :
|
exe echo-op :
|
||||||
echo_op.cpp
|
echo_op.cpp
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include <beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -21,7 +23,7 @@ auto
|
|||||||
async_echo(AsyncStream& stream, CompletionToken&& token)
|
async_echo(AsyncStream& stream, CompletionToken&& token)
|
||||||
|
|
||||||
//]
|
//]
|
||||||
-> beast::async_return_type<CompletionToken, void(beast::error_code)>;
|
-> boost::beast::async_return_type<CompletionToken, void(boost::beast::error_code)>;
|
||||||
|
|
||||||
//[example_core_echo_op_2
|
//[example_core_echo_op_2
|
||||||
|
|
||||||
@ -64,9 +66,9 @@ async_echo(AsyncStream& stream, CompletionToken&& token)
|
|||||||
template<
|
template<
|
||||||
class AsyncStream,
|
class AsyncStream,
|
||||||
class CompletionToken>
|
class CompletionToken>
|
||||||
beast::async_return_type< /*< The [link beast.ref.beast__async_return_type `async_return_type`] customizes the return value based on the completion token >*/
|
boost::beast::async_return_type< /*< The [link beast.ref.beast__async_return_type `async_return_type`] customizes the return value based on the completion token >*/
|
||||||
CompletionToken,
|
CompletionToken,
|
||||||
void(beast::error_code)> /*< This is the signature for the completion handler >*/
|
void(boost::beast::error_code)> /*< This is the signature for the completion handler >*/
|
||||||
async_echo(
|
async_echo(
|
||||||
AsyncStream& stream,
|
AsyncStream& stream,
|
||||||
CompletionToken&& token);
|
CompletionToken&& token);
|
||||||
@ -97,7 +99,7 @@ class echo_op
|
|||||||
// re-use of memory allocated by composed operations during
|
// re-use of memory allocated by composed operations during
|
||||||
// a continuation.
|
// a continuation.
|
||||||
//
|
//
|
||||||
boost::asio::basic_streambuf<beast::handler_alloc<char, Handler>> buffer;
|
boost::asio::basic_streambuf<boost::beast::handler_alloc<char, Handler>> buffer;
|
||||||
|
|
||||||
// handler_ptr requires that the first parameter to the
|
// handler_ptr requires that the first parameter to the
|
||||||
// contained object constructor is a reference to the
|
// contained object constructor is a reference to the
|
||||||
@ -106,7 +108,7 @@ class echo_op
|
|||||||
explicit state(Handler& handler, AsyncStream& stream_)
|
explicit state(Handler& handler, AsyncStream& stream_)
|
||||||
: stream(stream_)
|
: stream(stream_)
|
||||||
, buffer((std::numeric_limits<std::size_t>::max)(),
|
, buffer((std::numeric_limits<std::size_t>::max)(),
|
||||||
beast::handler_alloc<char, Handler>{handler})
|
boost::beast::handler_alloc<char, Handler>{handler})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -123,7 +125,7 @@ class echo_op
|
|||||||
// asio_handler_allocate
|
// asio_handler_allocate
|
||||||
// asio_handler_deallocate
|
// asio_handler_deallocate
|
||||||
//
|
//
|
||||||
beast::handler_ptr<state, Handler> p_;
|
boost::beast::handler_ptr<state, Handler> p_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Boost.Asio requires that handlers are CopyConstructible.
|
// Boost.Asio requires that handlers are CopyConstructible.
|
||||||
@ -145,7 +147,7 @@ public:
|
|||||||
// The entry point for this handler. This will get called
|
// The entry point for this handler. This will get called
|
||||||
// as our intermediate operations complete. Definition below.
|
// as our intermediate operations complete. Definition below.
|
||||||
//
|
//
|
||||||
void operator()(beast::error_code ec, std::size_t bytes_transferred);
|
void operator()(boost::beast::error_code ec, std::size_t bytes_transferred);
|
||||||
|
|
||||||
// The next four functions are required for our class
|
// The next four functions are required for our class
|
||||||
// to meet the requirements for composed operations.
|
// to meet the requirements for composed operations.
|
||||||
@ -177,7 +179,7 @@ public:
|
|||||||
//
|
//
|
||||||
template<class AsyncStream, class Handler>
|
template<class AsyncStream, class Handler>
|
||||||
void echo_op<AsyncStream, Handler>::
|
void echo_op<AsyncStream, Handler>::
|
||||||
operator()(beast::error_code ec, std::size_t bytes_transferred)
|
operator()(boost::beast::error_code ec, std::size_t bytes_transferred)
|
||||||
{
|
{
|
||||||
// Store a reference to our state. The address of the state won't
|
// Store a reference to our state. The address of the state won't
|
||||||
// change, and this solves the problem where dereferencing the
|
// change, and this solves the problem where dereferencing the
|
||||||
@ -199,7 +201,7 @@ operator()(beast::error_code ec, std::size_t bytes_transferred)
|
|||||||
// async_read_until could have read past the newline,
|
// async_read_until could have read past the newline,
|
||||||
// use buffer_prefix to make sure we only send one line
|
// use buffer_prefix to make sure we only send one line
|
||||||
return boost::asio::async_write(p.stream,
|
return boost::asio::async_write(p.stream,
|
||||||
beast::buffer_prefix(bytes_transferred, p.buffer.data()), std::move(*this));
|
boost::beast::buffer_prefix(bytes_transferred, p.buffer.data()), std::move(*this));
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
p.buffer.consume(bytes_transferred);
|
p.buffer.consume(bytes_transferred);
|
||||||
@ -295,20 +297,20 @@ class echo_op;
|
|||||||
// Read a line and echo it back
|
// Read a line and echo it back
|
||||||
//
|
//
|
||||||
template<class AsyncStream, class CompletionToken>
|
template<class AsyncStream, class CompletionToken>
|
||||||
beast::async_return_type<CompletionToken, void(beast::error_code)>
|
boost::beast::async_return_type<CompletionToken, void(boost::beast::error_code)>
|
||||||
async_echo(AsyncStream& stream, CompletionToken&& token)
|
async_echo(AsyncStream& stream, CompletionToken&& token)
|
||||||
{
|
{
|
||||||
// Make sure stream meets the requirements. We use static_assert
|
// Make sure stream meets the requirements. We use static_assert
|
||||||
// to cause a friendly message instead of an error novel.
|
// to cause a friendly message instead of an error novel.
|
||||||
//
|
//
|
||||||
static_assert(beast::is_async_stream<AsyncStream>::value,
|
static_assert(boost::beast::is_async_stream<AsyncStream>::value,
|
||||||
"AsyncStream requirements not met");
|
"AsyncStream requirements not met");
|
||||||
|
|
||||||
// This helper manages some of the handler's lifetime and
|
// This helper manages some of the handler's lifetime and
|
||||||
// uses the result and handler specializations associated with
|
// uses the result and handler specializations associated with
|
||||||
// the completion token to help customize the return value.
|
// the completion token to help customize the return value.
|
||||||
//
|
//
|
||||||
beast::async_completion<CompletionToken, void(beast::error_code)> init{token};
|
boost::beast::async_completion<CompletionToken, void(boost::beast::error_code)> init{token};
|
||||||
|
|
||||||
// Create the composed operation and launch it. This is a constructor
|
// Create the composed operation and launch it. This is a constructor
|
||||||
// call followed by invocation of operator(). We use handler_type
|
// call followed by invocation of operator(). We use handler_type
|
||||||
@ -316,8 +318,8 @@ async_echo(AsyncStream& stream, CompletionToken&& token)
|
|||||||
// allowing user-defined specializations of the async_result template
|
// allowing user-defined specializations of the async_result template
|
||||||
// to be used.
|
// to be used.
|
||||||
//
|
//
|
||||||
echo_op<AsyncStream, beast::handler_type<CompletionToken, void(beast::error_code)>>{
|
echo_op<AsyncStream, boost::beast::handler_type<CompletionToken, void(boost::beast::error_code)>>{
|
||||||
stream, init.completion_handler}(beast::error_code{}, 0);
|
stream, init.completion_handler}(boost::beast::error_code{}, 0);
|
||||||
|
|
||||||
// This hook lets the caller see a return value when appropriate.
|
// This hook lets the caller see a return value when appropriate.
|
||||||
// For example this might return std::future<error_code> if
|
// For example this might return std::future<error_code> if
|
||||||
@ -346,7 +348,7 @@ int main(int, char** argv)
|
|||||||
acceptor.listen();
|
acceptor.listen();
|
||||||
acceptor.accept(sock);
|
acceptor.accept(sock);
|
||||||
async_echo(sock,
|
async_echo(sock,
|
||||||
[&](beast::error_code ec)
|
[&](boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
if(ec)
|
if(ec)
|
||||||
std::cerr << argv[0] << ": " << ec.message() << std::endl;
|
std::cerr << argv[0] << ": " << ec.message() << std::endl;
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
GroupSources(include/beast beast)
|
GroupSources(include/boost/beast beast)
|
||||||
GroupSources(example/common common)
|
GroupSources(example/common common)
|
||||||
GroupSources(example/http-client-ssl "/")
|
GroupSources(example/http-client-ssl "/")
|
||||||
|
|
||||||
add_executable (http-client-ssl
|
add_executable (http-client-ssl
|
||||||
${BEAST_INCLUDES}
|
${BOOST_BEAST_INCLUDES}
|
||||||
${COMMON_INCLUDES}
|
${COMMON_INCLUDES}
|
||||||
|
Jamfile
|
||||||
http_client_ssl.cpp
|
http_client_ssl.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
import os ;
|
import os ;
|
||||||
|
|
||||||
|
@ -4,12 +4,14 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include "../common/root_certificates.hpp"
|
#include "../common/root_certificates.hpp"
|
||||||
|
|
||||||
#include <beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
#include <beast/http.hpp>
|
#include <boost/beast/http.hpp>
|
||||||
#include <beast/version.hpp>
|
#include <boost/beast/version.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/asio/ssl.hpp>
|
#include <boost/asio/ssl.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -17,13 +19,13 @@
|
|||||||
|
|
||||||
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
||||||
namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
|
namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
|
||||||
namespace http = beast::http; // from <beast/http.hpp>
|
namespace http = boost::beast::http; // from <boost/beast/http.hpp>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// A helper for reporting errors
|
// A helper for reporting errors
|
||||||
auto const fail =
|
auto const fail =
|
||||||
[](std::string what, beast::error_code ec)
|
[](std::string what, boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
std::cerr << what << ": " << ec.message() << std::endl;
|
std::cerr << what << ": " << ec.message() << std::endl;
|
||||||
std::cerr.flush();
|
std::cerr.flush();
|
||||||
@ -72,7 +74,7 @@ int main()
|
|||||||
req.version = 11;
|
req.version = 11;
|
||||||
req.set(http::field::host, host + ":" +
|
req.set(http::field::host, host + ":" +
|
||||||
std::to_string(sock.remote_endpoint().port()));
|
std::to_string(sock.remote_endpoint().port()));
|
||||||
req.set(http::field::user_agent, BEAST_VERSION_STRING);
|
req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
|
||||||
req.prepare_payload();
|
req.prepare_payload();
|
||||||
|
|
||||||
// Write the HTTP request to the remote host
|
// Write the HTTP request to the remote host
|
||||||
@ -81,7 +83,7 @@ int main()
|
|||||||
return fail("write", ec);
|
return fail("write", ec);
|
||||||
|
|
||||||
// This buffer is used for reading and must be persisted
|
// This buffer is used for reading and must be persisted
|
||||||
beast::flat_buffer b;
|
boost::beast::flat_buffer b;
|
||||||
|
|
||||||
// Declare a container to hold the response
|
// Declare a container to hold the response
|
||||||
http::response<http::dynamic_body> res;
|
http::response<http::dynamic_body> res;
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
GroupSources(include/beast beast)
|
GroupSources(include/boost/beast beast)
|
||||||
|
|
||||||
GroupSources(example/http-client "/")
|
GroupSources(example/http-client "/")
|
||||||
|
|
||||||
add_executable (http-client
|
add_executable (http-client
|
||||||
${BEAST_INCLUDES}
|
${BOOST_BEAST_INCLUDES}
|
||||||
${EXTRAS_INCLUDES}
|
Jamfile
|
||||||
http_client.cpp
|
http_client.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
exe http-client :
|
exe http-client :
|
||||||
http_client.cpp
|
http_client.cpp
|
||||||
|
@ -4,31 +4,32 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
|
||||||
//[example_http_client
|
//[example_http_client
|
||||||
|
|
||||||
#include <beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
#include <beast/http.hpp>
|
#include <boost/beast/http.hpp>
|
||||||
#include <beast/version.hpp>
|
#include <boost/beast/version.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
||||||
namespace http = beast::http; // from <beast/http.hpp>
|
namespace http = boost::beast::http; // from <boost/beast/http.hpp>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// A helper for reporting errors
|
// A helper for reporting errors
|
||||||
auto const fail =
|
auto const fail =
|
||||||
[](std::string what, beast::error_code ec)
|
[](std::string what, boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
std::cerr << what << ": " << ec.message() << std::endl;
|
std::cerr << what << ": " << ec.message() << std::endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
};
|
};
|
||||||
|
|
||||||
beast::error_code ec;
|
boost::beast::error_code ec;
|
||||||
|
|
||||||
// Set up an asio socket
|
// Set up an asio socket
|
||||||
boost::asio::io_service ios;
|
boost::asio::io_service ios;
|
||||||
@ -50,7 +51,7 @@ int main()
|
|||||||
http::request<http::string_body> req{http::verb::get, "/", 11};
|
http::request<http::string_body> req{http::verb::get, "/", 11};
|
||||||
req.set(http::field::host, host + ":" +
|
req.set(http::field::host, host + ":" +
|
||||||
std::to_string(sock.remote_endpoint().port()));
|
std::to_string(sock.remote_endpoint().port()));
|
||||||
req.set(http::field::user_agent, BEAST_VERSION_STRING);
|
req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
|
||||||
req.prepare_payload();
|
req.prepare_payload();
|
||||||
|
|
||||||
// Write the HTTP request to the remote host
|
// Write the HTTP request to the remote host
|
||||||
@ -59,7 +60,7 @@ int main()
|
|||||||
return fail("write", ec);
|
return fail("write", ec);
|
||||||
|
|
||||||
// This buffer is used for reading and must be persisted
|
// This buffer is used for reading and must be persisted
|
||||||
beast::flat_buffer b;
|
boost::beast::flat_buffer b;
|
||||||
|
|
||||||
// Declare a container to hold the response
|
// Declare a container to hold the response
|
||||||
http::response<http::dynamic_body> res;
|
http::response<http::dynamic_body> res;
|
||||||
@ -78,7 +79,7 @@ int main()
|
|||||||
// not_connected happens sometimes
|
// not_connected happens sometimes
|
||||||
// so don't bother reporting it.
|
// so don't bother reporting it.
|
||||||
//
|
//
|
||||||
if(ec && ec != beast::errc::not_connected)
|
if(ec && ec != boost::beast::errc::not_connected)
|
||||||
return fail("shutdown", ec);
|
return fail("shutdown", ec);
|
||||||
|
|
||||||
// If we get here then the connection is closed gracefully
|
// If we get here then the connection is closed gracefully
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
GroupSources(include/beast beast)
|
GroupSources(include/boost/beast beast)
|
||||||
|
|
||||||
GroupSources(example/http-crawl "/")
|
GroupSources(example/http-crawl "/")
|
||||||
|
|
||||||
add_executable (http-crawl
|
add_executable (http-crawl
|
||||||
${BEAST_INCLUDES}
|
${BOOST_BEAST_INCLUDES}
|
||||||
${EXTRAS_INCLUDES}
|
Jamfile
|
||||||
urls_large_data.hpp
|
urls_large_data.hpp
|
||||||
urls_large_data.cpp
|
urls_large_data.cpp
|
||||||
http_crawl.cpp
|
http_crawl.cpp
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
exe http-crawl :
|
exe http-crawl :
|
||||||
http_crawl.cpp
|
http_crawl.cpp
|
||||||
|
@ -4,22 +4,24 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include "urls_large_data.hpp"
|
#include "urls_large_data.hpp"
|
||||||
|
|
||||||
#include <beast/core/multi_buffer.hpp>
|
#include <boost/beast/core/multi_buffer.hpp>
|
||||||
#include <beast/http.hpp>
|
#include <boost/beast/http.hpp>
|
||||||
#include <beast/version.hpp>
|
#include <boost/beast/version.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
||||||
namespace http = beast::http; // from <beast/http.hpp>
|
namespace http = boost::beast::http; // from <boost/beast/http.hpp>
|
||||||
|
|
||||||
template<class String>
|
template<class String>
|
||||||
void
|
void
|
||||||
err(beast::error_code const& ec, String const& what)
|
err(boost::beast::error_code const& ec, String const& what)
|
||||||
{
|
{
|
||||||
std::cerr << what << ": " << ec.message() << std::endl;
|
std::cerr << what << ": " << ec.message() << std::endl;
|
||||||
}
|
}
|
||||||
@ -33,7 +35,7 @@ main(int, char const*[])
|
|||||||
{
|
{
|
||||||
// A helper for reporting errors
|
// A helper for reporting errors
|
||||||
auto const fail =
|
auto const fail =
|
||||||
[](std::string what, beast::error_code ec)
|
[](std::string what, boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
std::cerr << what << ": " << ec.message() << std::endl;
|
std::cerr << what << ": " << ec.message() << std::endl;
|
||||||
std::cerr.flush();
|
std::cerr.flush();
|
||||||
@ -46,7 +48,7 @@ main(int, char const*[])
|
|||||||
// Loop over all the URLs
|
// Loop over all the URLs
|
||||||
for(auto const& host : urls_large_data())
|
for(auto const& host : urls_large_data())
|
||||||
{
|
{
|
||||||
beast::error_code ec;
|
boost::beast::error_code ec;
|
||||||
|
|
||||||
// Look up the domain name
|
// Look up the domain name
|
||||||
tcp::resolver r(ios);
|
tcp::resolver r(ios);
|
||||||
@ -77,7 +79,7 @@ main(int, char const*[])
|
|||||||
// Set up an HTTP GET request
|
// Set up an HTTP GET request
|
||||||
http::request<http::string_body> req{http::verb::get, "/", 11};
|
http::request<http::string_body> req{http::verb::get, "/", 11};
|
||||||
req.set(http::field::host, host + std::string(":") + std::to_string(ep.port()));
|
req.set(http::field::host, host + std::string(":") + std::to_string(ep.port()));
|
||||||
req.set(http::field::user_agent, BEAST_VERSION_STRING);
|
req.set(http::field::user_agent, BOOST_BEAST_VERSION_STRING);
|
||||||
|
|
||||||
// Set the Connection: close field, this way the server will close
|
// Set the Connection: close field, this way the server will close
|
||||||
// the connection. This consumes less resources (no TIME_WAIT) because
|
// the connection. This consumes less resources (no TIME_WAIT) because
|
||||||
@ -95,7 +97,7 @@ main(int, char const*[])
|
|||||||
// "half-close" here to shut down our end.
|
// "half-close" here to shut down our end.
|
||||||
//
|
//
|
||||||
sock.shutdown(tcp::socket::shutdown_send, ec);
|
sock.shutdown(tcp::socket::shutdown_send, ec);
|
||||||
if(ec && ec != beast::errc::not_connected)
|
if(ec && ec != boost::beast::errc::not_connected)
|
||||||
return fail("shutdown", ec);
|
return fail("shutdown", ec);
|
||||||
}
|
}
|
||||||
if(ec)
|
if(ec)
|
||||||
@ -105,7 +107,7 @@ main(int, char const*[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This buffer is needed for reading
|
// This buffer is needed for reading
|
||||||
beast::multi_buffer b;
|
boost::beast::multi_buffer b;
|
||||||
|
|
||||||
// The response will go into this object
|
// The response will go into this object
|
||||||
http::response<http::string_body> res;
|
http::response<http::string_body> res;
|
||||||
@ -129,7 +131,7 @@ main(int, char const*[])
|
|||||||
// Now we do the other half of the close,
|
// Now we do the other half of the close,
|
||||||
// which is to shut down the receiver.
|
// which is to shut down the receiver.
|
||||||
sock.shutdown(tcp::socket::shutdown_receive, ec);
|
sock.shutdown(tcp::socket::shutdown_receive, ec);
|
||||||
if(ec && ec != beast::errc::not_connected)
|
if(ec && ec != boost::beast::errc::not_connected)
|
||||||
return fail("shutdown", ec);
|
return fail("shutdown", ec);
|
||||||
|
|
||||||
std::cout << res << std::endl;
|
std::cout << res << std::endl;
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include "urls_large_data.hpp"
|
#include "urls_large_data.hpp"
|
||||||
|
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_HTTP_CRAWL_URLS_LARGE_DATA_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_HTTP_CRAWL_URLS_LARGE_DATA_HPP
|
||||||
#define BEAST_EXAMPLE_HTTP_CRAWL_URLS_LARGE_DATA_HPP
|
#define BOOST_BEAST_EXAMPLE_HTTP_CRAWL_URLS_LARGE_DATA_HPP
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
GroupSources(include/beast beast)
|
GroupSources(include/boost/beast beast)
|
||||||
GroupSources(example/common common)
|
GroupSources(example/common common)
|
||||||
GroupSources(example/http-server-fast "/")
|
GroupSources(example/http-server-fast "/")
|
||||||
|
|
||||||
add_executable (http-server-fast
|
add_executable (http-server-fast
|
||||||
${BEAST_INCLUDES}
|
${BOOST_BEAST_INCLUDES}
|
||||||
${COMMON_INCLUDES}
|
${COMMON_INCLUDES}
|
||||||
|
Jamfile
|
||||||
fields_alloc.hpp
|
fields_alloc.hpp
|
||||||
http_server_fast.cpp
|
http_server_fast.cpp
|
||||||
)
|
)
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
exe http-server-fast :
|
exe http-server-fast :
|
||||||
http_server_fast.cpp
|
http_server_fast.cpp
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_FIELDS_ALLOC_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP
|
||||||
#define BEAST_EXAMPLE_FIELDS_ALLOC_HPP
|
#define BOOST_BEAST_EXAMPLE_FIELDS_ALLOC_HPP
|
||||||
|
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include "fields_alloc.hpp"
|
#include "fields_alloc.hpp"
|
||||||
|
|
||||||
#include "../common/mime_types.hpp"
|
#include "../common/mime_types.hpp"
|
||||||
|
|
||||||
#include <beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
#include <beast/http.hpp>
|
#include <boost/beast/http.hpp>
|
||||||
#include <beast/version.hpp>
|
#include <boost/beast/version.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -25,7 +27,7 @@
|
|||||||
|
|
||||||
namespace ip = boost::asio::ip; // from <boost/asio.hpp>
|
namespace ip = boost::asio::ip; // from <boost/asio.hpp>
|
||||||
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
||||||
namespace http = beast::http; // from <beast/http.hpp>
|
namespace http = boost::beast::http; // from <boost/beast/http.hpp>
|
||||||
|
|
||||||
class http_worker
|
class http_worker
|
||||||
{
|
{
|
||||||
@ -47,7 +49,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
using alloc_t = fields_alloc<char>;
|
using alloc_t = fields_alloc<char>;
|
||||||
using request_body_t = http::basic_dynamic_body<beast::flat_static_buffer<1024 * 1024>>;
|
using request_body_t = http::basic_dynamic_body<boost::beast::flat_static_buffer<1024 * 1024>>;
|
||||||
|
|
||||||
// The acceptor used to listen for incoming connections.
|
// The acceptor used to listen for incoming connections.
|
||||||
tcp::acceptor& acceptor_;
|
tcp::acceptor& acceptor_;
|
||||||
@ -59,7 +61,7 @@ private:
|
|||||||
tcp::socket socket_{acceptor_.get_io_service()};
|
tcp::socket socket_{acceptor_.get_io_service()};
|
||||||
|
|
||||||
// The buffer for performing reads
|
// The buffer for performing reads
|
||||||
beast::flat_static_buffer<8192> buffer_;
|
boost::beast::flat_static_buffer<8192> buffer_;
|
||||||
|
|
||||||
// The allocator used for the fields in the request and reply.
|
// The allocator used for the fields in the request and reply.
|
||||||
alloc_t alloc_{8192};
|
alloc_t alloc_{8192};
|
||||||
@ -86,13 +88,13 @@ private:
|
|||||||
void accept()
|
void accept()
|
||||||
{
|
{
|
||||||
// Clean up any previous connection.
|
// Clean up any previous connection.
|
||||||
beast::error_code ec;
|
boost::beast::error_code ec;
|
||||||
socket_.close(ec);
|
socket_.close(ec);
|
||||||
buffer_.consume(buffer_.size());
|
buffer_.consume(buffer_.size());
|
||||||
|
|
||||||
acceptor_.async_accept(
|
acceptor_.async_accept(
|
||||||
socket_,
|
socket_,
|
||||||
[this](beast::error_code ec)
|
[this](boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
@ -131,7 +133,7 @@ private:
|
|||||||
socket_,
|
socket_,
|
||||||
buffer_,
|
buffer_,
|
||||||
*parser_,
|
*parser_,
|
||||||
[this](beast::error_code ec)
|
[this](boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
if (ec)
|
if (ec)
|
||||||
accept();
|
accept();
|
||||||
@ -179,7 +181,7 @@ private:
|
|||||||
http::async_write(
|
http::async_write(
|
||||||
socket_,
|
socket_,
|
||||||
*string_serializer_,
|
*string_serializer_,
|
||||||
[this](beast::error_code ec)
|
[this](boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
socket_.shutdown(tcp::socket::shutdown_send, ec);
|
socket_.shutdown(tcp::socket::shutdown_send, ec);
|
||||||
string_serializer_.reset();
|
string_serializer_.reset();
|
||||||
@ -188,7 +190,7 @@ private:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_file(beast::string_view target)
|
void send_file(boost::beast::string_view target)
|
||||||
{
|
{
|
||||||
// Request path must be absolute and not contain "..".
|
// Request path must be absolute and not contain "..".
|
||||||
if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos)
|
if (target.empty() || target[0] != '/' || target.find("..") != std::string::npos)
|
||||||
@ -205,10 +207,10 @@ private:
|
|||||||
target.size());
|
target.size());
|
||||||
|
|
||||||
http::file_body::value_type file;
|
http::file_body::value_type file;
|
||||||
beast::error_code ec;
|
boost::beast::error_code ec;
|
||||||
file.open(
|
file.open(
|
||||||
full_path.c_str(),
|
full_path.c_str(),
|
||||||
beast::file_mode::read,
|
boost::beast::file_mode::read,
|
||||||
ec);
|
ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
{
|
{
|
||||||
@ -235,7 +237,7 @@ private:
|
|||||||
http::async_write(
|
http::async_write(
|
||||||
socket_,
|
socket_,
|
||||||
*file_serializer_,
|
*file_serializer_,
|
||||||
[this](beast::error_code ec)
|
[this](boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
socket_.shutdown(tcp::socket::shutdown_send, ec);
|
socket_.shutdown(tcp::socket::shutdown_send, ec);
|
||||||
file_serializer_.reset();
|
file_serializer_.reset();
|
||||||
@ -250,7 +252,7 @@ private:
|
|||||||
if (request_deadline_.expires_at() <= std::chrono::steady_clock::now())
|
if (request_deadline_.expires_at() <= std::chrono::steady_clock::now())
|
||||||
{
|
{
|
||||||
// Close socket to cancel any outstanding operation.
|
// Close socket to cancel any outstanding operation.
|
||||||
beast::error_code ec;
|
boost::beast::error_code ec;
|
||||||
socket_.close();
|
socket_.close();
|
||||||
|
|
||||||
// Sleep indefinitely until we're given a new deadline.
|
// Sleep indefinitely until we're given a new deadline.
|
||||||
@ -259,7 +261,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
request_deadline_.async_wait(
|
request_deadline_.async_wait(
|
||||||
[this](beast::error_code)
|
[this](boost::beast::error_code)
|
||||||
{
|
{
|
||||||
check_deadline();
|
check_deadline();
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
GroupSources(include/beast beast)
|
GroupSources(include/boost/beast beast)
|
||||||
|
|
||||||
GroupSources(example/http-server-small "/")
|
GroupSources(example/http-server-small "/")
|
||||||
|
|
||||||
add_executable (http-server-small
|
add_executable (http-server-small
|
||||||
${BEAST_INCLUDES}
|
${BOOST_BEAST_INCLUDES}
|
||||||
|
Jamfile
|
||||||
http_server_small.cpp
|
http_server_small.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
exe http-server-small :
|
exe http-server-small :
|
||||||
http_server_small.cpp
|
http_server_small.cpp
|
||||||
|
@ -4,10 +4,12 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include <beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
#include <beast/http.hpp>
|
#include <boost/beast/http.hpp>
|
||||||
#include <beast/version.hpp>
|
#include <boost/beast/version.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -18,7 +20,7 @@
|
|||||||
|
|
||||||
namespace ip = boost::asio::ip; // from <boost/asio.hpp>
|
namespace ip = boost::asio::ip; // from <boost/asio.hpp>
|
||||||
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
||||||
namespace http = beast::http; // from <beast/http.hpp>
|
namespace http = boost::beast::http; // from <boost/beast/http.hpp>
|
||||||
|
|
||||||
namespace my_program_state
|
namespace my_program_state
|
||||||
{
|
{
|
||||||
@ -57,7 +59,7 @@ private:
|
|||||||
tcp::socket socket_;
|
tcp::socket socket_;
|
||||||
|
|
||||||
// The buffer for performing reads.
|
// The buffer for performing reads.
|
||||||
beast::flat_buffer buffer_{8192};
|
boost::beast::flat_buffer buffer_{8192};
|
||||||
|
|
||||||
// The request message.
|
// The request message.
|
||||||
http::request<http::dynamic_body> request_;
|
http::request<http::dynamic_body> request_;
|
||||||
@ -79,7 +81,7 @@ private:
|
|||||||
socket_,
|
socket_,
|
||||||
buffer_,
|
buffer_,
|
||||||
request_,
|
request_,
|
||||||
[self](beast::error_code ec)
|
[self](boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
if(!ec)
|
if(!ec)
|
||||||
self->process_request();
|
self->process_request();
|
||||||
@ -106,7 +108,7 @@ private:
|
|||||||
// we do not recognize the request method.
|
// we do not recognize the request method.
|
||||||
response_.result(http::status::bad_request);
|
response_.result(http::status::bad_request);
|
||||||
response_.set(http::field::content_type, "text/plain");
|
response_.set(http::field::content_type, "text/plain");
|
||||||
beast::ostream(response_.body)
|
boost::beast::ostream(response_.body)
|
||||||
<< "Invalid request-method '"
|
<< "Invalid request-method '"
|
||||||
<< request_.method_string().to_string()
|
<< request_.method_string().to_string()
|
||||||
<< "'";
|
<< "'";
|
||||||
@ -123,7 +125,7 @@ private:
|
|||||||
if(request_.target() == "/count")
|
if(request_.target() == "/count")
|
||||||
{
|
{
|
||||||
response_.set(http::field::content_type, "text/html");
|
response_.set(http::field::content_type, "text/html");
|
||||||
beast::ostream(response_.body)
|
boost::beast::ostream(response_.body)
|
||||||
<< "<html>\n"
|
<< "<html>\n"
|
||||||
<< "<head><title>Request count</title></head>\n"
|
<< "<head><title>Request count</title></head>\n"
|
||||||
<< "<body>\n"
|
<< "<body>\n"
|
||||||
@ -137,7 +139,7 @@ private:
|
|||||||
else if(request_.target() == "/time")
|
else if(request_.target() == "/time")
|
||||||
{
|
{
|
||||||
response_.set(http::field::content_type, "text/html");
|
response_.set(http::field::content_type, "text/html");
|
||||||
beast::ostream(response_.body)
|
boost::beast::ostream(response_.body)
|
||||||
<< "<html>\n"
|
<< "<html>\n"
|
||||||
<< "<head><title>Current time</title></head>\n"
|
<< "<head><title>Current time</title></head>\n"
|
||||||
<< "<body>\n"
|
<< "<body>\n"
|
||||||
@ -152,7 +154,7 @@ private:
|
|||||||
{
|
{
|
||||||
response_.result(http::status::not_found);
|
response_.result(http::status::not_found);
|
||||||
response_.set(http::field::content_type, "text/plain");
|
response_.set(http::field::content_type, "text/plain");
|
||||||
beast::ostream(response_.body) << "File not found\r\n";
|
boost::beast::ostream(response_.body) << "File not found\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +169,7 @@ private:
|
|||||||
http::async_write(
|
http::async_write(
|
||||||
socket_,
|
socket_,
|
||||||
response_,
|
response_,
|
||||||
[self](beast::error_code ec)
|
[self](boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
self->socket_.shutdown(tcp::socket::shutdown_send, ec);
|
self->socket_.shutdown(tcp::socket::shutdown_send, ec);
|
||||||
self->deadline_.cancel();
|
self->deadline_.cancel();
|
||||||
@ -181,7 +183,7 @@ private:
|
|||||||
auto self = shared_from_this();
|
auto self = shared_from_this();
|
||||||
|
|
||||||
deadline_.async_wait(
|
deadline_.async_wait(
|
||||||
[self](beast::error_code ec)
|
[self](boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
if(!ec)
|
if(!ec)
|
||||||
{
|
{
|
||||||
@ -197,7 +199,7 @@ void
|
|||||||
http_server(tcp::acceptor& acceptor, tcp::socket& socket)
|
http_server(tcp::acceptor& acceptor, tcp::socket& socket)
|
||||||
{
|
{
|
||||||
acceptor.async_accept(socket,
|
acceptor.async_accept(socket,
|
||||||
[&](beast::error_code ec)
|
[&](boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
if(!ec)
|
if(!ec)
|
||||||
std::make_shared<http_connection>(std::move(socket))->start();
|
std::make_shared<http_connection>(std::move(socket))->start();
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
GroupSources(include/beast beast)
|
GroupSources(include/boost/beast beast)
|
||||||
GroupSources(example/common common)
|
GroupSources(example/common common)
|
||||||
GroupSources(example/http-server-threaded "/")
|
GroupSources(example/http-server-threaded "/")
|
||||||
|
|
||||||
add_executable (http-server-threaded
|
add_executable (http-server-threaded
|
||||||
${BEAST_INCLUDES}
|
${BOOST_BEAST_INCLUDES}
|
||||||
${COMMON_INCLUDES}
|
${COMMON_INCLUDES}
|
||||||
|
Jamfile
|
||||||
http_server_threaded.cpp
|
http_server_threaded.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
exe http-server-threaded :
|
exe http-server-threaded :
|
||||||
http_server_threaded.cpp
|
http_server_threaded.cpp
|
||||||
|
@ -4,12 +4,14 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include "../common/mime_types.hpp"
|
#include "../common/mime_types.hpp"
|
||||||
|
|
||||||
#include <beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
#include <beast/http.hpp>
|
#include <boost/beast/http.hpp>
|
||||||
#include <beast/version.hpp>
|
#include <boost/beast/version.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -28,17 +30,17 @@
|
|||||||
|
|
||||||
namespace ip = boost::asio::ip; // from <boost/asio.hpp>
|
namespace ip = boost::asio::ip; // from <boost/asio.hpp>
|
||||||
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
||||||
namespace http = beast::http; // from <beast/http.hpp>
|
namespace http = boost::beast::http; // from <boost/beast/http.hpp>
|
||||||
|
|
||||||
class connection
|
class connection
|
||||||
: public std::enable_shared_from_this<connection>
|
: public std::enable_shared_from_this<connection>
|
||||||
{
|
{
|
||||||
tcp::socket sock_;
|
tcp::socket sock_;
|
||||||
beast::string_view root_;
|
boost::beast::string_view root_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit
|
explicit
|
||||||
connection(tcp::socket&& sock, beast::string_view root)
|
connection(tcp::socket&& sock, boost::beast::string_view root)
|
||||||
: sock_(std::move(sock))
|
: sock_(std::move(sock))
|
||||||
, root_(root)
|
, root_(root)
|
||||||
{
|
{
|
||||||
@ -57,10 +59,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
// Send a client error response
|
// Send a client error response
|
||||||
http::response<http::span_body<char const>>
|
http::response<http::span_body<char const>>
|
||||||
client_error(http::status result, beast::string_view text)
|
client_error(http::status result, boost::beast::string_view text)
|
||||||
{
|
{
|
||||||
http::response<http::span_body<char const>> res{result, 11};
|
http::response<http::span_body<char const>> res{result, 11};
|
||||||
res.set(http::field::server, BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/plain");
|
res.set(http::field::content_type, "text/plain");
|
||||||
res.set(http::field::connection, "close");
|
res.set(http::field::connection, "close");
|
||||||
res.body = text;
|
res.body = text;
|
||||||
@ -74,7 +76,7 @@ private:
|
|||||||
not_found() const
|
not_found() const
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::not_found, 11};
|
http::response<http::string_body> res{http::status::not_found, 11};
|
||||||
res.set(http::field::server, BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.set(http::field::connection, "close");
|
res.set(http::field::connection, "close");
|
||||||
res.body = "The file was not found";
|
res.body = "The file was not found";
|
||||||
@ -85,10 +87,10 @@ private:
|
|||||||
// Return an HTTP Server Error
|
// Return an HTTP Server Error
|
||||||
//
|
//
|
||||||
http::response<http::string_body>
|
http::response<http::string_body>
|
||||||
server_error(beast::error_code const& ec) const
|
server_error(boost::beast::error_code const& ec) const
|
||||||
{
|
{
|
||||||
http::response<http::string_body> res{http::status::internal_server_error, 11};
|
http::response<http::string_body> res{http::status::internal_server_error, 11};
|
||||||
res.set(http::field::server, BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, "text/html");
|
res.set(http::field::content_type, "text/html");
|
||||||
res.set(http::field::connection, "close");
|
res.set(http::field::connection, "close");
|
||||||
res.body = "Error: " + ec.message();
|
res.body = "Error: " + ec.message();
|
||||||
@ -98,15 +100,15 @@ private:
|
|||||||
|
|
||||||
// Return a file response to an HTTP GET request
|
// Return a file response to an HTTP GET request
|
||||||
//
|
//
|
||||||
http::response<beast::http::file_body>
|
http::response<boost::beast::http::file_body>
|
||||||
get(boost::filesystem::path const& full_path,
|
get(boost::filesystem::path const& full_path,
|
||||||
beast::error_code& ec) const
|
boost::beast::error_code& ec) const
|
||||||
{
|
{
|
||||||
http::response<http::file_body> res;
|
http::response<http::file_body> res;
|
||||||
res.set(http::field::server, BEAST_VERSION_STRING);
|
res.set(http::field::server, BOOST_BEAST_VERSION_STRING);
|
||||||
res.set(http::field::content_type, mime_type(full_path));
|
res.set(http::field::content_type, mime_type(full_path));
|
||||||
res.set(http::field::connection, "close");
|
res.set(http::field::connection, "close");
|
||||||
res.body.open(full_path.string<std::string>().c_str(), beast::file_mode::scan, ec);
|
res.body.open(full_path.string<std::string>().c_str(), boost::beast::file_mode::scan, ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
return res;
|
return res;
|
||||||
res.set(http::field::content_length, res.body.size());
|
res.set(http::field::content_length, res.body.size());
|
||||||
@ -116,7 +118,7 @@ private:
|
|||||||
// Handle a request
|
// Handle a request
|
||||||
template<class Body>
|
template<class Body>
|
||||||
void
|
void
|
||||||
do_request(http::request<Body> const& req, beast::error_code& ec)
|
do_request(http::request<Body> const& req, boost::beast::error_code& ec)
|
||||||
{
|
{
|
||||||
// verb must be get
|
// verb must be get
|
||||||
if(req.method() != http::verb::get)
|
if(req.method() != http::verb::get)
|
||||||
@ -137,10 +139,10 @@ private:
|
|||||||
auto full_path = root_.to_string();
|
auto full_path = root_.to_string();
|
||||||
full_path.append(req.target().data(), req.target().size());
|
full_path.append(req.target().data(), req.target().size());
|
||||||
|
|
||||||
beast::error_code file_ec;
|
boost::beast::error_code file_ec;
|
||||||
auto res = get(full_path, file_ec);
|
auto res = get(full_path, file_ec);
|
||||||
|
|
||||||
if(file_ec == beast::errc::no_such_file_or_directory)
|
if(file_ec == boost::beast::errc::no_such_file_or_directory)
|
||||||
{
|
{
|
||||||
http::write(sock_, not_found(), ec);
|
http::write(sock_, not_found(), ec);
|
||||||
}
|
}
|
||||||
@ -160,8 +162,8 @@ private:
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
beast::error_code ec;
|
boost::beast::error_code ec;
|
||||||
beast::flat_buffer buffer;
|
boost::beast::flat_buffer buffer;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
http::request_parser<http::string_body> parser;
|
http::request_parser<http::string_body> parser;
|
||||||
@ -171,18 +173,18 @@ private:
|
|||||||
if(ec == http::error::end_of_stream)
|
if(ec == http::error::end_of_stream)
|
||||||
break;
|
break;
|
||||||
if(ec)
|
if(ec)
|
||||||
throw beast::system_error{ec};
|
throw boost::beast::system_error{ec};
|
||||||
do_request(parser.get(), ec);
|
do_request(parser.get(), ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
{
|
{
|
||||||
if(ec != http::error::end_of_stream)
|
if(ec != http::error::end_of_stream)
|
||||||
throw beast::system_error{ec};
|
throw boost::beast::system_error{ec};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sock_.shutdown(tcp::socket::shutdown_both, ec);
|
sock_.shutdown(tcp::socket::shutdown_both, ec);
|
||||||
if(ec && ec != boost::asio::error::not_connected)
|
if(ec && ec != boost::asio::error::not_connected)
|
||||||
throw beast::system_error{ec};
|
throw boost::beast::system_error{ec};
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
GroupSources(include/beast beast)
|
GroupSources(include/boost/beast beast)
|
||||||
|
|
||||||
GroupSources(example/server-framework "/")
|
GroupSources(example/server-framework "/")
|
||||||
GroupSources(example/common "common")
|
GroupSources(example/common "common")
|
||||||
@ -10,9 +17,10 @@ file(GLOB_RECURSE SERVER_INCLUDES
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_executable (server-framework
|
add_executable (server-framework
|
||||||
${BEAST_INCLUDES}
|
${BOOST_BEAST_INCLUDES}
|
||||||
${COMMON_INCLUDES}
|
${COMMON_INCLUDES}
|
||||||
${SERVER_INCLUDES}
|
${SERVER_INCLUDES}
|
||||||
|
Jamfile
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
exe server-framework :
|
exe server-framework :
|
||||||
main.cpp
|
main.cpp
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<img width="880" height = "80" alt = "Beast"
|
<img width="880" height = "80" alt = "Beast"
|
||||||
src="https://raw.githubusercontent.com/vinniefalco/Beast/master/doc/images/readme.png">
|
src="https://raw.githubusercontent.com/boostorg/beast/master/doc/images/readme.png">
|
||||||
|
|
||||||
# HTTP and WebSocket built on Boost.Asio in C++11
|
# HTTP and WebSocket built on Boost.Asio in C++11
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ ports created in the example program, and the HTTP services contained by
|
|||||||
the HTTP ports:
|
the HTTP ports:
|
||||||
|
|
||||||
<img width="880" height = "344" alt = "ServerFramework"
|
<img width="880" height = "344" alt = "ServerFramework"
|
||||||
src="https://raw.githubusercontent.com/vinniefalco/Beast/master/doc/images/server.png">
|
src="https://raw.githubusercontent.com/boostorg/beast/master/doc/images/server.png">
|
||||||
|
|
||||||
## PortHandler Requirements
|
## PortHandler Requirements
|
||||||
```C++
|
```C++
|
||||||
|
@ -4,18 +4,20 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_FILE_SERVICE_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_FILE_SERVICE_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_FILE_SERVICE_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_FILE_SERVICE_HPP
|
||||||
|
|
||||||
#include "framework.hpp"
|
#include "framework.hpp"
|
||||||
#include "../common/mime_types.hpp"
|
#include "../common/mime_types.hpp"
|
||||||
|
|
||||||
#include <beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
#include <beast/http/empty_body.hpp>
|
#include <boost/beast/http/empty_body.hpp>
|
||||||
#include <beast/http/file_body.hpp>
|
#include <boost/beast/http/file_body.hpp>
|
||||||
#include <beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
#include <beast/http/string_body.hpp>
|
#include <boost/beast/http/string_body.hpp>
|
||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
@ -51,7 +53,7 @@ public:
|
|||||||
explicit
|
explicit
|
||||||
file_service(
|
file_service(
|
||||||
boost::filesystem::path const& root,
|
boost::filesystem::path const& root,
|
||||||
beast::string_view server)
|
boost::beast::string_view server)
|
||||||
: root_(root)
|
: root_(root)
|
||||||
, server_(server)
|
, server_(server)
|
||||||
{
|
{
|
||||||
@ -109,7 +111,7 @@ public:
|
|||||||
respond(
|
respond(
|
||||||
Stream&&,
|
Stream&&,
|
||||||
endpoint_type const& ep,
|
endpoint_type const& ep,
|
||||||
beast::http::request<Body, Fields>&& req,
|
boost::beast::http::request<Body, Fields>&& req,
|
||||||
Send const& send) const
|
Send const& send) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused(ep);
|
boost::ignore_unused(ep);
|
||||||
@ -117,7 +119,7 @@ public:
|
|||||||
// Determine our action based on the method
|
// Determine our action based on the method
|
||||||
switch(req.method())
|
switch(req.method())
|
||||||
{
|
{
|
||||||
case beast::http::verb::get:
|
case boost::beast::http::verb::get:
|
||||||
{
|
{
|
||||||
// For GET requests we deliver the actual file
|
// For GET requests we deliver the actual file
|
||||||
boost::filesystem::path rel_path(req.target().to_string());
|
boost::filesystem::path rel_path(req.target().to_string());
|
||||||
@ -129,10 +131,10 @@ public:
|
|||||||
// Calculate full path from root
|
// Calculate full path from root
|
||||||
boost::filesystem::path full_path = root_ / rel_path;
|
boost::filesystem::path full_path = root_ / rel_path;
|
||||||
|
|
||||||
beast::error_code ec;
|
boost::beast::error_code ec;
|
||||||
auto res = get(req, full_path, ec);
|
auto res = get(req, full_path, ec);
|
||||||
|
|
||||||
if(ec == beast::errc::no_such_file_or_directory)
|
if(ec == boost::beast::errc::no_such_file_or_directory)
|
||||||
{
|
{
|
||||||
send(not_found(req, rel_path));
|
send(not_found(req, rel_path));
|
||||||
}
|
}
|
||||||
@ -149,7 +151,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
case beast::http::verb::head:
|
case boost::beast::http::verb::head:
|
||||||
{
|
{
|
||||||
// We are just going to give them the headers they
|
// We are just going to give them the headers they
|
||||||
// would otherwise get, but without the body.
|
// would otherwise get, but without the body.
|
||||||
@ -160,10 +162,10 @@ public:
|
|||||||
// Calculate full path from root
|
// Calculate full path from root
|
||||||
boost::filesystem::path full_path = root_ / rel_path;
|
boost::filesystem::path full_path = root_ / rel_path;
|
||||||
|
|
||||||
beast::error_code ec;
|
boost::beast::error_code ec;
|
||||||
auto res = head(req, full_path, ec);
|
auto res = head(req, full_path, ec);
|
||||||
|
|
||||||
if(ec == beast::errc::no_such_file_or_directory)
|
if(ec == boost::beast::errc::no_such_file_or_directory)
|
||||||
{
|
{
|
||||||
send(not_found(req, rel_path));
|
send(not_found(req, rel_path));
|
||||||
}
|
}
|
||||||
@ -194,17 +196,17 @@ private:
|
|||||||
// Return an HTTP Not Found response
|
// Return an HTTP Not Found response
|
||||||
//
|
//
|
||||||
template<class Body, class Fields>
|
template<class Body, class Fields>
|
||||||
beast::http::response<beast::http::string_body>
|
boost::beast::http::response<boost::beast::http::string_body>
|
||||||
not_found(
|
not_found(
|
||||||
beast::http::request<Body, Fields> const& req,
|
boost::beast::http::request<Body, Fields> const& req,
|
||||||
boost::filesystem::path const& rel_path) const
|
boost::filesystem::path const& rel_path) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused(rel_path);
|
boost::ignore_unused(rel_path);
|
||||||
beast::http::response<beast::http::string_body> res;
|
boost::beast::http::response<boost::beast::http::string_body> res;
|
||||||
res.version = req.version;
|
res.version = req.version;
|
||||||
res.result(beast::http::status::not_found);
|
res.result(boost::beast::http::status::not_found);
|
||||||
res.set(beast::http::field::server, server_);
|
res.set(boost::beast::http::field::server, server_);
|
||||||
res.set(beast::http::field::content_type, "text/html");
|
res.set(boost::beast::http::field::content_type, "text/html");
|
||||||
res.body = "The file was not found"; // VFALCO append rel_path
|
res.body = "The file was not found"; // VFALCO append rel_path
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
@ -213,18 +215,18 @@ private:
|
|||||||
// Return an HTTP Server Error
|
// Return an HTTP Server Error
|
||||||
//
|
//
|
||||||
template<class Body, class Fields>
|
template<class Body, class Fields>
|
||||||
beast::http::response<beast::http::string_body>
|
boost::beast::http::response<boost::beast::http::string_body>
|
||||||
server_error(
|
server_error(
|
||||||
beast::http::request<Body, Fields> const& req,
|
boost::beast::http::request<Body, Fields> const& req,
|
||||||
boost::filesystem::path const& rel_path,
|
boost::filesystem::path const& rel_path,
|
||||||
error_code const& ec) const
|
error_code const& ec) const
|
||||||
{
|
{
|
||||||
boost::ignore_unused(rel_path);
|
boost::ignore_unused(rel_path);
|
||||||
beast::http::response<beast::http::string_body> res;
|
boost::beast::http::response<boost::beast::http::string_body> res;
|
||||||
res.version = req.version;
|
res.version = req.version;
|
||||||
res.result(beast::http::status::internal_server_error);
|
res.result(boost::beast::http::status::internal_server_error);
|
||||||
res.set(beast::http::field::server, server_);
|
res.set(boost::beast::http::field::server, server_);
|
||||||
res.set(beast::http::field::content_type, "text/html");
|
res.set(boost::beast::http::field::content_type, "text/html");
|
||||||
res.body = "Error: " + ec.message();
|
res.body = "Error: " + ec.message();
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
@ -233,43 +235,43 @@ private:
|
|||||||
// Return a file response to an HTTP GET request
|
// Return a file response to an HTTP GET request
|
||||||
//
|
//
|
||||||
template<class Body, class Fields>
|
template<class Body, class Fields>
|
||||||
boost::optional<beast::http::response<beast::http::file_body>>
|
boost::optional<boost::beast::http::response<boost::beast::http::file_body>>
|
||||||
get(
|
get(
|
||||||
beast::http::request<Body, Fields> const& req,
|
boost::beast::http::request<Body, Fields> const& req,
|
||||||
boost::filesystem::path const& full_path,
|
boost::filesystem::path const& full_path,
|
||||||
beast::error_code& ec) const
|
boost::beast::error_code& ec) const
|
||||||
{
|
{
|
||||||
beast::http::response<beast::http::file_body> res;
|
boost::beast::http::response<boost::beast::http::file_body> res;
|
||||||
res.version = req.version;
|
res.version = req.version;
|
||||||
res.set(beast::http::field::server, server_);
|
res.set(boost::beast::http::field::server, server_);
|
||||||
res.set(beast::http::field::content_type, mime_type(full_path));
|
res.set(boost::beast::http::field::content_type, mime_type(full_path));
|
||||||
res.body.open(full_path.string<std::string>().c_str(), beast::file_mode::scan, ec);
|
res.body.open(full_path.string<std::string>().c_str(), boost::beast::file_mode::scan, ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
return boost::none;
|
return boost::none;
|
||||||
res.set(beast::http::field::content_length, res.body.size());
|
res.set(boost::beast::http::field::content_length, res.body.size());
|
||||||
return {std::move(res)};
|
return {std::move(res)};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a response to an HTTP HEAD request
|
// Return a response to an HTTP HEAD request
|
||||||
//
|
//
|
||||||
template<class Body, class Fields>
|
template<class Body, class Fields>
|
||||||
boost::optional<beast::http::response<beast::http::empty_body>>
|
boost::optional<boost::beast::http::response<boost::beast::http::empty_body>>
|
||||||
head(
|
head(
|
||||||
beast::http::request<Body, Fields> const& req,
|
boost::beast::http::request<Body, Fields> const& req,
|
||||||
boost::filesystem::path const& full_path,
|
boost::filesystem::path const& full_path,
|
||||||
beast::error_code& ec) const
|
boost::beast::error_code& ec) const
|
||||||
{
|
{
|
||||||
beast::http::response<beast::http::empty_body> res;
|
boost::beast::http::response<boost::beast::http::empty_body> res;
|
||||||
res.version = req.version;
|
res.version = req.version;
|
||||||
res.set(beast::http::field::server, server_);
|
res.set(boost::beast::http::field::server, server_);
|
||||||
res.set(beast::http::field::content_type, mime_type(full_path));
|
res.set(boost::beast::http::field::content_type, mime_type(full_path));
|
||||||
|
|
||||||
// Use a manual file body here
|
// Use a manual file body here
|
||||||
beast::http::file_body::value_type body;
|
boost::beast::http::file_body::value_type body;
|
||||||
body.open(full_path.string<std::string>().c_str(), beast::file_mode::scan, ec);
|
body.open(full_path.string<std::string>().c_str(), boost::beast::file_mode::scan, ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
return boost::none;
|
return boost::none;
|
||||||
res.set(beast::http::field::content_length, body.size());
|
res.set(boost::beast::http::field::content_length, body.size());
|
||||||
return {std::move(res)};
|
return {std::move(res)};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_FRAMEWORK_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_FRAMEWORK_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_FRAMEWORK_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_FRAMEWORK_HPP
|
||||||
|
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <boost/asio/strand.hpp>
|
#include <boost/asio/strand.hpp>
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_HTTP_ASYNC_PORT_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_HTTP_ASYNC_PORT_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_HTTP_ASYNC_PORT_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_HTTP_ASYNC_PORT_HPP
|
||||||
|
|
||||||
#include "server.hpp"
|
#include "server.hpp"
|
||||||
|
|
||||||
@ -16,12 +18,12 @@
|
|||||||
#include "../common/rfc7231.hpp"
|
#include "../common/rfc7231.hpp"
|
||||||
#include "../common/write_msg.hpp"
|
#include "../common/write_msg.hpp"
|
||||||
|
|
||||||
#include <beast/core/flat_buffer.hpp>
|
#include <boost/beast/core/flat_buffer.hpp>
|
||||||
#include <beast/http/dynamic_body.hpp>
|
#include <boost/beast/http/dynamic_body.hpp>
|
||||||
#include <beast/http/parser.hpp>
|
#include <boost/beast/http/parser.hpp>
|
||||||
#include <beast/http/read.hpp>
|
#include <boost/beast/http/read.hpp>
|
||||||
#include <beast/http/string_body.hpp>
|
#include <boost/beast/http/string_body.hpp>
|
||||||
#include <beast/http/write.hpp>
|
#include <boost/beast/http/write.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@ -57,7 +59,7 @@ class queued_http_write_impl : public queued_http_write
|
|||||||
Stream& stream_;
|
Stream& stream_;
|
||||||
|
|
||||||
// The message to send, which we acquire by move or copy
|
// The message to send, which we acquire by move or copy
|
||||||
beast::http::message<isRequest, Body, Fields> msg_;
|
boost::beast::http::message<isRequest, Body, Fields> msg_;
|
||||||
|
|
||||||
// The handler to invoke when the send completes.
|
// The handler to invoke when the send completes.
|
||||||
Handler handler_;
|
Handler handler_;
|
||||||
@ -70,7 +72,7 @@ public:
|
|||||||
template<class DeducedHandler>
|
template<class DeducedHandler>
|
||||||
queued_http_write_impl(
|
queued_http_write_impl(
|
||||||
Stream& stream,
|
Stream& stream,
|
||||||
beast::http::message<isRequest, Body, Fields>&& msg,
|
boost::beast::http::message<isRequest, Body, Fields>&& msg,
|
||||||
DeducedHandler&& handler)
|
DeducedHandler&& handler)
|
||||||
: stream_(stream)
|
: stream_(stream)
|
||||||
, msg_(std::move(msg))
|
, msg_(std::move(msg))
|
||||||
@ -105,7 +107,7 @@ template<
|
|||||||
std::unique_ptr<queued_http_write>
|
std::unique_ptr<queued_http_write>
|
||||||
make_queued_http_write(
|
make_queued_http_write(
|
||||||
Stream& stream,
|
Stream& stream,
|
||||||
beast::http::message<isRequest, Body, Fields>&& msg,
|
boost::beast::http::message<isRequest, Body, Fields>&& msg,
|
||||||
Handler&& handler)
|
Handler&& handler)
|
||||||
{
|
{
|
||||||
return std::unique_ptr<queued_http_write>{
|
return std::unique_ptr<queued_http_write>{
|
||||||
@ -158,10 +160,10 @@ protected:
|
|||||||
endpoint_type ep_;
|
endpoint_type ep_;
|
||||||
|
|
||||||
// The buffer for performing reads
|
// The buffer for performing reads
|
||||||
beast::flat_buffer buffer_;
|
boost::beast::flat_buffer buffer_;
|
||||||
|
|
||||||
// The parser for reading the requests
|
// The parser for reading the requests
|
||||||
boost::optional<beast::http::request_parser<beast::http::dynamic_body>> parser_;
|
boost::optional<boost::beast::http::request_parser<boost::beast::http::dynamic_body>> parser_;
|
||||||
|
|
||||||
// This is the queue of outgoing messages
|
// This is the queue of outgoing messages
|
||||||
std::vector<std::unique_ptr<queued_http_write>> queue_;
|
std::vector<std::unique_ptr<queued_http_write>> queue_;
|
||||||
@ -177,7 +179,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
async_http_con_base(
|
async_http_con_base(
|
||||||
beast::string_view server_name,
|
boost::beast::string_view server_name,
|
||||||
std::ostream& log,
|
std::ostream& log,
|
||||||
service_list<Services...> const& services,
|
service_list<Services...> const& services,
|
||||||
std::size_t id,
|
std::size_t id,
|
||||||
@ -267,7 +269,7 @@ protected:
|
|||||||
parser_.emplace(std::piecewise_construct, std::make_tuple(1024 * 1024));
|
parser_.emplace(std::piecewise_construct, std::make_tuple(1024 * 1024));
|
||||||
|
|
||||||
// Read just the header
|
// Read just the header
|
||||||
beast::http::async_read_header(
|
boost::beast::http::async_read_header(
|
||||||
impl().stream(),
|
impl().stream(),
|
||||||
buffer_,
|
buffer_,
|
||||||
*parser_,
|
*parser_,
|
||||||
@ -299,7 +301,7 @@ protected:
|
|||||||
// sends a message
|
// sends a message
|
||||||
template<class Body, class Fields>
|
template<class Body, class Fields>
|
||||||
void
|
void
|
||||||
operator()(beast::http::response<Body, Fields>&& res) const
|
operator()(boost::beast::http::response<Body, Fields>&& res) const
|
||||||
{
|
{
|
||||||
self_.do_write(std::move(res));
|
self_.do_write(std::move(res));
|
||||||
}
|
}
|
||||||
@ -311,7 +313,7 @@ protected:
|
|||||||
{
|
{
|
||||||
// This happens when the other end closes gracefully
|
// This happens when the other end closes gracefully
|
||||||
//
|
//
|
||||||
if(ec == beast::http::error::end_of_stream)
|
if(ec == boost::beast::http::error::end_of_stream)
|
||||||
{
|
{
|
||||||
// VFALCO what about the write queue?
|
// VFALCO what about the write queue?
|
||||||
return impl().do_shutdown();
|
return impl().do_shutdown();
|
||||||
@ -342,7 +344,7 @@ protected:
|
|||||||
|
|
||||||
// Read the rest of the message, if any.
|
// Read the rest of the message, if any.
|
||||||
//
|
//
|
||||||
beast::http::async_read(
|
boost::beast::http::async_read(
|
||||||
impl().stream(),
|
impl().stream(),
|
||||||
buffer_,
|
buffer_,
|
||||||
*parser_,
|
*parser_,
|
||||||
@ -413,7 +415,7 @@ protected:
|
|||||||
//
|
//
|
||||||
template<class Body, class Fields>
|
template<class Body, class Fields>
|
||||||
void
|
void
|
||||||
do_write(beast::http::response<Body, Fields>&& res)
|
do_write(boost::beast::http::response<Body, Fields>&& res)
|
||||||
{
|
{
|
||||||
// See if a write is in progress
|
// See if a write is in progress
|
||||||
if(! writing_)
|
if(! writing_)
|
||||||
@ -459,7 +461,7 @@ protected:
|
|||||||
// should be closed afterwards. For example if
|
// should be closed afterwards. For example if
|
||||||
// we send a Connection: close.
|
// we send a Connection: close.
|
||||||
//
|
//
|
||||||
if(ec == beast::http::error::end_of_stream)
|
if(ec == boost::beast::http::error::end_of_stream)
|
||||||
return impl().do_shutdown();
|
return impl().do_shutdown();
|
||||||
|
|
||||||
// On failure just log and return
|
// On failure just log and return
|
||||||
@ -565,7 +567,7 @@ private:
|
|||||||
// not_connected happens under normal
|
// not_connected happens under normal
|
||||||
// circumstances so don't bother reporting it.
|
// circumstances so don't bother reporting it.
|
||||||
//
|
//
|
||||||
if(ec && ec != beast::errc::not_connected)
|
if(ec && ec != boost::beast::errc::not_connected)
|
||||||
return this->fail("shutdown", ec);
|
return this->fail("shutdown", ec);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_HTTP_BASE_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_HTTP_BASE_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_HTTP_BASE_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_HTTP_BASE_HPP
|
||||||
|
|
||||||
#include <beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
#include <beast/http/empty_body.hpp>
|
#include <boost/beast/http/empty_body.hpp>
|
||||||
#include <beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
#include <beast/http/string_body.hpp>
|
#include <boost/beast/http/string_body.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@ -25,11 +27,11 @@ namespace framework {
|
|||||||
*/
|
*/
|
||||||
class http_base
|
class http_base
|
||||||
{
|
{
|
||||||
beast::string_view server_name_;
|
boost::beast::string_view server_name_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit
|
explicit
|
||||||
http_base(beast::string_view server_name)
|
http_base(boost::beast::string_view server_name)
|
||||||
: server_name_(server_name)
|
: server_name_(server_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -38,17 +40,17 @@ protected:
|
|||||||
// Returns a bad request result response
|
// Returns a bad request result response
|
||||||
//
|
//
|
||||||
template<class Body, class Fields>
|
template<class Body, class Fields>
|
||||||
beast::http::response<beast::http::string_body>
|
boost::beast::http::response<boost::beast::http::string_body>
|
||||||
bad_request(beast::http::request<Body, Fields> const& req) const
|
bad_request(boost::beast::http::request<Body, Fields> const& req) const
|
||||||
{
|
{
|
||||||
beast::http::response<beast::http::string_body> res;
|
boost::beast::http::response<boost::beast::http::string_body> res;
|
||||||
|
|
||||||
// Match the version to the request
|
// Match the version to the request
|
||||||
res.version = req.version;
|
res.version = req.version;
|
||||||
|
|
||||||
res.result(beast::http::status::bad_request);
|
res.result(boost::beast::http::status::bad_request);
|
||||||
res.set(beast::http::field::server, server_name_);
|
res.set(boost::beast::http::field::server, server_name_);
|
||||||
res.set(beast::http::field::content_type, "text/html");
|
res.set(boost::beast::http::field::content_type, "text/html");
|
||||||
res.body = "Bad request";
|
res.body = "Bad request";
|
||||||
res.prepare_payload();
|
res.prepare_payload();
|
||||||
return res;
|
return res;
|
||||||
@ -57,16 +59,16 @@ protected:
|
|||||||
// Returns a 100 Continue result response
|
// Returns a 100 Continue result response
|
||||||
//
|
//
|
||||||
template<class Body, class Fields>
|
template<class Body, class Fields>
|
||||||
beast::http::response<beast::http::empty_body>
|
boost::beast::http::response<boost::beast::http::empty_body>
|
||||||
continue_100(beast::http::request<Body, Fields> const& req) const
|
continue_100(boost::beast::http::request<Body, Fields> const& req) const
|
||||||
{
|
{
|
||||||
beast::http::response<beast::http::empty_body> res;
|
boost::beast::http::response<boost::beast::http::empty_body> res;
|
||||||
|
|
||||||
// Match the version to the request
|
// Match the version to the request
|
||||||
res.version = req.version;
|
res.version = req.version;
|
||||||
|
|
||||||
res.result(beast::http::status::continue_);
|
res.result(boost::beast::http::status::continue_);
|
||||||
res.set(beast::http::field::server, server_name_);
|
res.set(boost::beast::http::field::server, server_name_);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_HTTP_SYNC_PORT_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_HTTP_SYNC_PORT_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_HTTP_SYNC_PORT_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_HTTP_SYNC_PORT_HPP
|
||||||
|
|
||||||
#include "server.hpp"
|
#include "server.hpp"
|
||||||
|
|
||||||
@ -16,13 +18,13 @@
|
|||||||
#include "../common/rfc7231.hpp"
|
#include "../common/rfc7231.hpp"
|
||||||
#include "../common/write_msg.hpp"
|
#include "../common/write_msg.hpp"
|
||||||
|
|
||||||
#include <beast/core/flat_buffer.hpp>
|
#include <boost/beast/core/flat_buffer.hpp>
|
||||||
#include <beast/core/handler_ptr.hpp>
|
#include <boost/beast/core/handler_ptr.hpp>
|
||||||
#include <beast/http/dynamic_body.hpp>
|
#include <boost/beast/http/dynamic_body.hpp>
|
||||||
#include <beast/http/parser.hpp>
|
#include <boost/beast/http/parser.hpp>
|
||||||
#include <beast/http/read.hpp>
|
#include <boost/beast/http/read.hpp>
|
||||||
#include <beast/http/string_body.hpp>
|
#include <boost/beast/http/string_body.hpp>
|
||||||
#include <beast/http/write.hpp>
|
#include <boost/beast/http/write.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@ -68,12 +70,12 @@ class sync_http_con_base
|
|||||||
endpoint_type ep_;
|
endpoint_type ep_;
|
||||||
|
|
||||||
// The buffer for performing reads
|
// The buffer for performing reads
|
||||||
beast::flat_buffer buffer_;
|
boost::beast::flat_buffer buffer_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
sync_http_con_base(
|
sync_http_con_base(
|
||||||
beast::string_view server_name,
|
boost::beast::string_view server_name,
|
||||||
std::ostream& log,
|
std::ostream& log,
|
||||||
service_list<Services...> const& services,
|
service_list<Services...> const& services,
|
||||||
std::size_t id,
|
std::size_t id,
|
||||||
@ -155,10 +157,10 @@ private:
|
|||||||
template<class Body, class Fields>
|
template<class Body, class Fields>
|
||||||
void
|
void
|
||||||
operator()(
|
operator()(
|
||||||
beast::http::response<Body, Fields>&& res) const
|
boost::beast::http::response<Body, Fields>&& res) const
|
||||||
{
|
{
|
||||||
beast::http::serializer<false, Body, Fields> sr{res};
|
boost::beast::http::serializer<false, Body, Fields> sr{res};
|
||||||
beast::http::write(self_.impl().stream(), sr, ec_);
|
boost::beast::http::write(self_.impl().stream(), sr, ec_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -189,19 +191,19 @@ private:
|
|||||||
// We construct the dynamic body with a 1MB limit
|
// We construct the dynamic body with a 1MB limit
|
||||||
// to prevent vulnerability to buffer attacks.
|
// to prevent vulnerability to buffer attacks.
|
||||||
//
|
//
|
||||||
beast::http::request_parser<beast::http::dynamic_body> parser(
|
boost::beast::http::request_parser<boost::beast::http::dynamic_body> parser(
|
||||||
std::piecewise_construct, std::make_tuple(1024* 1024));
|
std::piecewise_construct, std::make_tuple(1024* 1024));
|
||||||
|
|
||||||
// Read the header first
|
// Read the header first
|
||||||
beast::http::read_header(impl().stream(), buffer_, parser, ec);
|
boost::beast::http::read_header(impl().stream(), buffer_, parser, ec);
|
||||||
|
|
||||||
// This happens when the other end closes gracefully
|
// This happens when the other end closes gracefully
|
||||||
//
|
//
|
||||||
if(ec == beast::http::error::end_of_stream)
|
if(ec == boost::beast::http::error::end_of_stream)
|
||||||
{
|
{
|
||||||
// Give the derived class a chance to do stuff
|
// Give the derived class a chance to do stuff
|
||||||
impl().do_shutdown(ec);
|
impl().do_shutdown(ec);
|
||||||
if(ec && ec != beast::errc::not_connected)
|
if(ec && ec != boost::beast::errc::not_connected)
|
||||||
return fail("shutdown", ec);
|
return fail("shutdown", ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -228,11 +230,11 @@ private:
|
|||||||
// should be closed afterwards. For example if
|
// should be closed afterwards. For example if
|
||||||
// we send a Connection: close.
|
// we send a Connection: close.
|
||||||
//
|
//
|
||||||
if(ec == beast::http::error::end_of_stream)
|
if(ec == boost::beast::http::error::end_of_stream)
|
||||||
{
|
{
|
||||||
// Give the derived class a chance to do stuff
|
// Give the derived class a chance to do stuff
|
||||||
impl().do_shutdown(ec);
|
impl().do_shutdown(ec);
|
||||||
if(ec && ec != beast::errc::not_connected)
|
if(ec && ec != boost::beast::errc::not_connected)
|
||||||
return fail("shutdown", ec);
|
return fail("shutdown", ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -245,7 +247,7 @@ private:
|
|||||||
|
|
||||||
// Read the rest of the message, if any.
|
// Read the rest of the message, if any.
|
||||||
//
|
//
|
||||||
beast::http::read(impl().stream(), buffer_, parser, ec);
|
boost::beast::http::read(impl().stream(), buffer_, parser, ec);
|
||||||
|
|
||||||
// Shouldn't be getting end_of_stream here;
|
// Shouldn't be getting end_of_stream here;
|
||||||
// that would mean that we got an incomplete
|
// that would mean that we got an incomplete
|
||||||
@ -272,11 +274,11 @@ private:
|
|||||||
// should be closed afterwards. For example if
|
// should be closed afterwards. For example if
|
||||||
// we send a Connection: close.
|
// we send a Connection: close.
|
||||||
//
|
//
|
||||||
if(ec == beast::http::error::end_of_stream)
|
if(ec == boost::beast::http::error::end_of_stream)
|
||||||
{
|
{
|
||||||
// Give the derived class a chance to do stuff
|
// Give the derived class a chance to do stuff
|
||||||
impl().do_shutdown(ec);
|
impl().do_shutdown(ec);
|
||||||
if(ec && ec != beast::errc::not_connected)
|
if(ec && ec != boost::beast::errc::not_connected)
|
||||||
return fail("shutdown", ec);
|
return fail("shutdown", ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -293,10 +295,10 @@ private:
|
|||||||
// should be closed afterwards. For example if
|
// should be closed afterwards. For example if
|
||||||
// we send a Connection: close.
|
// we send a Connection: close.
|
||||||
//
|
//
|
||||||
if(ec == beast::http::error::end_of_stream)
|
if(ec == boost::beast::http::error::end_of_stream)
|
||||||
{
|
{
|
||||||
// Give the derived class a chance to do stuff
|
// Give the derived class a chance to do stuff
|
||||||
if(ec && ec != beast::errc::not_connected)
|
if(ec && ec != boost::beast::errc::not_connected)
|
||||||
return fail("shutdown", ec);
|
return fail("shutdown", ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_HTTPS_PORTS_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_HTTPS_PORTS_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_HTTPS_PORTS_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_HTTPS_PORTS_HPP
|
||||||
|
|
||||||
#include "http_sync_port.hpp"
|
#include "http_sync_port.hpp"
|
||||||
#include "http_async_port.hpp"
|
#include "http_async_port.hpp"
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include "server.hpp"
|
#include "server.hpp"
|
||||||
|
|
||||||
@ -12,7 +14,7 @@
|
|||||||
#include "ws_async_port.hpp"
|
#include "ws_async_port.hpp"
|
||||||
#include "ws_sync_port.hpp"
|
#include "ws_sync_port.hpp"
|
||||||
|
|
||||||
#if BEAST_USE_OPENSSL
|
#if BOOST_BEAST_USE_OPENSSL
|
||||||
#include "https_ports.hpp"
|
#include "https_ports.hpp"
|
||||||
#include "multi_port.hpp"
|
#include "multi_port.hpp"
|
||||||
#include "wss_ports.hpp"
|
#include "wss_ports.hpp"
|
||||||
@ -58,17 +60,17 @@ sig_wait()
|
|||||||
*/
|
*/
|
||||||
class set_ws_options
|
class set_ws_options
|
||||||
{
|
{
|
||||||
beast::websocket::permessage_deflate pmd_;
|
boost::beast::websocket::permessage_deflate pmd_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
set_ws_options(beast::websocket::permessage_deflate const& pmd)
|
set_ws_options(boost::beast::websocket::permessage_deflate const& pmd)
|
||||||
: pmd_(pmd)
|
: pmd_(pmd)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
void
|
void
|
||||||
operator()(beast::websocket::stream<NextLayer>& ws) const
|
operator()(boost::beast::websocket::stream<NextLayer>& ws) const
|
||||||
{
|
{
|
||||||
ws.auto_fragment(false);
|
ws.auto_fragment(false);
|
||||||
ws.set_option(pmd_);
|
ws.set_option(pmd_);
|
||||||
@ -82,7 +84,7 @@ main(
|
|||||||
char const* av[])
|
char const* av[])
|
||||||
{
|
{
|
||||||
using namespace framework;
|
using namespace framework;
|
||||||
using namespace beast::http;
|
using namespace boost::beast::http;
|
||||||
|
|
||||||
// Helper for reporting failures
|
// Helper for reporting failures
|
||||||
//
|
//
|
||||||
@ -131,7 +133,7 @@ main(
|
|||||||
boost::filesystem::path const root = vm["root"].as<std::string>();
|
boost::filesystem::path const root = vm["root"].as<std::string>();
|
||||||
|
|
||||||
// These settings will be applied to all new websocket connections
|
// These settings will be applied to all new websocket connections
|
||||||
beast::websocket::permessage_deflate pmd;
|
boost::beast::websocket::permessage_deflate pmd;
|
||||||
pmd.client_enable = true;
|
pmd.client_enable = true;
|
||||||
pmd.server_enable = true;
|
pmd.server_enable = true;
|
||||||
pmd.compLevel = 3;
|
pmd.compLevel = 3;
|
||||||
@ -263,7 +265,7 @@ main(
|
|||||||
// an installed and configured OpenSSL as part of the build.
|
// an installed and configured OpenSSL as part of the build.
|
||||||
//
|
//
|
||||||
|
|
||||||
#if BEAST_USE_OPENSSL
|
#if BOOST_BEAST_USE_OPENSSL
|
||||||
|
|
||||||
ssl_certificate cert;
|
ssl_certificate cert;
|
||||||
|
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_MULTI_PORT_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_MULTI_PORT_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_MULTI_PORT_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_MULTI_PORT_HPP
|
||||||
|
|
||||||
#include "ws_async_port.hpp"
|
#include "ws_async_port.hpp"
|
||||||
#include "http_async_port.hpp"
|
#include "http_async_port.hpp"
|
||||||
@ -15,7 +17,7 @@
|
|||||||
|
|
||||||
#include "../common/detect_ssl.hpp"
|
#include "../common/detect_ssl.hpp"
|
||||||
|
|
||||||
#include <beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
|
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
|
|
||||||
@ -54,7 +56,7 @@ class multi_con
|
|||||||
boost::asio::ssl::context& ctx_;
|
boost::asio::ssl::context& ctx_;
|
||||||
|
|
||||||
// Holds the data we read during ssl detection
|
// Holds the data we read during ssl detection
|
||||||
beast::flat_static_buffer<6> buffer_;
|
boost::beast::flat_static_buffer<6> buffer_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
@ -181,7 +183,7 @@ private:
|
|||||||
// not_connected happens under normal
|
// not_connected happens under normal
|
||||||
// circumstances so don't bother reporting it.
|
// circumstances so don't bother reporting it.
|
||||||
//
|
//
|
||||||
if(ec && ec != beast::errc::not_connected)
|
if(ec && ec != boost::beast::errc::not_connected)
|
||||||
return this->fail("shutdown", ec);
|
return this->fail("shutdown", ec);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -213,8 +215,8 @@ protected:
|
|||||||
// crash with gcc and clang using libstdc++
|
// crash with gcc and clang using libstdc++
|
||||||
|
|
||||||
// The types of the on_stream callback
|
// The types of the on_stream callback
|
||||||
using on_new_stream_cb1 = boost::function<void(beast::websocket::stream<socket_type>&)>;
|
using on_new_stream_cb1 = boost::function<void(boost::beast::websocket::stream<socket_type>&)>;
|
||||||
using on_new_stream_cb2 = boost::function<void(beast::websocket::stream<ssl_stream<socket_type>>&)>;
|
using on_new_stream_cb2 = boost::function<void(boost::beast::websocket::stream<ssl_stream<socket_type>>&)>;
|
||||||
|
|
||||||
// Reference to the server instance that made us
|
// Reference to the server instance that made us
|
||||||
server& instance_;
|
server& instance_;
|
||||||
@ -244,7 +246,7 @@ public:
|
|||||||
should have this equivalent signature:
|
should have this equivalent signature:
|
||||||
@code
|
@code
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
void callback(beast::websocket::stream<NextLayer>&);
|
void callback(boost::beast::websocket::stream<NextLayer>&);
|
||||||
@endcode
|
@endcode
|
||||||
In C++14 this can be accomplished with a generic lambda. In
|
In C++14 this can be accomplished with a generic lambda. In
|
||||||
C++11 it will be necessary to write out a lambda manually,
|
C++11 it will be necessary to write out a lambda manually,
|
||||||
@ -280,7 +282,7 @@ public:
|
|||||||
on_upgrade(
|
on_upgrade(
|
||||||
socket_type&& sock,
|
socket_type&& sock,
|
||||||
endpoint_type ep,
|
endpoint_type ep,
|
||||||
beast::http::request<Body>&& req)
|
boost::beast::http::request<Body>&& req)
|
||||||
{
|
{
|
||||||
// Create the connection and call the version of
|
// Create the connection and call the version of
|
||||||
// run that takes the request since we have it already
|
// run that takes the request since we have it already
|
||||||
@ -311,7 +313,7 @@ public:
|
|||||||
on_upgrade(
|
on_upgrade(
|
||||||
ssl_stream<socket_type>&& stream,
|
ssl_stream<socket_type>&& stream,
|
||||||
endpoint_type ep,
|
endpoint_type ep,
|
||||||
beast::http::request<Body>&& req)
|
boost::beast::http::request<Body>&& req)
|
||||||
{
|
{
|
||||||
std::make_shared<async_wss_con>(
|
std::make_shared<async_wss_con>(
|
||||||
std::move(stream),
|
std::move(stream),
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_FRAMEWORK_SERVER_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_FRAMEWORK_SERVER_HPP
|
||||||
#define BEAST_EXAMPLE_FRAMEWORK_SERVER_HPP
|
#define BOOST_BEAST_EXAMPLE_FRAMEWORK_SERVER_HPP
|
||||||
|
|
||||||
#include "framework.hpp"
|
#include "framework.hpp"
|
||||||
|
|
||||||
|
@ -4,13 +4,15 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_SERVICE_LIST_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_SERVICE_LIST_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_SERVICE_LIST_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_SERVICE_LIST_HPP
|
||||||
|
|
||||||
#include "framework.hpp"
|
#include "framework.hpp"
|
||||||
|
|
||||||
#include <beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -118,7 +120,7 @@ public:
|
|||||||
respond(
|
respond(
|
||||||
Stream&& stream,
|
Stream&& stream,
|
||||||
endpoint_type const& ep,
|
endpoint_type const& ep,
|
||||||
beast::http::request<Body>&& req,
|
boost::beast::http::request<Body>&& req,
|
||||||
Send const& send) const
|
Send const& send) const
|
||||||
{
|
{
|
||||||
return try_respond(
|
return try_respond(
|
||||||
@ -141,7 +143,7 @@ private:
|
|||||||
try_respond(
|
try_respond(
|
||||||
Stream&&,
|
Stream&&,
|
||||||
endpoint_type const&,
|
endpoint_type const&,
|
||||||
beast::http::request<Body>&&,
|
boost::beast::http::request<Body>&&,
|
||||||
Send const&,
|
Send const&,
|
||||||
C<sizeof...(Services)> const&) const
|
C<sizeof...(Services)> const&) const
|
||||||
{
|
{
|
||||||
@ -162,7 +164,7 @@ private:
|
|||||||
try_respond(
|
try_respond(
|
||||||
Stream&& stream,
|
Stream&& stream,
|
||||||
endpoint_type const& ep,
|
endpoint_type const& ep,
|
||||||
beast::http::request<Body>&& req,
|
boost::beast::http::request<Body>&& req,
|
||||||
Send const& send,
|
Send const& send,
|
||||||
C<I> const&) const
|
C<I> const&) const
|
||||||
{
|
{
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_SSL_CERTIFICATE_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_SSL_CERTIFICATE_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_SSL_CERTIFICATE_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_SSL_CERTIFICATE_HPP
|
||||||
|
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/asio/ssl/context.hpp>
|
#include <boost/asio/ssl/context.hpp>
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_WS_ASYNC_PORT_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_WS_ASYNC_PORT_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_WS_ASYNC_PORT_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_WS_ASYNC_PORT_HPP
|
||||||
|
|
||||||
#include "server.hpp"
|
#include "server.hpp"
|
||||||
|
|
||||||
#include <beast/core/multi_buffer.hpp>
|
#include <boost/beast/core/multi_buffer.hpp>
|
||||||
#include <beast/websocket/stream.hpp>
|
#include <boost/beast/websocket/stream.hpp>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@ -47,7 +49,7 @@ class async_ws_con_base
|
|||||||
endpoint_type ep_;
|
endpoint_type ep_;
|
||||||
|
|
||||||
// This is used to hold the message data
|
// This is used to hold the message data
|
||||||
beast::multi_buffer buffer_;
|
boost::beast::multi_buffer buffer_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// The strand makes sure that our data is
|
// The strand makes sure that our data is
|
||||||
@ -59,7 +61,7 @@ public:
|
|||||||
// Constructor
|
// Constructor
|
||||||
template<class Callback>
|
template<class Callback>
|
||||||
async_ws_con_base(
|
async_ws_con_base(
|
||||||
beast::string_view server_name,
|
boost::beast::string_view server_name,
|
||||||
std::ostream& log,
|
std::ostream& log,
|
||||||
std::size_t id,
|
std::size_t id,
|
||||||
endpoint_type const& ep,
|
endpoint_type const& ep,
|
||||||
@ -92,16 +94,16 @@ public:
|
|||||||
//
|
//
|
||||||
template<class Body>
|
template<class Body>
|
||||||
void
|
void
|
||||||
run(beast::http::request<Body> const& req)
|
run(boost::beast::http::request<Body> const& req)
|
||||||
{
|
{
|
||||||
// Call the overload of accept() which takes
|
// Call the overload of accept() which takes
|
||||||
// the request by parameter, instead of reading
|
// the request by parameter, instead of reading
|
||||||
// it from the network.
|
// it from the network.
|
||||||
//
|
//
|
||||||
impl().stream().async_accept_ex(req,
|
impl().stream().async_accept_ex(req,
|
||||||
[&](beast::websocket::response_type& res)
|
[&](boost::beast::websocket::response_type& res)
|
||||||
{
|
{
|
||||||
res.set(beast::http::field::server, server_name_);
|
res.set(boost::beast::http::field::server, server_name_);
|
||||||
},
|
},
|
||||||
strand_.wrap(std::bind(
|
strand_.wrap(std::bind(
|
||||||
&async_ws_con_base::on_accept,
|
&async_ws_con_base::on_accept,
|
||||||
@ -118,9 +120,9 @@ protected:
|
|||||||
// to send back the response.
|
// to send back the response.
|
||||||
//
|
//
|
||||||
impl().stream().async_accept_ex(
|
impl().stream().async_accept_ex(
|
||||||
[&](beast::websocket::response_type& res)
|
[&](boost::beast::websocket::response_type& res)
|
||||||
{
|
{
|
||||||
res.set(beast::http::field::server, server_name_);
|
res.set(boost::beast::http::field::server, server_name_);
|
||||||
},
|
},
|
||||||
strand_.wrap(std::bind(
|
strand_.wrap(std::bind(
|
||||||
&async_ws_con_base::on_accept,
|
&async_ws_con_base::on_accept,
|
||||||
@ -133,7 +135,7 @@ protected:
|
|||||||
void
|
void
|
||||||
fail(std::string what, error_code ec)
|
fail(std::string what, error_code ec)
|
||||||
{
|
{
|
||||||
if(ec != beast::websocket::error::closed)
|
if(ec != boost::beast::websocket::error::closed)
|
||||||
log_ <<
|
log_ <<
|
||||||
"[#" << id_ << " " << ep_ << "] " <<
|
"[#" << id_ << " " << ep_ << "] " <<
|
||||||
what << ": " << ec.message() << std::endl;
|
what << ": " << ec.message() << std::endl;
|
||||||
@ -224,7 +226,7 @@ class async_ws_con
|
|||||||
// The stream should be created before the base class so
|
// The stream should be created before the base class so
|
||||||
// use the "base from member" idiom.
|
// use the "base from member" idiom.
|
||||||
//
|
//
|
||||||
, public base_from_member<beast::websocket::stream<socket_type>>
|
, public base_from_member<boost::beast::websocket::stream<socket_type>>
|
||||||
|
|
||||||
// Constructs last, destroys first
|
// Constructs last, destroys first
|
||||||
//
|
//
|
||||||
@ -240,7 +242,7 @@ public:
|
|||||||
async_ws_con(
|
async_ws_con(
|
||||||
socket_type&& sock,
|
socket_type&& sock,
|
||||||
Args&&... args)
|
Args&&... args)
|
||||||
: base_from_member<beast::websocket::stream<socket_type>>(std::move(sock))
|
: base_from_member<boost::beast::websocket::stream<socket_type>>(std::move(sock))
|
||||||
, async_ws_con_base<async_ws_con>(std::forward<Args>(args)...)
|
, async_ws_con_base<async_ws_con>(std::forward<Args>(args)...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -252,7 +254,7 @@ public:
|
|||||||
// class to work with different return types for `stream()` such
|
// class to work with different return types for `stream()` such
|
||||||
// as a `boost::asio::ip::tcp::socket&` or a `boost::asio::ssl::stream&`
|
// as a `boost::asio::ip::tcp::socket&` or a `boost::asio::ssl::stream&`
|
||||||
//
|
//
|
||||||
beast::websocket::stream<socket_type>&
|
boost::beast::websocket::stream<socket_type>&
|
||||||
stream()
|
stream()
|
||||||
{
|
{
|
||||||
return this->member;
|
return this->member;
|
||||||
@ -282,7 +284,7 @@ class ws_async_port
|
|||||||
// The type of the on_new_stream callback
|
// The type of the on_new_stream callback
|
||||||
//
|
//
|
||||||
using on_new_stream_cb =
|
using on_new_stream_cb =
|
||||||
boost::function<void(beast::websocket::stream<socket_type>&)>;
|
boost::function<void(boost::beast::websocket::stream<socket_type>&)>;
|
||||||
|
|
||||||
server& instance_;
|
server& instance_;
|
||||||
std::ostream& log_;
|
std::ostream& log_;
|
||||||
@ -301,7 +303,7 @@ public:
|
|||||||
should have this equivalent signature:
|
should have this equivalent signature:
|
||||||
@code
|
@code
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
void callback(beast::websocket::stream<NextLayer>&);
|
void callback(boost::beast::websocket::stream<NextLayer>&);
|
||||||
@endcode
|
@endcode
|
||||||
In C++14 this can be accomplished with a generic lambda. In
|
In C++14 this can be accomplished with a generic lambda. In
|
||||||
C++11 it will be necessary to write out a lambda manually,
|
C++11 it will be necessary to write out a lambda manually,
|
||||||
@ -357,7 +359,7 @@ public:
|
|||||||
on_upgrade(
|
on_upgrade(
|
||||||
socket_type&& sock,
|
socket_type&& sock,
|
||||||
endpoint_type ep,
|
endpoint_type ep,
|
||||||
beast::http::request<Body>&& req)
|
boost::beast::http::request<Body>&& req)
|
||||||
{
|
{
|
||||||
std::make_shared<async_ws_con>(
|
std::make_shared<async_ws_con>(
|
||||||
std::move(sock),
|
std::move(sock),
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_WS_SYNC_PORT_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_WS_SYNC_PORT_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_WS_SYNC_PORT_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_WS_SYNC_PORT_HPP
|
||||||
|
|
||||||
#include "server.hpp"
|
#include "server.hpp"
|
||||||
|
|
||||||
#include <beast/core/multi_buffer.hpp>
|
#include <boost/beast/core/multi_buffer.hpp>
|
||||||
#include <beast/websocket.hpp>
|
#include <boost/beast/websocket.hpp>
|
||||||
#include <boost/function.hpp>
|
#include <boost/function.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
@ -60,7 +62,7 @@ public:
|
|||||||
//
|
//
|
||||||
template<class Callback>
|
template<class Callback>
|
||||||
sync_ws_con_base(
|
sync_ws_con_base(
|
||||||
beast::string_view server_name,
|
boost::beast::string_view server_name,
|
||||||
std::ostream& log,
|
std::ostream& log,
|
||||||
std::size_t id,
|
std::size_t id,
|
||||||
endpoint_type const& ep,
|
endpoint_type const& ep,
|
||||||
@ -95,9 +97,9 @@ public:
|
|||||||
//
|
//
|
||||||
template<class Body>
|
template<class Body>
|
||||||
void
|
void
|
||||||
run(beast::http::request<Body>&& req)
|
run(boost::beast::http::request<Body>&& req)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(beast::websocket::is_upgrade(req));
|
BOOST_ASSERT(boost::beast::websocket::is_upgrade(req));
|
||||||
|
|
||||||
// We need to transfer ownership of the request object into
|
// We need to transfer ownership of the request object into
|
||||||
// the lambda, but there's no C++14 lambda capture
|
// the lambda, but there's no C++14 lambda capture
|
||||||
@ -119,7 +121,7 @@ protected:
|
|||||||
// Don't report the "closed" error since that
|
// Don't report the "closed" error since that
|
||||||
// happens under normal circumstances.
|
// happens under normal circumstances.
|
||||||
//
|
//
|
||||||
if(ec && ec != beast::websocket::error::closed)
|
if(ec && ec != boost::beast::websocket::error::closed)
|
||||||
{
|
{
|
||||||
log_ <<
|
log_ <<
|
||||||
"[#" << id_ << " " << ep_ << "] " <<
|
"[#" << id_ << " " << ep_ << "] " <<
|
||||||
@ -148,9 +150,9 @@ private:
|
|||||||
// to send back the response.
|
// to send back the response.
|
||||||
//
|
//
|
||||||
impl().stream().accept_ex(
|
impl().stream().accept_ex(
|
||||||
[&](beast::websocket::response_type& res)
|
[&](boost::beast::websocket::response_type& res)
|
||||||
{
|
{
|
||||||
res.insert(beast::http::field::server, server_name_);
|
res.insert(boost::beast::http::field::server, server_name_);
|
||||||
},
|
},
|
||||||
ec);
|
ec);
|
||||||
|
|
||||||
@ -172,7 +174,7 @@ private:
|
|||||||
class lambda
|
class lambda
|
||||||
{
|
{
|
||||||
std::shared_ptr<sync_ws_con_base> self_;
|
std::shared_ptr<sync_ws_con_base> self_;
|
||||||
beast::http::request<Body> req_;
|
boost::beast::http::request<Body> req_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
@ -181,11 +183,11 @@ private:
|
|||||||
//
|
//
|
||||||
lambda(
|
lambda(
|
||||||
std::shared_ptr<sync_ws_con_base> self,
|
std::shared_ptr<sync_ws_con_base> self,
|
||||||
beast::http::request<Body>&& req)
|
boost::beast::http::request<Body>&& req)
|
||||||
: self_(std::move(self))
|
: self_(std::move(self))
|
||||||
, req_(std::move(req))
|
, req_(std::move(req))
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(beast::websocket::is_upgrade(req_));
|
BOOST_ASSERT(boost::beast::websocket::is_upgrade(req_));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke the lambda
|
// Invoke the lambda
|
||||||
@ -193,7 +195,7 @@ private:
|
|||||||
void
|
void
|
||||||
operator()()
|
operator()()
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(beast::websocket::is_upgrade(req_));
|
BOOST_ASSERT(boost::beast::websocket::is_upgrade(req_));
|
||||||
error_code ec;
|
error_code ec;
|
||||||
{
|
{
|
||||||
// Move the message to the stack so we can get
|
// Move the message to the stack so we can get
|
||||||
@ -207,9 +209,9 @@ private:
|
|||||||
// it from the network.
|
// it from the network.
|
||||||
//
|
//
|
||||||
self_->impl().stream().accept_ex(req,
|
self_->impl().stream().accept_ex(req,
|
||||||
[&](beast::websocket::response_type& res)
|
[&](boost::beast::websocket::response_type& res)
|
||||||
{
|
{
|
||||||
res.insert(beast::http::field::server, self_->server_name_);
|
res.insert(boost::beast::http::field::server, self_->server_name_);
|
||||||
},
|
},
|
||||||
ec);
|
ec);
|
||||||
}
|
}
|
||||||
@ -233,7 +235,7 @@ private:
|
|||||||
// This buffer holds the message. We place a one
|
// This buffer holds the message. We place a one
|
||||||
// megabyte limit on the size to prevent abuse.
|
// megabyte limit on the size to prevent abuse.
|
||||||
//
|
//
|
||||||
beast::multi_buffer buffer{1024*1024};
|
boost::beast::multi_buffer buffer{1024*1024};
|
||||||
|
|
||||||
// Read the message
|
// Read the message
|
||||||
//
|
//
|
||||||
@ -276,7 +278,7 @@ class sync_ws_con
|
|||||||
// The stream should be created before the base class so
|
// The stream should be created before the base class so
|
||||||
// use the "base from member" idiom.
|
// use the "base from member" idiom.
|
||||||
//
|
//
|
||||||
, public base_from_member<beast::websocket::stream<socket_type>>
|
, public base_from_member<boost::beast::websocket::stream<socket_type>>
|
||||||
|
|
||||||
// Constructs last, destroys first
|
// Constructs last, destroys first
|
||||||
//
|
//
|
||||||
@ -290,7 +292,7 @@ public:
|
|||||||
sync_ws_con(
|
sync_ws_con(
|
||||||
socket_type&& sock,
|
socket_type&& sock,
|
||||||
Args&&... args)
|
Args&&... args)
|
||||||
: base_from_member<beast::websocket::stream<socket_type>>(std::move(sock))
|
: base_from_member<boost::beast::websocket::stream<socket_type>>(std::move(sock))
|
||||||
, sync_ws_con_base<sync_ws_con>(std::forward<Args>(args)...)
|
, sync_ws_con_base<sync_ws_con>(std::forward<Args>(args)...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -302,7 +304,7 @@ public:
|
|||||||
// class to work with different return types for `stream()` such
|
// class to work with different return types for `stream()` such
|
||||||
// as a `boost::asio::ip::tcp::socket&` or a `boost::asio::ssl::stream&`
|
// as a `boost::asio::ip::tcp::socket&` or a `boost::asio::ssl::stream&`
|
||||||
//
|
//
|
||||||
beast::websocket::stream<socket_type>&
|
boost::beast::websocket::stream<socket_type>&
|
||||||
stream()
|
stream()
|
||||||
{
|
{
|
||||||
return this->member;
|
return this->member;
|
||||||
@ -337,7 +339,7 @@ class ws_sync_port
|
|||||||
// The type of the on_new_stream callback
|
// The type of the on_new_stream callback
|
||||||
//
|
//
|
||||||
using on_new_stream_cb =
|
using on_new_stream_cb =
|
||||||
boost::function<void(beast::websocket::stream<socket_type>&)>;
|
boost::function<void(boost::beast::websocket::stream<socket_type>&)>;
|
||||||
|
|
||||||
server& instance_;
|
server& instance_;
|
||||||
std::ostream& log_;
|
std::ostream& log_;
|
||||||
@ -356,7 +358,7 @@ public:
|
|||||||
should have this equivalent signature:
|
should have this equivalent signature:
|
||||||
@code
|
@code
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
void callback(beast::websocket::stream<NextLayer>&);
|
void callback(boost::beast::websocket::stream<NextLayer>&);
|
||||||
@endcode
|
@endcode
|
||||||
In C++14 this can be accomplished with a generic lambda. In
|
In C++14 this can be accomplished with a generic lambda. In
|
||||||
C++11 it will be necessary to write out a lambda manually,
|
C++11 it will be necessary to write out a lambda manually,
|
||||||
@ -412,7 +414,7 @@ public:
|
|||||||
on_upgrade(
|
on_upgrade(
|
||||||
socket_type&& sock,
|
socket_type&& sock,
|
||||||
endpoint_type ep,
|
endpoint_type ep,
|
||||||
beast::http::request<Body>&& req)
|
boost::beast::http::request<Body>&& req)
|
||||||
{
|
{
|
||||||
// Create the connection object and run it,
|
// Create the connection object and run it,
|
||||||
// transferring ownership of the ugprade request.
|
// transferring ownership of the ugprade request.
|
||||||
|
@ -4,14 +4,16 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_WS_UPGRADE_SERVICE_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_WS_UPGRADE_SERVICE_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_WS_UPGRADE_SERVICE_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_WS_UPGRADE_SERVICE_HPP
|
||||||
|
|
||||||
#include "framework.hpp"
|
#include "framework.hpp"
|
||||||
|
|
||||||
#include <beast/http/message.hpp>
|
#include <boost/beast/http/message.hpp>
|
||||||
#include <beast/websocket/rfc6455.hpp>
|
#include <boost/beast/websocket/rfc6455.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace framework {
|
namespace framework {
|
||||||
@ -73,13 +75,13 @@ public:
|
|||||||
respond(
|
respond(
|
||||||
Stream&& stream,
|
Stream&& stream,
|
||||||
endpoint_type const& ep,
|
endpoint_type const& ep,
|
||||||
beast::http::request<Body>&& req,
|
boost::beast::http::request<Body>&& req,
|
||||||
Send const&) const
|
Send const&) const
|
||||||
{
|
{
|
||||||
// If its not an upgrade request, return `false`
|
// If its not an upgrade request, return `false`
|
||||||
// to indicate that we are not handling it.
|
// to indicate that we are not handling it.
|
||||||
//
|
//
|
||||||
if(! beast::websocket::is_upgrade(req))
|
if(! boost::beast::websocket::is_upgrade(req))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Its an ugprade request, so transfer ownership
|
// Its an ugprade request, so transfer ownership
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_EXAMPLE_SERVER_WSS_PORTS_HPP
|
#ifndef BOOST_BEAST_EXAMPLE_SERVER_WSS_PORTS_HPP
|
||||||
#define BEAST_EXAMPLE_SERVER_WSS_PORTS_HPP
|
#define BOOST_BEAST_EXAMPLE_SERVER_WSS_PORTS_HPP
|
||||||
|
|
||||||
#include "ws_sync_port.hpp"
|
#include "ws_sync_port.hpp"
|
||||||
#include "ws_async_port.hpp"
|
#include "ws_async_port.hpp"
|
||||||
@ -36,7 +38,7 @@ class sync_wss_con
|
|||||||
// The stream should be created before the base class so
|
// The stream should be created before the base class so
|
||||||
// use the "base from member" idiom.
|
// use the "base from member" idiom.
|
||||||
//
|
//
|
||||||
, public base_from_member<beast::websocket::stream<ssl_stream<socket_type>>>
|
, public base_from_member<boost::beast::websocket::stream<ssl_stream<socket_type>>>
|
||||||
|
|
||||||
// Constructs last, destroys first
|
// Constructs last, destroys first
|
||||||
//
|
//
|
||||||
@ -53,7 +55,7 @@ public:
|
|||||||
socket_type&& sock,
|
socket_type&& sock,
|
||||||
boost::asio::ssl::context& ctx,
|
boost::asio::ssl::context& ctx,
|
||||||
Args&&... args)
|
Args&&... args)
|
||||||
: base_from_member<beast::websocket::stream<ssl_stream<socket_type>>>(std::move(sock), ctx)
|
: base_from_member<boost::beast::websocket::stream<ssl_stream<socket_type>>>(std::move(sock), ctx)
|
||||||
, sync_ws_con_base<sync_wss_con>(std::forward<Args>(args)...)
|
, sync_ws_con_base<sync_wss_con>(std::forward<Args>(args)...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -64,7 +66,7 @@ public:
|
|||||||
sync_wss_con(
|
sync_wss_con(
|
||||||
ssl_stream<socket_type>&& stream,
|
ssl_stream<socket_type>&& stream,
|
||||||
Args&&... args)
|
Args&&... args)
|
||||||
: base_from_member<beast::websocket::stream<ssl_stream<socket_type>>>(std::move(stream))
|
: base_from_member<boost::beast::websocket::stream<ssl_stream<socket_type>>>(std::move(stream))
|
||||||
, sync_ws_con_base<sync_wss_con>(std::forward<Args>(args)...)
|
, sync_ws_con_base<sync_wss_con>(std::forward<Args>(args)...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -76,7 +78,7 @@ public:
|
|||||||
// class to work with different return types for `stream()` such
|
// class to work with different return types for `stream()` such
|
||||||
// as a `boost::asio::ip::tcp::socket&` or a `boost::asio::ssl::stream&`
|
// as a `boost::asio::ip::tcp::socket&` or a `boost::asio::ssl::stream&`
|
||||||
//
|
//
|
||||||
beast::websocket::stream<ssl_stream<socket_type>>&
|
boost::beast::websocket::stream<ssl_stream<socket_type>>&
|
||||||
stream()
|
stream()
|
||||||
{
|
{
|
||||||
return this->member;
|
return this->member;
|
||||||
@ -116,7 +118,7 @@ class async_wss_con
|
|||||||
// The stream should be created before the base class so
|
// The stream should be created before the base class so
|
||||||
// use the "base from member" idiom.
|
// use the "base from member" idiom.
|
||||||
//
|
//
|
||||||
, public base_from_member<beast::websocket::stream<ssl_stream<socket_type>>>
|
, public base_from_member<boost::beast::websocket::stream<ssl_stream<socket_type>>>
|
||||||
|
|
||||||
// Constructs last, destroys first
|
// Constructs last, destroys first
|
||||||
//
|
//
|
||||||
@ -132,7 +134,7 @@ public:
|
|||||||
socket_type&& sock,
|
socket_type&& sock,
|
||||||
boost::asio::ssl::context& ctx,
|
boost::asio::ssl::context& ctx,
|
||||||
Args&&... args)
|
Args&&... args)
|
||||||
: base_from_member<beast::websocket::stream<ssl_stream<socket_type>>>(std::move(sock), ctx)
|
: base_from_member<boost::beast::websocket::stream<ssl_stream<socket_type>>>(std::move(sock), ctx)
|
||||||
, async_ws_con_base<async_wss_con>(std::forward<Args>(args)...)
|
, async_ws_con_base<async_wss_con>(std::forward<Args>(args)...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -143,7 +145,7 @@ public:
|
|||||||
async_wss_con(
|
async_wss_con(
|
||||||
ssl_stream<socket_type>&& stream,
|
ssl_stream<socket_type>&& stream,
|
||||||
Args&&... args)
|
Args&&... args)
|
||||||
: base_from_member<beast::websocket::stream<ssl_stream<socket_type>>>(std::move(stream))
|
: base_from_member<boost::beast::websocket::stream<ssl_stream<socket_type>>>(std::move(stream))
|
||||||
, async_ws_con_base<async_wss_con>(std::forward<Args>(args)...)
|
, async_ws_con_base<async_wss_con>(std::forward<Args>(args)...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -155,7 +157,7 @@ public:
|
|||||||
// class to work with different return types for `stream()` such
|
// class to work with different return types for `stream()` such
|
||||||
// as a `boost::asio::ip::tcp::socket&` or a `boost::asio::ssl::stream&`
|
// as a `boost::asio::ip::tcp::socket&` or a `boost::asio::ssl::stream&`
|
||||||
//
|
//
|
||||||
beast::websocket::stream<ssl_stream<socket_type>>&
|
boost::beast::websocket::stream<ssl_stream<socket_type>>&
|
||||||
stream()
|
stream()
|
||||||
{
|
{
|
||||||
return this->member;
|
return this->member;
|
||||||
@ -211,10 +213,10 @@ class wss_sync_port
|
|||||||
// The types of the on_new_stream callbacks
|
// The types of the on_new_stream callbacks
|
||||||
//
|
//
|
||||||
using on_new_stream_cb1 =
|
using on_new_stream_cb1 =
|
||||||
boost::function<void(beast::websocket::stream<socket_type>&)>;
|
boost::function<void(boost::beast::websocket::stream<socket_type>&)>;
|
||||||
|
|
||||||
using on_new_stream_cb2 =
|
using on_new_stream_cb2 =
|
||||||
boost::function<void(beast::websocket::stream<ssl_stream<socket_type>>&)>;
|
boost::function<void(boost::beast::websocket::stream<ssl_stream<socket_type>>&)>;
|
||||||
|
|
||||||
server& instance_;
|
server& instance_;
|
||||||
std::ostream& log_;
|
std::ostream& log_;
|
||||||
@ -237,7 +239,7 @@ public:
|
|||||||
should have this equivalent signature:
|
should have this equivalent signature:
|
||||||
@code
|
@code
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
void callback(beast::websocket::stream<NextLayer>&);
|
void callback(boost::beast::websocket::stream<NextLayer>&);
|
||||||
@endcode
|
@endcode
|
||||||
In C++14 this can be accomplished with a generic lambda. In
|
In C++14 this can be accomplished with a generic lambda. In
|
||||||
C++11 it will be necessary to write out a lambda manually,
|
C++11 it will be necessary to write out a lambda manually,
|
||||||
@ -297,7 +299,7 @@ public:
|
|||||||
on_upgrade(
|
on_upgrade(
|
||||||
ssl_stream<socket_type>&& stream,
|
ssl_stream<socket_type>&& stream,
|
||||||
endpoint_type ep,
|
endpoint_type ep,
|
||||||
beast::http::request<Body>&& req)
|
boost::beast::http::request<Body>&& req)
|
||||||
{
|
{
|
||||||
// Create the connection object and run it,
|
// Create the connection object and run it,
|
||||||
// transferring ownership of the ugprade request.
|
// transferring ownership of the ugprade request.
|
||||||
@ -328,10 +330,10 @@ class wss_async_port
|
|||||||
// The types of the on_new_stream callbacks
|
// The types of the on_new_stream callbacks
|
||||||
//
|
//
|
||||||
using on_new_stream_cb1 =
|
using on_new_stream_cb1 =
|
||||||
boost::function<void(beast::websocket::stream<socket_type>&)>;
|
boost::function<void(boost::beast::websocket::stream<socket_type>&)>;
|
||||||
|
|
||||||
using on_new_stream_cb2 =
|
using on_new_stream_cb2 =
|
||||||
boost::function<void(beast::websocket::stream<ssl_stream<socket_type>>&)>;
|
boost::function<void(boost::beast::websocket::stream<ssl_stream<socket_type>>&)>;
|
||||||
|
|
||||||
// Reference to the server instance that made us
|
// Reference to the server instance that made us
|
||||||
server& instance_;
|
server& instance_;
|
||||||
@ -361,7 +363,7 @@ public:
|
|||||||
should have this equivalent signature:
|
should have this equivalent signature:
|
||||||
@code
|
@code
|
||||||
template<class NextLayer>
|
template<class NextLayer>
|
||||||
void callback(beast::websocket::stream<NextLayer>&);
|
void callback(boost::beast::websocket::stream<NextLayer>&);
|
||||||
@endcode
|
@endcode
|
||||||
In C++14 this can be accomplished with a generic lambda. In
|
In C++14 this can be accomplished with a generic lambda. In
|
||||||
C++11 it will be necessary to write out a lambda manually,
|
C++11 it will be necessary to write out a lambda manually,
|
||||||
@ -421,7 +423,7 @@ public:
|
|||||||
on_upgrade(
|
on_upgrade(
|
||||||
ssl_stream<socket_type>&& stream,
|
ssl_stream<socket_type>&& stream,
|
||||||
endpoint_type ep,
|
endpoint_type ep,
|
||||||
beast::http::request<Body>&& req)
|
boost::beast::http::request<Body>&& req)
|
||||||
{
|
{
|
||||||
std::make_shared<async_wss_con>(
|
std::make_shared<async_wss_con>(
|
||||||
std::move(stream),
|
std::move(stream),
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
GroupSources(include/beast beast)
|
GroupSources(include/boost/beast beast)
|
||||||
|
|
||||||
GroupSources(example/websocket-client-ssl "/")
|
GroupSources(example/websocket-client-ssl "/")
|
||||||
|
|
||||||
add_executable (websocket-client-ssl
|
add_executable (websocket-client-ssl
|
||||||
${BEAST_INCLUDES}
|
${BOOST_BEAST_INCLUDES}
|
||||||
|
Jamfile
|
||||||
websocket_client_ssl.cpp
|
websocket_client_ssl.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
import os ;
|
import os ;
|
||||||
|
|
||||||
|
@ -4,12 +4,14 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include "../common/root_certificates.hpp"
|
#include "../common/root_certificates.hpp"
|
||||||
|
|
||||||
#include <beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
#include <beast/websocket.hpp>
|
#include <boost/beast/websocket.hpp>
|
||||||
#include <beast/websocket/ssl.hpp>
|
#include <boost/beast/websocket/ssl.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/asio/ssl.hpp>
|
#include <boost/asio/ssl.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -18,13 +20,13 @@
|
|||||||
|
|
||||||
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
||||||
namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
|
namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
|
||||||
namespace websocket = beast::websocket; // from <beast/websocket.hpp>
|
namespace websocket = boost::beast::websocket; // from <boost/beast/websocket.hpp>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// A helper for reporting errors
|
// A helper for reporting errors
|
||||||
auto const fail =
|
auto const fail =
|
||||||
[](std::string what, beast::error_code ec)
|
[](std::string what, boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
std::cerr << what << ": " << ec.message() << std::endl;
|
std::cerr << what << ": " << ec.message() << std::endl;
|
||||||
std::cerr.flush();
|
std::cerr.flush();
|
||||||
@ -81,7 +83,7 @@ int main()
|
|||||||
return fail("write", ec);
|
return fail("write", ec);
|
||||||
|
|
||||||
// This buffer will hold the incoming message
|
// This buffer will hold the incoming message
|
||||||
beast::multi_buffer b;
|
boost::beast::multi_buffer b;
|
||||||
|
|
||||||
// Read the message into our buffer
|
// Read the message into our buffer
|
||||||
ws.read(b, ec);
|
ws.read(b, ec);
|
||||||
@ -94,13 +96,13 @@ int main()
|
|||||||
return fail("close", ec);
|
return fail("close", ec);
|
||||||
|
|
||||||
// The buffers() function helps print a ConstBufferSequence
|
// The buffers() function helps print a ConstBufferSequence
|
||||||
std::cout << beast::buffers(b.data()) << std::endl;
|
std::cout << boost::beast::buffers(b.data()) << std::endl;
|
||||||
|
|
||||||
// WebSocket says that to close a connection you have
|
// WebSocket says that to close a connection you have
|
||||||
// to keep reading messages until you receive a close frame.
|
// to keep reading messages until you receive a close frame.
|
||||||
// Beast delivers the close frame as an error from read.
|
// Beast delivers the close frame as an error from read.
|
||||||
//
|
//
|
||||||
beast::drain_buffer drain; // Throws everything away efficiently
|
boost::beast::drain_buffer drain; // Throws everything away efficiently
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
// Keep reading messages...
|
// Keep reading messages...
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
GroupSources(include/beast beast)
|
GroupSources(include/boost/beast beast)
|
||||||
|
|
||||||
GroupSources(example/websocket-client "/")
|
GroupSources(example/websocket-client "/")
|
||||||
|
|
||||||
add_executable (websocket-client
|
add_executable (websocket-client
|
||||||
${BEAST_INCLUDES}
|
${BOOST_BEAST_INCLUDES}
|
||||||
${EXTRAS_INCLUDES}
|
Jamfile
|
||||||
websocket_client.cpp
|
websocket_client.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
exe websocket-client :
|
exe websocket-client :
|
||||||
websocket_client.cpp
|
websocket_client.cpp
|
||||||
|
@ -4,24 +4,26 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
//[example_websocket_client
|
//[example_websocket_client
|
||||||
|
|
||||||
#include <beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
#include <beast/websocket.hpp>
|
#include <boost/beast/websocket.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
||||||
namespace websocket = beast::websocket; // from <beast/websocket.hpp>
|
namespace websocket = boost::beast::websocket; // from <boost/beast/websocket.hpp>
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// A helper for reporting errors
|
// A helper for reporting errors
|
||||||
auto const fail =
|
auto const fail =
|
||||||
[](std::string what, beast::error_code ec)
|
[](std::string what, boost::beast::error_code ec)
|
||||||
{
|
{
|
||||||
std::cerr << what << ": " << ec.message() << std::endl;
|
std::cerr << what << ": " << ec.message() << std::endl;
|
||||||
std::cerr.flush();
|
std::cerr.flush();
|
||||||
@ -60,7 +62,7 @@ int main()
|
|||||||
return fail("write", ec);
|
return fail("write", ec);
|
||||||
|
|
||||||
// This buffer will hold the incoming message
|
// This buffer will hold the incoming message
|
||||||
beast::multi_buffer b;
|
boost::beast::multi_buffer b;
|
||||||
|
|
||||||
// Read the message into our buffer
|
// Read the message into our buffer
|
||||||
ws.read(b, ec);
|
ws.read(b, ec);
|
||||||
@ -73,13 +75,13 @@ int main()
|
|||||||
return fail("close", ec);
|
return fail("close", ec);
|
||||||
|
|
||||||
// The buffers() function helps print a ConstBufferSequence
|
// The buffers() function helps print a ConstBufferSequence
|
||||||
std::cout << beast::buffers(b.data()) << std::endl;
|
std::cout << boost::beast::buffers(b.data()) << std::endl;
|
||||||
|
|
||||||
// WebSocket says that to close a connection you have
|
// WebSocket says that to close a connection you have
|
||||||
// to keep reading messages until you receive a close frame.
|
// to keep reading messages until you receive a close frame.
|
||||||
// Beast delivers the close frame as an error from read.
|
// Beast delivers the close frame as an error from read.
|
||||||
//
|
//
|
||||||
beast::drain_buffer drain; // Throws everything away efficiently
|
boost::beast::drain_buffer drain; // Throws everything away efficiently
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
// Keep reading messages...
|
// Keep reading messages...
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
# Part of Beast
|
#
|
||||||
|
# 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)
|
||||||
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
GroupSources(include/beast beast)
|
GroupSources(include/boost/beast beast)
|
||||||
GroupSources(example/common common)
|
GroupSources(example/common common)
|
||||||
GroupSources(example/websocket-server-async "/")
|
GroupSources(example/websocket-server-async "/")
|
||||||
|
|
||||||
add_executable (websocket-server-async
|
add_executable (websocket-server-async
|
||||||
${BEAST_INCLUDES}
|
${BOOST_BEAST_INCLUDES}
|
||||||
${COMMON_INCLUDES}
|
${COMMON_INCLUDES}
|
||||||
|
Jamfile
|
||||||
websocket_server_async.cpp
|
websocket_server_async.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
#
|
#
|
||||||
|
# Official repository: https://github.com/boostorg/beast
|
||||||
|
#
|
||||||
|
|
||||||
exe websocket-server-async :
|
exe websocket-server-async :
|
||||||
websocket_server_async.cpp
|
websocket_server_async.cpp
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include "../common/helpers.hpp"
|
#include "../common/helpers.hpp"
|
||||||
|
|
||||||
#include <beast/core.hpp>
|
#include <boost/beast/core.hpp>
|
||||||
#include <beast/websocket.hpp>
|
#include <boost/beast/websocket.hpp>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
@ -20,8 +22,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
namespace http = beast::http; // from <beast/http.hpp>
|
namespace http = boost::beast::http; // from <boost/beast/http.hpp>
|
||||||
namespace websocket = beast::websocket; // from <beast/websocket.hpp>
|
namespace websocket = boost::beast::websocket; // from <boost/beast/websocket.hpp>
|
||||||
namespace ip = boost::asio::ip; // from <boost/asio.hpp>
|
namespace ip = boost::asio::ip; // from <boost/asio.hpp>
|
||||||
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
||||||
|
|
||||||
@ -38,7 +40,7 @@ using tcp = boost::asio::ip::tcp; // from <boost/asio.hpp>
|
|||||||
*/
|
*/
|
||||||
class server
|
class server
|
||||||
{
|
{
|
||||||
using error_code = beast::error_code; // Saves typing
|
using error_code = boost::beast::error_code; // Saves typing
|
||||||
using clock_type =
|
using clock_type =
|
||||||
std::chrono::steady_clock; // For the timer
|
std::chrono::steady_clock; // For the timer
|
||||||
using stream_type =
|
using stream_type =
|
||||||
@ -63,8 +65,8 @@ class server
|
|||||||
boost::asio::basic_waitable_timer<
|
boost::asio::basic_waitable_timer<
|
||||||
clock_type> timer_; // Needed for timeouts
|
clock_type> timer_; // Needed for timeouts
|
||||||
boost::asio::io_service::strand strand_;// Needed when threads > 1
|
boost::asio::io_service::strand strand_;// Needed when threads > 1
|
||||||
beast::multi_buffer buffer_; // Stores the current message
|
boost::beast::multi_buffer buffer_; // Stores the current message
|
||||||
beast::drain_buffer drain_; // Helps discard data on close
|
boost::beast::drain_buffer drain_; // Helps discard data on close
|
||||||
std::size_t id_; // A small unique id
|
std::size_t id_; // A small unique id
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -395,7 +397,7 @@ int main(int argc, char* argv[])
|
|||||||
s.on_new_stream(set_stream_options{pmd});
|
s.on_new_stream(set_stream_options{pmd});
|
||||||
|
|
||||||
// Open the listening port
|
// Open the listening port
|
||||||
beast::error_code ec;
|
boost::beast::error_code ec;
|
||||||
s.open(tcp::endpoint{address, port}, ec);
|
s.open(tcp::endpoint{address, port}, ec);
|
||||||
if(ec)
|
if(ec)
|
||||||
{
|
{
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef BEAST_DOC_DEBUG_HPP
|
#ifndef BOOST_BEAST_DOC_DEBUG_HPP
|
||||||
#define BEAST_DOC_DEBUG_HPP
|
#define BOOST_BEAST_DOC_DEBUG_HPP
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
|
|
||||||
#if BEAST_DOXYGEN
|
#if BOOST_BEAST_DOXYGEN
|
||||||
|
|
||||||
/// doc type (documentation debug helper)
|
/// doc type (documentation debug helper)
|
||||||
using doc_type = int;
|
using doc_type = int;
|
@ -4,13 +4,16 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_TEST_FAIL_COUNTER_HPP
|
#ifndef BOOST_BEAST_TEST_FAIL_COUNTER_HPP
|
||||||
#define BEAST_TEST_FAIL_COUNTER_HPP
|
#define BOOST_BEAST_TEST_FAIL_COUNTER_HPP
|
||||||
|
|
||||||
#include <beast/core/error.hpp>
|
#include <boost/beast/core/error.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
@ -156,6 +159,7 @@ public:
|
|||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace system {
|
namespace system {
|
@ -4,18 +4,21 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_TEST_FAIL_STREAM_HPP
|
#ifndef BOOST_BEAST_TEST_FAIL_STREAM_HPP
|
||||||
#define BEAST_TEST_FAIL_STREAM_HPP
|
#define BOOST_BEAST_TEST_FAIL_STREAM_HPP
|
||||||
|
|
||||||
#include <beast/core/async_result.hpp>
|
#include <boost/beast/core/async_result.hpp>
|
||||||
#include <beast/core/bind_handler.hpp>
|
#include <boost/beast/core/bind_handler.hpp>
|
||||||
#include <beast/core/error.hpp>
|
#include <boost/beast/core/error.hpp>
|
||||||
#include <beast/core/detail/type_traits.hpp>
|
#include <boost/beast/core/detail/type_traits.hpp>
|
||||||
#include <beast/websocket/teardown.hpp>
|
#include <boost/beast/websocket/teardown.hpp>
|
||||||
#include <beast/test/fail_counter.hpp>
|
#include <boost/beast/test/fail_counter.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
@ -188,5 +191,6 @@ public:
|
|||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,14 +4,17 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_TEST_FUZZ_HPP
|
#ifndef BOOST_BEAST_TEST_FUZZ_HPP
|
||||||
#define BEAST_TEST_FUZZ_HPP
|
#define BOOST_BEAST_TEST_FUZZ_HPP
|
||||||
|
|
||||||
#include <beast/core/static_string.hpp>
|
#include <boost/beast/core/static_string.hpp>
|
||||||
#include <beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
@ -97,5 +100,6 @@ fuzz(
|
|||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,17 +4,19 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_TEST_PIPE_STREAM_HPP
|
#ifndef BOOST_BEAST_TEST_PIPE_STREAM_HPP
|
||||||
#define BEAST_TEST_PIPE_STREAM_HPP
|
#define BOOST_BEAST_TEST_PIPE_STREAM_HPP
|
||||||
|
|
||||||
#include <beast/core/async_result.hpp>
|
#include <boost/beast/core/async_result.hpp>
|
||||||
#include <beast/core/bind_handler.hpp>
|
#include <boost/beast/core/bind_handler.hpp>
|
||||||
#include <beast/core/flat_buffer.hpp>
|
#include <boost/beast/core/flat_buffer.hpp>
|
||||||
#include <beast/core/string.hpp>
|
#include <boost/beast/core/string.hpp>
|
||||||
#include <beast/core/type_traits.hpp>
|
#include <boost/beast/core/type_traits.hpp>
|
||||||
#include <beast/websocket/teardown.hpp>
|
#include <boost/beast/websocket/teardown.hpp>
|
||||||
#include <beast/test/fail_counter.hpp>
|
#include <boost/beast/test/fail_counter.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
@ -24,6 +26,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
@ -525,5 +528,6 @@ async_write_some(ConstBufferSequence const& buffers,
|
|||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,12 +4,15 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_TEST_SIG_WAIT_HPP
|
#ifndef BOOST_BEAST_TEST_SIG_WAIT_HPP
|
||||||
#define BEAST_TEST_SIG_WAIT_HPP
|
#define BOOST_BEAST_TEST_SIG_WAIT_HPP
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
@ -30,5 +33,6 @@ sig_wait()
|
|||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,20 +4,23 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_TEST_STRING_IOSTREAM_HPP
|
#ifndef BOOST_BEAST_TEST_STRING_IOSTREAM_HPP
|
||||||
#define BEAST_TEST_STRING_IOSTREAM_HPP
|
#define BOOST_BEAST_TEST_STRING_IOSTREAM_HPP
|
||||||
|
|
||||||
#include <beast/core/async_result.hpp>
|
#include <boost/beast/core/async_result.hpp>
|
||||||
#include <beast/core/bind_handler.hpp>
|
#include <boost/beast/core/bind_handler.hpp>
|
||||||
#include <beast/core/buffer_prefix.hpp>
|
#include <boost/beast/core/buffer_prefix.hpp>
|
||||||
#include <beast/core/error.hpp>
|
#include <boost/beast/core/error.hpp>
|
||||||
#include <beast/websocket/teardown.hpp>
|
#include <boost/beast/websocket/teardown.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
@ -169,5 +172,6 @@ public:
|
|||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,19 +4,22 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_TEST_STRING_ISTREAM_HPP
|
#ifndef BOOST_BEAST_TEST_STRING_ISTREAM_HPP
|
||||||
#define BEAST_TEST_STRING_ISTREAM_HPP
|
#define BOOST_BEAST_TEST_STRING_ISTREAM_HPP
|
||||||
|
|
||||||
#include <beast/core/async_result.hpp>
|
#include <boost/beast/core/async_result.hpp>
|
||||||
#include <beast/core/bind_handler.hpp>
|
#include <boost/beast/core/bind_handler.hpp>
|
||||||
#include <beast/core/error.hpp>
|
#include <boost/beast/core/error.hpp>
|
||||||
#include <beast/websocket/teardown.hpp>
|
#include <boost/beast/websocket/teardown.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
@ -157,5 +160,6 @@ public:
|
|||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,20 +4,23 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_TEST_STRING_OSTREAM_HPP
|
#ifndef BOOST_BEAST_TEST_STRING_OSTREAM_HPP
|
||||||
#define BEAST_TEST_STRING_OSTREAM_HPP
|
#define BOOST_BEAST_TEST_STRING_OSTREAM_HPP
|
||||||
|
|
||||||
#include <beast/core/async_result.hpp>
|
#include <boost/beast/core/async_result.hpp>
|
||||||
#include <beast/core/bind_handler.hpp>
|
#include <boost/beast/core/bind_handler.hpp>
|
||||||
#include <beast/core/buffer_prefix.hpp>
|
#include <boost/beast/core/buffer_prefix.hpp>
|
||||||
#include <beast/core/error.hpp>
|
#include <boost/beast/core/error.hpp>
|
||||||
#include <beast/websocket/teardown.hpp>
|
#include <boost/beast/websocket/teardown.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
@ -145,5 +148,6 @@ public:
|
|||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,14 +4,17 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_TEST_TEST_ALLOCATOR_HPP
|
#ifndef BOOST_BEAST_TEST_TEST_ALLOCATOR_HPP
|
||||||
#define BEAST_TEST_TEST_ALLOCATOR_HPP
|
#define BOOST_BEAST_TEST_TEST_ALLOCATOR_HPP
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
@ -162,5 +165,6 @@ public:
|
|||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_TEST_YIELD_TO_HPP
|
#ifndef BOOST_BEAST_TEST_YIELD_TO_HPP
|
||||||
#define BEAST_TEST_YIELD_TO_HPP
|
#define BOOST_BEAST_TEST_YIELD_TO_HPP
|
||||||
|
|
||||||
#include <boost/asio/io_service.hpp>
|
#include <boost/asio/io_service.hpp>
|
||||||
#include <boost/asio/spawn.hpp>
|
#include <boost/asio/spawn.hpp>
|
||||||
@ -17,6 +19,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
@ -78,7 +81,7 @@ public:
|
|||||||
|
|
||||||
@param fn... One or more functions to invoke.
|
@param fn... One or more functions to invoke.
|
||||||
*/
|
*/
|
||||||
#if BEAST_DOXYGEN
|
#if BOOST_BEAST_DOXYGEN
|
||||||
template<class... FN>
|
template<class... FN>
|
||||||
void
|
void
|
||||||
yield_to(FN&&... fn)
|
yield_to(FN&&... fn)
|
||||||
@ -130,5 +133,6 @@ spawn(F0&& f, FN&&... fn)
|
|||||||
|
|
||||||
} // test
|
} // test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,14 +4,17 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_AMOUNT_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_AMOUNT_HPP
|
||||||
#define BEAST_UNIT_TEST_AMOUNT_HPP
|
#define BOOST_BEAST_UNIT_TEST_AMOUNT_HPP
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -51,5 +54,6 @@ operator<<(std::ostream& s, amount const& t)
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,10 +4,13 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_DETAIL_CONST_CONTAINER_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_DETAIL_CONST_CONTAINER_HPP
|
||||||
#define BEAST_UNIT_TEST_DETAIL_CONST_CONTAINER_HPP
|
#define BOOST_BEAST_UNIT_TEST_DETAIL_CONST_CONTAINER_HPP
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
@ -87,5 +90,6 @@ public:
|
|||||||
} // detail
|
} // detail
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_DSTREAM_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_DSTREAM_HPP
|
||||||
#define BEAST_UNIT_TEST_DSTREAM_HPP
|
#define BOOST_BEAST_UNIT_TEST_DSTREAM_HPP
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
@ -20,6 +22,7 @@
|
|||||||
//#include <boost/detail/winapi/debugapi.hpp>
|
//#include <boost/detail/winapi/debugapi.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -122,5 +125,6 @@ using dwstream = std::wostream&;
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,12 +4,15 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_GLOBAL_SUITES_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_GLOBAL_SUITES_HPP
|
||||||
#define BEAST_UNIT_TEST_GLOBAL_SUITES_HPP
|
#define BOOST_BEAST_UNIT_TEST_GLOBAL_SUITES_HPP
|
||||||
|
|
||||||
#include <beast/unit_test/suite_list.hpp>
|
#include <boost/beast/unit_test/suite_list.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -47,5 +50,6 @@ global_suites()
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,13 +4,15 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#include <beast/unit_test/amount.hpp>
|
#include <boost/beast/unit_test/amount.hpp>
|
||||||
#include <beast/unit_test/dstream.hpp>
|
#include <boost/beast/unit_test/dstream.hpp>
|
||||||
#include <beast/unit_test/global_suites.hpp>
|
#include <boost/beast/unit_test/global_suites.hpp>
|
||||||
#include <beast/unit_test/match.hpp>
|
#include <boost/beast/unit_test/match.hpp>
|
||||||
#include <beast/unit_test/reporter.hpp>
|
#include <boost/beast/unit_test/reporter.hpp>
|
||||||
#include <beast/unit_test/suite.hpp>
|
#include <boost/beast/unit_test/suite.hpp>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -27,6 +29,7 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -71,13 +74,14 @@ print(std::ostream& os)
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
// Simple main used to produce stand
|
// Simple main used to produce stand
|
||||||
// alone executables that run unit tests.
|
// alone executables that run unit tests.
|
||||||
int main(int ac, char const* av[])
|
int main(int ac, char const* av[])
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace beast::unit_test;
|
using namespace boost::beast::unit_test;
|
||||||
|
|
||||||
#if BOOST_MSVC
|
#if BOOST_MSVC
|
||||||
{
|
{
|
@ -4,13 +4,16 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_MATCH_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_MATCH_HPP
|
||||||
#define BEAST_UNIT_TEST_MATCH_HPP
|
#define BOOST_BEAST_UNIT_TEST_MATCH_HPP
|
||||||
|
|
||||||
#include <beast/unit_test/suite_info.hpp>
|
#include <boost/beast/unit_test/suite_info.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -169,5 +172,6 @@ match_library(std::string const& name)
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,13 +4,16 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_RECORDER_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_RECORDER_HPP
|
||||||
#define BEAST_UNIT_TEST_RECORDER_HPP
|
#define BOOST_BEAST_UNIT_TEST_RECORDER_HPP
|
||||||
|
|
||||||
#include <beast/unit_test/results.hpp>
|
#include <boost/beast/unit_test/results.hpp>
|
||||||
#include <beast/unit_test/runner.hpp>
|
#include <boost/beast/unit_test/runner.hpp>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -88,5 +91,6 @@ private:
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,12 +4,14 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_REPORTER_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_REPORTER_HPP
|
||||||
#define BEAST_UNIT_TEST_REPORTER_HPP
|
#define BOOST_BEAST_UNIT_TEST_REPORTER_HPP
|
||||||
|
|
||||||
#include <beast/unit_test/amount.hpp>
|
#include <boost/beast/unit_test/amount.hpp>
|
||||||
#include <beast/unit_test/recorder.hpp>
|
#include <boost/beast/unit_test/recorder.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -21,6 +23,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -291,5 +294,6 @@ using reporter = detail::reporter<>;
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,15 +4,18 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_RESULTS_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_RESULTS_HPP
|
||||||
#define BEAST_UNIT_TEST_RESULTS_HPP
|
#define BOOST_BEAST_UNIT_TEST_RESULTS_HPP
|
||||||
|
|
||||||
#include <beast/unit_test/detail/const_container.hpp>
|
#include <boost/beast/unit_test/detail/const_container.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -238,5 +241,6 @@ public:
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,16 +4,19 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_RUNNER_H_INCLUDED
|
#ifndef BOOST_BEAST_UNIT_TEST_RUNNER_H_INCLUDED
|
||||||
#define BEAST_UNIT_TEST_RUNNER_H_INCLUDED
|
#define BOOST_BEAST_UNIT_TEST_RUNNER_H_INCLUDED
|
||||||
|
|
||||||
#include <beast/unit_test/suite_info.hpp>
|
#include <boost/beast/unit_test/suite_info.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -284,5 +287,6 @@ runner::log(std::string const& s)
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,11 +4,13 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_SUITE_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_SUITE_HPP
|
||||||
#define BEAST_UNIT_TEST_SUITE_HPP
|
#define BOOST_BEAST_UNIT_TEST_SUITE_HPP
|
||||||
|
|
||||||
#include <beast/unit_test/runner.hpp>
|
#include <boost/beast/unit_test/runner.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
@ -16,6 +18,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -52,7 +55,7 @@ enum abort_t
|
|||||||
|
|
||||||
Derived classes execute a series of testcases, where each testcase is
|
Derived classes execute a series of testcases, where each testcase is
|
||||||
a series of pass/fail tests. To provide a unit test using this class,
|
a series of pass/fail tests. To provide a unit test using this class,
|
||||||
derive from it and use the BEAST_DEFINE_UNIT_TEST macro in a
|
derive from it and use the BOOST_BEAST_DEFINE_UNIT_TEST macro in a
|
||||||
translation unit.
|
translation unit.
|
||||||
*/
|
*/
|
||||||
class suite
|
class suite
|
||||||
@ -599,31 +602,32 @@ run(runner& r)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BEAST_EXPECT
|
#ifndef BOOST_BEAST_EXPECT
|
||||||
/** Check a precondition.
|
/** Check a precondition.
|
||||||
|
|
||||||
If the condition is false, the file and line number are reported.
|
If the condition is false, the file and line number are reported.
|
||||||
*/
|
*/
|
||||||
#define BEAST_EXPECT(cond) expect(cond, __FILE__, __LINE__)
|
#define BOOST_BEAST_EXPECT(cond) expect(cond, __FILE__, __LINE__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BEAST_EXPECTS
|
#ifndef BOOST_BEAST_EXPECTS
|
||||||
/** Check a precondition.
|
/** Check a precondition.
|
||||||
|
|
||||||
If the condition is false, the file and line number are reported.
|
If the condition is false, the file and line number are reported.
|
||||||
*/
|
*/
|
||||||
#define BEAST_EXPECTS(cond, reason) ((cond) ? (pass(), true) : \
|
#define BOOST_BEAST_EXPECTS(cond, reason) ((cond) ? (pass(), true) : \
|
||||||
(fail((reason), __FILE__, __LINE__), false))
|
(fail((reason), __FILE__, __LINE__), false))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// detail:
|
// detail:
|
||||||
// This inserts the suite with the given manual flag
|
// This inserts the suite with the given manual flag
|
||||||
#define BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,manual) \
|
#define BOOST_BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,manual) \
|
||||||
static beast::unit_test::detail::insert_suite <Class##_test> \
|
static beast::unit_test::detail::insert_suite <Class##_test> \
|
||||||
Library ## Module ## Class ## _test_instance( \
|
Library ## Module ## Class ## _test_instance( \
|
||||||
#Class, #Module, #Library, manual)
|
#Class, #Module, #Library, manual)
|
||||||
@ -635,15 +639,15 @@ run(runner& r)
|
|||||||
// If this is already defined, don't redefine it. This allows
|
// If this is already defined, don't redefine it. This allows
|
||||||
// programs to provide custom behavior for testsuite definitions
|
// programs to provide custom behavior for testsuite definitions
|
||||||
//
|
//
|
||||||
#ifndef BEAST_DEFINE_TESTSUITE
|
#ifndef BOOST_BEAST_DEFINE_TESTSUITE
|
||||||
|
|
||||||
/** Enables insertion of test suites into the global container.
|
/** Enables insertion of test suites into the global container.
|
||||||
The default is to insert all test suite definitions into the global
|
The default is to insert all test suite definitions into the global
|
||||||
container. If BEAST_DEFINE_TESTSUITE is user defined, this macro
|
container. If BOOST_BEAST_DEFINE_TESTSUITE is user defined, this macro
|
||||||
has no effect.
|
has no effect.
|
||||||
*/
|
*/
|
||||||
#ifndef BEAST_NO_UNIT_TEST_INLINE
|
#ifndef BOOST_BEAST_NO_UNIT_TEST_INLINE
|
||||||
#define BEAST_NO_UNIT_TEST_INLINE 0
|
#define BOOST_BEAST_NO_UNIT_TEST_INLINE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** Define a unit test suite.
|
/** Define a unit test suite.
|
||||||
@ -668,15 +672,15 @@ run(runner& r)
|
|||||||
The macro invocation must appear in the same namespace as the test class.
|
The macro invocation must appear in the same namespace as the test class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if BEAST_NO_UNIT_TEST_INLINE
|
#if BOOST_BEAST_NO_UNIT_TEST_INLINE
|
||||||
#define BEAST_DEFINE_TESTSUITE(Class,Module,Library)
|
#define BOOST_BEAST_DEFINE_TESTSUITE(Class,Module,Library)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <beast/unit_test/global_suites.hpp>
|
#include <boost/beast/unit_test/global_suites.hpp>
|
||||||
#define BEAST_DEFINE_TESTSUITE(Class,Module,Library) \
|
#define BOOST_BEAST_DEFINE_TESTSUITE(Class,Module,Library) \
|
||||||
BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,false)
|
BOOST_BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,false)
|
||||||
#define BEAST_DEFINE_TESTSUITE_MANUAL(Class,Module,Library) \
|
#define BOOST_BEAST_DEFINE_TESTSUITE_MANUAL(Class,Module,Library) \
|
||||||
BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,true)
|
BOOST_BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,true)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -4,15 +4,18 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_SUITE_INFO_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_SUITE_INFO_HPP
|
||||||
#define BEAST_UNIT_TEST_SUITE_INFO_HPP
|
#define BOOST_BEAST_UNIT_TEST_SUITE_INFO_HPP
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -118,5 +121,6 @@ make_suite_info(
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,17 +4,20 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_SUITE_LIST_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_SUITE_LIST_HPP
|
||||||
#define BEAST_UNIT_TEST_SUITE_LIST_HPP
|
#define BOOST_BEAST_UNIT_TEST_SUITE_LIST_HPP
|
||||||
|
|
||||||
#include <beast/unit_test/suite_info.hpp>
|
#include <boost/beast/unit_test/suite_info.hpp>
|
||||||
#include <beast/unit_test/detail/const_container.hpp>
|
#include <boost/beast/unit_test/detail/const_container.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <typeindex>
|
#include <typeindex>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -72,6 +75,7 @@ suite_list::insert(
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -4,15 +4,18 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_UNIT_TEST_THREAD_HPP
|
#ifndef BOOST_BEAST_UNIT_TEST_THREAD_HPP
|
||||||
#define BEAST_UNIT_TEST_THREAD_HPP
|
#define BOOST_BEAST_UNIT_TEST_THREAD_HPP
|
||||||
|
|
||||||
#include <beast/unit_test/suite.hpp>
|
#include <boost/beast/unit_test/suite.hpp>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace unit_test {
|
namespace unit_test {
|
||||||
|
|
||||||
@ -120,5 +123,6 @@ private:
|
|||||||
|
|
||||||
} // unit_test
|
} // unit_test
|
||||||
} // beast
|
} // beast
|
||||||
|
} // boost
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,19 +0,0 @@
|
|||||||
//
|
|
||||||
// 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_HPP
|
|
||||||
#define BEAST_HPP
|
|
||||||
|
|
||||||
#include <beast/config.hpp>
|
|
||||||
|
|
||||||
#include <beast/core.hpp>
|
|
||||||
#include <beast/http.hpp>
|
|
||||||
#include <beast/version.hpp>
|
|
||||||
#include <beast/websocket.hpp>
|
|
||||||
#include <beast/zlib.hpp>
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,40 +0,0 @@
|
|||||||
//
|
|
||||||
// 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_CORE_HPP
|
|
||||||
#define BEAST_CORE_HPP
|
|
||||||
|
|
||||||
#include <beast/config.hpp>
|
|
||||||
|
|
||||||
#include <beast/core/async_result.hpp>
|
|
||||||
#include <beast/core/bind_handler.hpp>
|
|
||||||
#include <beast/core/buffer_cat.hpp>
|
|
||||||
#include <beast/core/buffer_prefix.hpp>
|
|
||||||
#include <beast/core/buffered_read_stream.hpp>
|
|
||||||
#include <beast/core/buffers_adapter.hpp>
|
|
||||||
#include <beast/core/consuming_buffers.hpp>
|
|
||||||
#include <beast/core/drain_buffer.hpp>
|
|
||||||
#include <beast/core/error.hpp>
|
|
||||||
#include <beast/core/file.hpp>
|
|
||||||
#include <beast/core/file_base.hpp>
|
|
||||||
#include <beast/core/file_posix.hpp>
|
|
||||||
#include <beast/core/file_stdio.hpp>
|
|
||||||
#include <beast/core/file_win32.hpp>
|
|
||||||
#include <beast/core/flat_buffer.hpp>
|
|
||||||
#include <beast/core/handler_alloc.hpp>
|
|
||||||
#include <beast/core/handler_ptr.hpp>
|
|
||||||
#include <beast/core/multi_buffer.hpp>
|
|
||||||
#include <beast/core/ostream.hpp>
|
|
||||||
#include <beast/core/read_size.hpp>
|
|
||||||
#include <beast/core/span.hpp>
|
|
||||||
#include <beast/core/flat_static_buffer.hpp>
|
|
||||||
#include <beast/core/static_string.hpp>
|
|
||||||
#include <beast/core/string.hpp>
|
|
||||||
#include <beast/core/string_param.hpp>
|
|
||||||
#include <beast/core/type_traits.hpp>
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,36 +0,0 @@
|
|||||||
//
|
|
||||||
// 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_HTTP_HPP
|
|
||||||
#define BEAST_HTTP_HPP
|
|
||||||
|
|
||||||
#include <beast/config.hpp>
|
|
||||||
|
|
||||||
#include <beast/http/basic_dynamic_body.hpp>
|
|
||||||
#include <beast/http/basic_parser.hpp>
|
|
||||||
#include <beast/http/buffer_body.hpp>
|
|
||||||
#include <beast/http/chunk_encode.hpp>
|
|
||||||
#include <beast/http/dynamic_body.hpp>
|
|
||||||
#include <beast/http/empty_body.hpp>
|
|
||||||
#include <beast/http/error.hpp>
|
|
||||||
#include <beast/http/field.hpp>
|
|
||||||
#include <beast/http/fields.hpp>
|
|
||||||
#include <beast/http/file_body.hpp>
|
|
||||||
#include <beast/http/message.hpp>
|
|
||||||
#include <beast/http/parser.hpp>
|
|
||||||
#include <beast/http/read.hpp>
|
|
||||||
#include <beast/http/rfc7230.hpp>
|
|
||||||
#include <beast/http/serializer.hpp>
|
|
||||||
#include <beast/http/span_body.hpp>
|
|
||||||
#include <beast/http/status.hpp>
|
|
||||||
#include <beast/http/string_body.hpp>
|
|
||||||
#include <beast/http/type_traits.hpp>
|
|
||||||
#include <beast/http/vector_body.hpp>
|
|
||||||
#include <beast/http/verb.hpp>
|
|
||||||
#include <beast/http/write.hpp>
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,26 +0,0 @@
|
|||||||
//
|
|
||||||
// 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_VERSION_HPP
|
|
||||||
#define BEAST_VERSION_HPP
|
|
||||||
|
|
||||||
#include <beast/config.hpp>
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
|
|
||||||
/** @def BEAST_API_VERSION
|
|
||||||
|
|
||||||
Identifies the API version of Beast.
|
|
||||||
|
|
||||||
This is a simple integer that is incremented by one every time
|
|
||||||
a set of code changes is merged to the master or develop branch.
|
|
||||||
*/
|
|
||||||
#define BEAST_VERSION 85
|
|
||||||
|
|
||||||
#define BEAST_VERSION_STRING "Beast/" BOOST_STRINGIZE(BEAST_VERSION)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
|||||||
//
|
|
||||||
// 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_WEBSOCKET_HPP
|
|
||||||
#define BEAST_WEBSOCKET_HPP
|
|
||||||
|
|
||||||
#include <beast/config.hpp>
|
|
||||||
|
|
||||||
#include <beast/websocket/error.hpp>
|
|
||||||
#include <beast/websocket/option.hpp>
|
|
||||||
#include <beast/websocket/rfc6455.hpp>
|
|
||||||
#include <beast/websocket/stream.hpp>
|
|
||||||
#include <beast/websocket/teardown.hpp>
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,18 +0,0 @@
|
|||||||
//
|
|
||||||
// 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_ZLIB_HPP
|
|
||||||
#define BEAST_ZLIB_HPP
|
|
||||||
|
|
||||||
#include <beast/config.hpp>
|
|
||||||
|
|
||||||
#include <beast/zlib/deflate_stream.hpp>
|
|
||||||
#include <beast/zlib/error.hpp>
|
|
||||||
#include <beast/zlib/inflate_stream.hpp>
|
|
||||||
#include <beast/zlib/zlib.hpp>
|
|
||||||
|
|
||||||
#endif
|
|
21
include/boost/beast.hpp
Normal file
21
include/boost/beast.hpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// 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)
|
||||||
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BOOST_BEAST_HPP
|
||||||
|
#define BOOST_BEAST_HPP
|
||||||
|
|
||||||
|
#include <boost/beast/config.hpp> // must come first
|
||||||
|
|
||||||
|
#include <boost/beast/core.hpp>
|
||||||
|
#include <boost/beast/http.hpp>
|
||||||
|
#include <boost/beast/version.hpp>
|
||||||
|
#include <boost/beast/websocket.hpp>
|
||||||
|
#include <boost/beast/zlib.hpp>
|
||||||
|
|
||||||
|
#endif
|
@ -4,9 +4,11 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
//
|
//
|
||||||
|
// Official repository: https://github.com/boostorg/beast
|
||||||
|
//
|
||||||
|
|
||||||
#ifndef BEAST_CONFIG_HPP
|
#ifndef BOOST_BEAST_CONFIG_HPP
|
||||||
#define BEAST_CONFIG_HPP
|
#define BOOST_BEAST_CONFIG_HPP
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user