From 4469ff4b9a44f37fc33b5d03e375cb9cb6d44e04 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Tue, 19 Apr 2016 20:29:16 -0400 Subject: [PATCH] Reorganize source files --- Builds/VisualStudio2015/RippleD.vcxproj | 622 ++- .../VisualStudio2015/RippleD.vcxproj.filters | 949 ++-- SConstruct | 26 +- src/beast/.gitignore | 4 - src/beast/.travis.yml | 26 - src/beast/BeastConfig.h | 139 - src/beast/Jamroot | 1 + src/beast/README.md | 13 +- src/beast/TODO.txt | 20 +- src/beast/beast/asio.h | 38 - src/beast/beast/asio/buffers_debug.h | 51 - src/beast/beast/asio/placeholders.h | 41 - .../src/test/beast_asio_bind_handler_test.cpp | 48 - .../asio/src/test/beast_asio_buffers_test.cpp | 362 -- src/beast/beast/asio/streambuf.h | 31 - src/beast/beast/asio/temp_buffer.h | 109 - src/beast/beast/crypto/sha.h | 34 - src/beast/beast/empty_base_optimization.h | 111 - src/beast/beast/http.h | 39 - src/beast/beast/http/body.h | 150 - src/beast/beast/http/empty_body.h | 87 - src/beast/beast/http/headers.h | 38 - src/beast/beast/http/impl/README.md | 3 - .../beast/http/impl/http-parser/.gitignore | 30 - .../beast/http/impl/http-parser/.mailmap | 8 - .../beast/http/impl/http-parser/.travis.yml | 13 - .../beast/http/impl/http-parser/Makefile | 149 - src/beast/beast/http/impl/http-parser/bench.c | 111 - .../impl/http-parser/contrib/parsertrace.c | 160 - .../impl/http-parser/contrib/url_parser.c | 47 - .../http/impl/http-parser/http_parser.gyp | 111 - src/beast/beast/http/impl/http-parser/test.c | 4127 ----------------- src/beast/beast/http/parser.h | 282 -- src/beast/beast/http/resume_context.h | 46 - .../http/src/beast_http_nodejs_parser.cpp | 90 - src/beast/beast/http/src/nodejs_parser.h | 45 - .../http/src/test/beast_http_parser_test.cpp | 94 - src/beast/beast/http/type_check.h | 84 - src/beast/beast/streams/abstract_ostream.h | 32 - src/beast/beast/streams/basic_std_ostream.h | 73 - src/beast/beast/streams/debug_ostream.h | 91 - .../beast_basic_abstract_ostream_test.cpp | 66 - src/beast/beast/unit_test/README.md | 3 - src/beast/beast/unit_test/amount.h | 67 - src/beast/beast/unit_test/global_suites.h | 68 - src/beast/beast/unit_test/print.h | 80 - src/beast/beast/unity/beast_asio_unity.cpp | 22 - src/beast/beast/unity/beast_crypto_unity.cpp | 21 - src/beast/beast/unity/beast_http_unity.cpp | 27 - src/beast/beast/unity/beast_streams_unity.cpp | 20 - src/beast/beast/unity/beast_test_unity.cpp | 20 - src/beast/beast/unity/beast_wsproto_unity.cpp | 21 - src/beast/beast/wsproto.h | 30 - src/beast/beast/wsproto/README.md | 232 - src/beast/beast/wsproto/detail/hybi13.h | 66 - src/beast/beast/wsproto/error.h | 72 - src/beast/beast/wsproto/impl/error.ipp | 39 - .../beast/wsproto/src/test/async_echo_peer.h | 285 -- .../src/test/beast_wsproto_ws_echo_test.cpp | 94 - .../src/test/beast_wsproto_ws_test.cpp | 362 -- .../beast/wsproto/src/test/sync_echo_peer.h | 182 - src/beast/examples/Jamfile | 6 +- src/beast/examples/file_body.h | 4 +- src/beast/examples/http_async_server.h | 2 +- src/beast/examples/http_server_response.h | 31 - src/beast/examples/http_stream.h | 4 +- src/beast/examples/http_stream.ipp | 12 +- src/beast/examples/http_sync_server.h | 1 - src/beast/examples/wsproto_async_echo_peer.h | 20 +- src/beast/examples/wsproto_echo.cpp | 25 +- src/beast/examples/wsproto_sync_echo_peer.h | 16 +- .../beast/async_completion.hpp} | 30 +- .../beast/basic_streambuf.hpp} | 34 +- .../beast/bind_handler.hpp} | 30 +- .../beast/buffer_cat.hpp} | 76 +- .../beast/buffers_adapter.hpp} | 28 +- src/beast/include/beast/buffers_debug.hpp | 39 + .../beast/consuming_buffers.hpp} | 30 +- .../beast/detail/base64.hpp} | 38 +- .../beast/detail/ci_char_traits.hpp} | 38 +- .../beast/detail/const_container.hpp} | 30 +- .../beast/detail/empty_base_optimization.hpp | 94 + .../beast/detail/is_call_possible.hpp} | 39 +- .../beast/detail/sha1.hpp} | 36 +- .../beast/detail/stream/abstract_ostream.hpp | 22 + .../detail/stream/basic_abstract_ostream.hpp} | 35 +- .../detail/stream/basic_scoped_ostream.hpp} | 34 +- .../beast/detail/stream/basic_std_ostream.hpp | 62 + .../beast/detail/stream/debug_ostream.hpp | 80 + .../beast/detail/temp_dir.hpp} | 30 +- src/beast/include/beast/detail/unit_test.h | 23 + .../include/beast/detail/unit_test/amount.hpp | 59 + .../beast/detail}/unit_test/define_print.cpp | 40 +- .../beast/detail/unit_test/global_suites.hpp | 60 + .../beast/detail/unit_test/match.hpp} | 35 +- .../include/beast/detail/unit_test/print.hpp | 71 + .../beast/detail/unit_test/recorder.hpp} | 36 +- .../beast/detail/unit_test/reporter.hpp} | 46 +- .../beast/detail/unit_test/results.hpp} | 34 +- .../beast/detail/unit_test/runner.hpp} | 38 +- .../beast/detail/unit_test/suite.hpp} | 38 +- .../beast/detail/unit_test/suite_info.hpp} | 32 +- .../beast/detail/unit_test/suite_list.hpp} | 36 +- .../beast/detail/unit_test/thread.hpp} | 34 +- .../beast/handler_alloc.hpp} | 28 +- src/beast/include/beast/http.hpp | 29 + .../beast/http/basic_headers.hpp} | 44 +- .../beast/http/basic_parser.hpp} | 50 +- .../beast/http/chunk_encode.hpp} | 28 +- .../beast/http/detail/error.hpp} | 30 +- .../beast/http/detail/write_preparation.hpp} | 30 +- .../beast/http/detail/writes.hpp} | 30 +- src/beast/include/beast/http/empty_body.hpp | 75 + .../beast/http/error.hpp} | 16 +- .../beast/http/fields.hpp} | 0 src/beast/include/beast/http/headers.hpp | 26 + .../beast/http/impl/basic_headers.ipp | 36 +- .../beast/http/impl/basic_parser.ipp | 98 +- .../beast/http/impl}/http_parser.h | 14 +- .../{ => include}/beast/http/impl/message.ipp | 38 +- .../{ => include}/beast/http/impl/read.ipp | 36 +- .../{ => include}/beast/http/impl/write.ipp | 60 +- src/beast/include/beast/http/message.hpp | 170 + .../beast/http/method.hpp} | 28 +- src/beast/include/beast/http/parser.hpp | 155 + .../read.h => include/beast/http/read.hpp} | 34 +- .../beast/http/reason.hpp} | 28 +- .../include/beast/http/resume_context.hpp | 34 + .../beast/http/rfc2616.hpp} | 28 +- .../beast/http/streambuf_body.hpp} | 36 +- .../beast/http/string_body.hpp} | 38 +- src/beast/include/beast/http/type_check.hpp | 72 + .../write.h => include/beast/http/write.hpp} | 32 +- .../beast}/impl/basic_streambuf.ipp | 32 +- .../beast}/impl/streambuf_readstream.ipp | 36 +- src/beast/include/beast/placeholders.hpp | 29 + .../beast/prepare_buffers.hpp} | 28 +- .../beast/static_streambuf.hpp} | 28 +- .../asio.cpp => include/beast/streambuf.hpp} | 14 +- .../beast/streambuf_readstream.hpp} | 32 +- .../beast/type_check.hpp} | 97 +- .../error.h => include/beast/websocket.hpp} | 19 +- .../beast/websocket/detail/debug.hpp} | 2 +- .../beast/websocket/detail/decorator.hpp} | 38 +- .../beast/websocket/detail/error.hpp} | 36 +- .../beast/websocket/detail/frame.hpp} | 42 +- .../include/beast/websocket/detail/hybi13.hpp | 57 + .../beast/websocket/detail/invokable.hpp} | 32 +- .../beast/websocket/detail/mask.hpp} | 8 +- .../beast/websocket/detail/stream_base.hpp} | 66 +- .../beast/websocket/detail/utf8_checker.hpp} | 32 +- src/beast/include/beast/websocket/error.hpp | 60 + .../beast/websocket}/impl/accept_op.ipp | 56 +- .../beast/websocket}/impl/close_op.ipp | 50 +- .../include/beast/websocket/impl/error.ipp | 27 + .../beast/websocket}/impl/handshake_op.ipp | 56 +- .../beast/websocket}/impl/read_frame_op.ipp | 54 +- .../beast/websocket}/impl/read_op.ipp | 48 +- .../beast/websocket}/impl/response_op.ipp | 52 +- .../beast/websocket}/impl/socket.ipp | 184 +- .../beast/websocket}/impl/ssl.ipp | 36 +- .../beast/websocket}/impl/teardown.ipp | 36 +- .../beast/websocket}/impl/write_frame_op.ipp | 62 +- .../beast/websocket}/impl/write_op.ipp | 55 +- .../beast/websocket/option.hpp} | 36 +- .../beast/websocket/rfc6455.hpp} | 34 +- .../ssl.h => include/beast/websocket/ssl.hpp} | 36 +- .../beast/websocket/static_string.hpp} | 8 +- .../beast/websocket/stream.hpp} | 151 +- .../beast/websocket/teardown.hpp} | 20 +- src/beast/src/beast_http_nodejs_parser.cpp | 17 + .../http/impl => src}/http-parser/AUTHORS | 0 .../http/impl => src}/http-parser/LICENSE-MIT | 0 .../http/impl => src}/http-parser/README.md | 0 .../impl => src}/http-parser/http_parser.c | 9 +- src/beast/test/Jamfile | 13 +- src/beast/test/async_completion.cpp | 2 +- .../beast_base64_test.cpp => test/base64.cpp} | 15 +- src/beast/test/basic_headers.cpp | 6 +- src/beast/test/basic_streambuf.cpp | 2 +- src/beast/test/beast_wsproto_ws_test.cpp | 358 -- src/beast/test/bind_handler.cpp | 30 +- .../{append_buffers.cpp => buffer_cat.cpp} | 20 +- src/beast/test/buffers_adapter.cpp | 8 +- src/beast/test/buffers_debug.cpp | 2 +- .../chunk_encode.cpp} | 8 +- src/beast/test/consuming_buffers.cpp | 8 +- .../empty_base_optimization.cpp} | 12 +- src/beast/test/handler_alloc.cpp | 2 +- .../{beast/unit_test/src => test}/main.cpp | 9 +- .../message.cpp} | 30 +- src/beast/test/placeholders.cpp | 2 +- src/beast/test/prepare_buffers.cpp | 12 +- .../rfc2616.cpp} | 7 +- src/beast/test/ssl_error.cpp | 43 - src/beast/test/static_streambuf.cpp | 10 +- src/beast/test/streambuf.cpp | 8 +- src/beast/test/streambuf_readstream.cpp | 2 +- src/beast/test/type_check.cpp | 2 +- src/ripple/app/ledger/InboundTransactions.h | 2 +- src/ripple/app/ledger/Ledger.cpp | 2 +- src/ripple/app/ledger/LedgerProposal.h | 2 +- src/ripple/app/main/Application.cpp | 2 +- src/ripple/app/main/Main.cpp | 8 +- src/ripple/app/tests/AccountTxPaging.test.cpp | 2 +- src/ripple/app/tests/AmendmentTable.test.cpp | 2 +- src/ripple/app/tests/CrossingLimits_test.cpp | 2 +- src/ripple/app/tests/DeliverMin.test.cpp | 2 +- src/ripple/app/tests/HashRouter_test.cpp | 2 +- src/ripple/app/tests/OfferStream.test.cpp | 2 +- src/ripple/app/tests/OversizeMeta_test.cpp | 2 +- src/ripple/app/tests/Path_test.cpp | 2 +- src/ripple/app/tests/Taker.test.cpp | 2 +- src/ripple/basics/BasicConfig.h | 10 +- src/ripple/basics/KeyCache.h | 2 +- src/ripple/basics/Log.h | 4 +- src/ripple/basics/TaggedCache.h | 2 +- src/ripple/basics/TestSuite.h | 2 +- src/ripple/basics/UnorderedContainers.h | 6 +- src/ripple/basics/chrono.h | 6 +- src/ripple/basics/hardened_hash.h | 4 +- .../basics/impl/CheckLibraryVersions.cpp | 2 +- src/ripple/basics/impl/RangeSet.cpp | 2 +- src/ripple/basics/impl/ResolverAsio.cpp | 2 +- src/ripple/basics/impl/StringUtilities.cpp | 2 +- src/ripple/basics/random.h | 6 +- .../tests/CheckLibraryVersions.test.cpp | 2 +- src/ripple/basics/tests/KeyCache.test.cpp | 4 +- src/ripple/basics/tests/RangeSet.test.cpp | 2 +- .../basics/tests/StringUtilities.test.cpp | 2 +- src/ripple/basics/tests/TaggedCache.test.cpp | 4 +- src/ripple/basics/tests/contract.test.cpp | 2 +- .../basics/tests/hardened_hash_test.cpp | 2 +- src/ripple/basics/tests/mulDiv.test.cpp | 2 +- .../beast/asio/io_latency_probe.h | 0 src/{beast => ripple}/beast/asio/ssl_bundle.h | 0 src/{beast => ripple}/beast/asio/ssl_error.h | 0 .../beast/clock/abstract_clock.h | 0 .../beast/clock/basic_seconds_clock.h | 2 +- .../beast/clock/chrono_util.h | 0 .../beast/clock/manual_clock.h | 2 +- .../clock/tests/beast_abstract_clock_test.cpp | 6 +- .../tests/beast_basic_seconds_clock_test.cpp | 4 +- .../container/detail/aged_ordered_container.h | 58 +- .../detail/aged_unordered_container.h | 56 +- .../tests/aged_associative_container.test.cpp | 4 +- src/ripple/beast/core/LexicalCast.cpp | 4 +- src/ripple/beast/core/List.h | 2 +- src/ripple/beast/core/RelativeTime.cpp | 2 +- src/ripple/beast/core/SemanticVersion.cpp | 2 +- .../beast/crypto/detail/mac_facade.h | 4 +- .../beast/crypto/detail/ripemd_context.h | 0 .../beast/crypto/detail/sha2_context.h | 0 src/{beast => ripple}/beast/crypto/ripemd.h | 4 +- .../beast/crypto/secure_erase.h | 0 src/{beast => ripple}/beast/crypto/sha2.h | 4 +- .../beast/cxx17/type_traits.h | 0 .../beast/deprecated_http.h} | 392 +- src/{beast => ripple}/beast/hash/endian.h | 0 src/{beast => ripple}/beast/hash/fnv1a.h | 0 .../beast/hash/hash_append.h | 4 +- .../beast/hash/impl/hash_speed_test.cpp | 0 .../beast/hash/impl/siphash.cpp | 2 +- .../beast/hash/impl/spookyv2.cpp | 2 +- .../beast/hash/impl/spookyv2.h | 0 .../beast/hash/impl/xxhash.c | 2 +- .../beast/hash/impl/xxhash.h | 0 src/{beast => ripple}/beast/hash/meta.h | 0 src/{beast => ripple}/beast/hash/siphash.h | 0 src/{beast => ripple}/beast/hash/spooky.h | 4 +- .../beast/hash/tests/hash_append_test.cpp | 12 +- .../beast/hash/tests/hash_metrics.h | 0 .../beast/hash/tests/hash_speed_test.cpp | 10 +- src/{beast => ripple}/beast/hash/uhash.h | 4 +- src/{beast => ripple}/beast/hash/xxhasher.h | 4 +- src/ripple/beast/insight/Event.h | 2 +- src/ripple/beast/insight/impl/Groups.cpp | 2 +- .../beast/insight/impl/StatsDCollector.cpp | 2 +- src/ripple/beast/net/IPAddress.h | 4 +- src/ripple/beast/net/IPAddressV4.h | 2 +- src/ripple/beast/net/IPEndpoint.h | 4 +- src/ripple/beast/net/URL.h | 195 - src/ripple/beast/net/impl/URL.cpp | 231 - .../beast/net/tests/IPEndpoint.test.cpp | 2 +- .../net/tests}/beast_asio_error_test.cpp | 4 +- .../beast/net/tests/beast_http_URL_test.cpp | 63 - .../nudb/test/beast_nudb_callgrind_test.cpp | 8 +- .../nudb/test/beast_nudb_recover_test.cpp | 8 +- .../beast/nudb/test/beast_nudb_store_test.cpp | 8 +- .../nudb/test/beast_nudb_varint_test.cpp | 2 +- .../nudb/test/beast_nudb_verify_test.cpp | 4 +- src/ripple/beast/nudb/test/common.h | 4 +- src/{ => ripple}/beast/site_scons/Beast.py | 0 .../beast/site_scons/site_tools/Protoc.py | 0 .../beast/site_scons/site_tools/VSProject.py | 0 src/{beast => ripple}/beast/type_name.h | 0 src/{beast => ripple}/beast/unit_test.h | 28 +- .../beast/unity/beast_clock_unity.cpp | 4 +- .../beast/unity/beast_hash_unity.cpp | 12 +- src/ripple/beast/unity/beast_net_unity.cpp | 2 - src/ripple/beast/utility/src/beast_Debug.cpp | 2 +- .../utility/src/beast_PropertyStream.cpp | 2 +- src/ripple/beast/utility/tagged_integer.h | 2 +- .../beast/utility/test/beast_Journal_test.cpp | 2 +- .../beast/utility/test/beast_Zero_test.cpp | 2 +- .../test/beast_tagged_integer_test.cpp | 2 +- .../beast/utility/test/beast_weak_fn_test.cpp | 2 +- src/ripple/beast/utility/weak_fn.h | 6 +- .../beast/xor_shift_engine.h | 0 src/ripple/core/Config.h | 3 +- src/ripple/core/TimeKeeper.h | 2 +- src/ripple/core/impl/Config.cpp | 22 +- src/ripple/core/impl/JobQueue.cpp | 2 +- src/ripple/core/impl/SNTPClock.cpp | 2 +- src/ripple/core/impl/SNTPClock.h | 2 +- src/ripple/core/impl/Workers.cpp | 2 +- src/ripple/core/tests/LoadFeeTrack.test.cpp | 2 +- src/ripple/core/tests/Stoppable.test.cpp | 2 +- src/ripple/crypto/tests/CBigNum_test.cpp | 2 +- src/ripple/crypto/tests/CKey.test.cpp | 2 +- src/ripple/json/impl/Writer.cpp | 2 +- src/ripple/json/tests/Object.test.cpp | 2 +- src/ripple/json/tests/Writer.test.cpp | 2 +- src/ripple/json/tests/json_value.test.cpp | 4 +- src/ripple/ledger/ReadView.h | 2 +- src/ripple/ledger/tests/PendingSaves_test.cpp | 2 +- src/ripple/ledger/tests/SkipList_test.cpp | 2 +- src/ripple/net/impl/HTTPClient.cpp | 2 +- src/ripple/net/impl/RPCCall.cpp | 6 +- .../nodestore/backend/MemoryFactory.cpp | 4 +- src/ripple/nodestore/backend/NuDBFactory.cpp | 2 +- src/ripple/nodestore/impl/ManagerImp.cpp | 4 +- src/ripple/nodestore/tests/Backend.test.cpp | 4 +- src/ripple/nodestore/tests/Base.test.h | 4 +- src/ripple/nodestore/tests/Database.test.cpp | 8 +- src/ripple/nodestore/tests/Timing.test.cpp | 10 +- src/ripple/nodestore/tests/import_test.cpp | 14 +- src/ripple/overlay/Cluster.h | 2 +- src/ripple/overlay/Overlay.h | 4 +- src/ripple/overlay/PeerSet.h | 2 +- src/ripple/overlay/impl/ConnectAttempt.h | 10 +- src/ripple/overlay/impl/OverlayImpl.cpp | 12 +- src/ripple/overlay/impl/OverlayImpl.h | 1 + src/ripple/overlay/impl/PeerImp.cpp | 3 +- src/ripple/overlay/impl/PeerImp.h | 10 +- src/ripple/overlay/impl/PeerSet.cpp | 2 +- src/ripple/overlay/impl/TMHello.cpp | 16 +- src/ripple/overlay/impl/TMHello.h | 3 +- src/ripple/overlay/tests/TMHello.test.cpp | 2 +- src/ripple/overlay/tests/short_read.test.cpp | 4 +- src/ripple/peerfinder/PeerfinderManager.h | 2 +- src/ripple/peerfinder/impl/Checker.h | 2 +- .../peerfinder/tests/Livecache.test.cpp | 4 +- .../peerfinder/tests/PeerFinder_test.cpp | 2 +- src/ripple/protocol/HashPrefix.h | 2 +- src/ripple/protocol/STObject.h | 27 - src/ripple/protocol/digest.h | 6 +- src/ripple/protocol/impl/BuildInfo.cpp | 2 +- src/ripple/protocol/impl/STTx.cpp | 2 +- src/ripple/protocol/impl/STVar.cpp | 18 - src/ripple/protocol/impl/STVar.h | 14 - src/ripple/protocol/impl/SecretKey.cpp | 2 +- src/ripple/protocol/impl/Seed.cpp | 2 +- src/ripple/protocol/tests/BuildInfo.test.cpp | 2 +- src/ripple/protocol/tests/IOUAmount.test.cpp | 2 +- .../tests/InnerObjectFormats.test.cpp | 2 +- src/ripple/protocol/tests/Issue.test.cpp | 2 +- src/ripple/protocol/tests/PublicKey_test.cpp | 2 +- src/ripple/protocol/tests/Quality.test.cpp | 2 +- src/ripple/protocol/tests/STAccount.test.cpp | 2 +- src/ripple/protocol/tests/STAmount.test.cpp | 2 +- src/ripple/protocol/tests/STObject.test.cpp | 2 +- src/ripple/protocol/tests/STTx.test.cpp | 2 +- src/ripple/protocol/tests/SecretKey_test.cpp | 2 +- src/ripple/protocol/tests/Seed_test.cpp | 4 +- src/ripple/protocol/tests/XRPAmount.test.cpp | 2 +- src/ripple/protocol/tests/digest_test.cpp | 4 +- src/ripple/protocol/tests/types_test.cpp | 2 +- src/ripple/resource/impl/Entry.h | 2 +- src/ripple/resource/impl/Logic.h | 2 +- src/ripple/resource/tests/Logic.test.cpp | 2 +- src/ripple/rpc/tests/AccountLinesRPC.test.cpp | 2 +- src/ripple/rpc/tests/Book.test.cpp | 2 +- src/ripple/rpc/tests/JSONRPC.test.cpp | 2 +- .../rpc/tests/LedgerRequestRPC.test.cpp | 2 +- .../rpc/tests/RobustTransaction.test.cpp | 2 +- src/ripple/rpc/tests/Status.test.cpp | 2 +- src/ripple/rpc/tests/Subscribe.test.cpp | 2 +- src/ripple/server/Handler.h | 2 +- src/ripple/server/Handoff.h | 4 +- src/ripple/server/JsonWriter.h | 5 +- src/ripple/server/Port.h | 6 +- src/ripple/server/ServerHandler.h | 1 + src/ripple/server/Session.h | 4 +- src/ripple/server/impl/BaseHTTPPeer.h | 12 +- src/ripple/server/impl/BaseWSPeer.h | 12 +- src/ripple/server/impl/Door.cpp | 4 +- src/ripple/server/impl/Door.h | 2 +- src/ripple/server/impl/PlainWSPeer.h | 2 +- src/ripple/server/impl/Port.cpp | 4 +- src/ripple/server/impl/SSLHTTPPeer.h | 2 +- src/ripple/server/impl/SSLWSPeer.h | 8 +- src/ripple/server/impl/ServerHandlerImp.cpp | 6 +- src/ripple/server/tests/Server_test.cpp | 2 +- src/ripple/shamap/impl/SHAMap.cpp | 2 +- src/ripple/shamap/impl/SHAMapSync.cpp | 2 +- src/ripple/shamap/tests/FetchPack.test.cpp | 4 +- src/ripple/shamap/tests/SHAMap.test.cpp | 2 +- src/ripple/shamap/tests/SHAMapSync.test.cpp | 2 +- src/ripple/shamap/tests/common.h | 2 +- src/ripple/test/BasicNetwork.h | 6 +- src/ripple/test/impl/BasicNetwork_test.cpp | 2 +- src/ripple/test/impl/JSONRPCClient.cpp | 5 +- src/ripple/test/impl/WSClient.cpp | 12 +- src/ripple/test/impl/WSClient_test.cpp | 8 +- src/ripple/test/jtx/Account.h | 2 +- src/ripple/test/jtx/Env.h | 8 +- src/ripple/test/jtx/impl/Env_test.cpp | 4 +- src/ripple/unity/beast.cpp | 2 +- src/ripple/websocket/AutoSocket.h | 4 +- src/ripple/websocket/Connection.h | 2 +- src/websocketpp_02/src/sockets/autotls.hpp | 2 +- 422 files changed, 4031 insertions(+), 13217 deletions(-) delete mode 100644 src/beast/.travis.yml delete mode 100644 src/beast/BeastConfig.h delete mode 100644 src/beast/beast/asio.h delete mode 100644 src/beast/beast/asio/buffers_debug.h delete mode 100644 src/beast/beast/asio/placeholders.h delete mode 100644 src/beast/beast/asio/src/test/beast_asio_bind_handler_test.cpp delete mode 100644 src/beast/beast/asio/src/test/beast_asio_buffers_test.cpp delete mode 100644 src/beast/beast/asio/streambuf.h delete mode 100644 src/beast/beast/asio/temp_buffer.h delete mode 100644 src/beast/beast/crypto/sha.h delete mode 100644 src/beast/beast/empty_base_optimization.h delete mode 100644 src/beast/beast/http.h delete mode 100644 src/beast/beast/http/body.h delete mode 100644 src/beast/beast/http/empty_body.h delete mode 100644 src/beast/beast/http/headers.h delete mode 100644 src/beast/beast/http/impl/README.md delete mode 100644 src/beast/beast/http/impl/http-parser/.gitignore delete mode 100644 src/beast/beast/http/impl/http-parser/.mailmap delete mode 100644 src/beast/beast/http/impl/http-parser/.travis.yml delete mode 100644 src/beast/beast/http/impl/http-parser/Makefile delete mode 100644 src/beast/beast/http/impl/http-parser/bench.c delete mode 100644 src/beast/beast/http/impl/http-parser/contrib/parsertrace.c delete mode 100644 src/beast/beast/http/impl/http-parser/contrib/url_parser.c delete mode 100644 src/beast/beast/http/impl/http-parser/http_parser.gyp delete mode 100644 src/beast/beast/http/impl/http-parser/test.c delete mode 100644 src/beast/beast/http/parser.h delete mode 100644 src/beast/beast/http/resume_context.h delete mode 100644 src/beast/beast/http/src/beast_http_nodejs_parser.cpp delete mode 100644 src/beast/beast/http/src/nodejs_parser.h delete mode 100644 src/beast/beast/http/src/test/beast_http_parser_test.cpp delete mode 100644 src/beast/beast/http/type_check.h delete mode 100644 src/beast/beast/streams/abstract_ostream.h delete mode 100644 src/beast/beast/streams/basic_std_ostream.h delete mode 100644 src/beast/beast/streams/debug_ostream.h delete mode 100644 src/beast/beast/streams/tests/beast_basic_abstract_ostream_test.cpp delete mode 100644 src/beast/beast/unit_test/README.md delete mode 100644 src/beast/beast/unit_test/amount.h delete mode 100644 src/beast/beast/unit_test/global_suites.h delete mode 100644 src/beast/beast/unit_test/print.h delete mode 100644 src/beast/beast/unity/beast_asio_unity.cpp delete mode 100644 src/beast/beast/unity/beast_crypto_unity.cpp delete mode 100644 src/beast/beast/unity/beast_http_unity.cpp delete mode 100644 src/beast/beast/unity/beast_streams_unity.cpp delete mode 100644 src/beast/beast/unity/beast_test_unity.cpp delete mode 100644 src/beast/beast/unity/beast_wsproto_unity.cpp delete mode 100644 src/beast/beast/wsproto.h delete mode 100644 src/beast/beast/wsproto/README.md delete mode 100644 src/beast/beast/wsproto/detail/hybi13.h delete mode 100644 src/beast/beast/wsproto/error.h delete mode 100644 src/beast/beast/wsproto/impl/error.ipp delete mode 100644 src/beast/beast/wsproto/src/test/async_echo_peer.h delete mode 100644 src/beast/beast/wsproto/src/test/beast_wsproto_ws_echo_test.cpp delete mode 100644 src/beast/beast/wsproto/src/test/beast_wsproto_ws_test.cpp delete mode 100644 src/beast/beast/wsproto/src/test/sync_echo_peer.h delete mode 100644 src/beast/examples/http_server_response.h rename src/beast/{beast/asio/async_completion.h => include/beast/async_completion.hpp} (65%) rename src/beast/{beast/asio/basic_streambuf.h => include/beast/basic_streambuf.hpp} (86%) rename src/beast/{beast/asio/bind_handler.h => include/beast/bind_handler.hpp} (75%) rename src/beast/{beast/asio/append_buffers.h => include/beast/buffer_cat.hpp} (80%) rename src/beast/{beast/asio/buffers_adapter.h => include/beast/buffers_adapter.hpp} (92%) create mode 100644 src/beast/include/beast/buffers_debug.hpp rename src/beast/{beast/asio/consuming_buffers.h => include/beast/consuming_buffers.hpp} (85%) rename src/beast/{beast/crypto/base64.h => include/beast/detail/base64.hpp} (75%) rename src/beast/{beast/ci_char_traits.h => include/beast/detail/ci_char_traits.hpp} (56%) rename src/beast/{beast/unit_test/const_container.h => include/beast/detail/const_container.hpp} (55%) create mode 100644 src/beast/include/beast/detail/empty_base_optimization.hpp rename src/beast/{beast/is_call_possible.h => include/beast/detail/is_call_possible.hpp} (57%) rename src/beast/{beast/crypto/detail/sha_context.h => include/beast/detail/sha1.hpp} (86%) create mode 100644 src/beast/include/beast/detail/stream/abstract_ostream.hpp rename src/beast/{beast/streams/basic_abstract_ostream.h => include/beast/detail/stream/basic_abstract_ostream.hpp} (55%) rename src/beast/{beast/streams/basic_scoped_ostream.h => include/beast/detail/stream/basic_scoped_ostream.hpp} (69%) create mode 100644 src/beast/include/beast/detail/stream/basic_std_ostream.hpp create mode 100644 src/beast/include/beast/detail/stream/debug_ostream.hpp rename src/beast/{beast/unit_test/temp_dir.h => include/beast/detail/temp_dir.hpp} (51%) create mode 100644 src/beast/include/beast/detail/unit_test.h create mode 100644 src/beast/include/beast/detail/unit_test/amount.hpp rename src/beast/{beast => include/beast/detail}/unit_test/define_print.cpp (52%) create mode 100644 src/beast/include/beast/detail/unit_test/global_suites.hpp rename src/beast/{beast/unit_test/match.h => include/beast/detail/unit_test/match.hpp} (73%) create mode 100644 src/beast/include/beast/detail/unit_test/print.hpp rename src/beast/{beast/unit_test/recorder.h => include/beast/detail/unit_test/recorder.hpp} (52%) rename src/beast/{beast/unit_test/reporter.h => include/beast/detail/unit_test/reporter.hpp} (80%) rename src/beast/{beast/unit_test/results.h => include/beast/detail/unit_test/results.hpp} (79%) rename src/beast/{beast/unit_test/runner.h => include/beast/detail/unit_test/runner.hpp} (83%) rename src/beast/{beast/unit_test/suite.h => include/beast/detail/unit_test/suite.hpp} (90%) rename src/beast/{beast/unit_test/suite_info.h => include/beast/detail/unit_test/suite_info.hpp} (64%) rename src/beast/{beast/unit_test/suite_list.h => include/beast/detail/unit_test/suite_list.hpp} (51%) rename src/beast/{beast/unit_test/thread.h => include/beast/detail/unit_test/thread.hpp} (63%) rename src/beast/{beast/asio/handler_alloc.h => include/beast/handler_alloc.hpp} (70%) create mode 100644 src/beast/include/beast/http.hpp rename src/beast/{beast/http/basic_headers.h => include/beast/http/basic_headers.hpp} (86%) rename src/beast/{beast/http/basic_parser.h => include/beast/http/basic_parser.hpp} (89%) rename src/beast/{beast/http/chunk_encode.h => include/beast/http/chunk_encode.hpp} (85%) rename src/beast/{beast/http/detail/error.h => include/beast/http/detail/error.hpp} (50%) rename src/beast/{beast/http/detail/write_preparation.h => include/beast/http/detail/write_preparation.hpp} (67%) rename src/beast/{beast/http/detail/writes.h => include/beast/http/detail/writes.hpp} (52%) create mode 100644 src/beast/include/beast/http/empty_body.hpp rename src/beast/{test/temp_buffer.cpp => include/beast/http/error.hpp} (53%) rename src/beast/{beast/http/fields.h => include/beast/http/fields.hpp} (100%) create mode 100644 src/beast/include/beast/http/headers.hpp rename src/beast/{ => include}/beast/http/impl/basic_headers.ipp (81%) rename src/beast/{ => include}/beast/http/impl/basic_parser.ipp (65%) rename src/beast/{beast/http/impl/http-parser => include/beast/http/impl}/http_parser.h (97%) rename src/beast/{ => include}/beast/http/impl/message.ipp (85%) rename src/beast/{ => include}/beast/http/impl/read.ipp (84%) rename src/beast/{ => include}/beast/http/impl/write.ipp (84%) create mode 100644 src/beast/include/beast/http/message.hpp rename src/beast/{beast/http/method.h => include/beast/http/method.hpp} (79%) create mode 100644 src/beast/include/beast/http/parser.hpp rename src/beast/{beast/http/read.h => include/beast/http/read.hpp} (70%) rename src/beast/{beast/http/reason.h => include/beast/http/reason.hpp} (62%) create mode 100644 src/beast/include/beast/http/resume_context.hpp rename src/beast/{beast/http/rfc2616.h => include/beast/http/rfc2616.hpp} (89%) rename src/beast/{beast/http/streambuf_body.h => include/beast/http/streambuf_body.hpp} (55%) rename src/beast/{beast/http/string_body.h => include/beast/http/string_body.hpp} (50%) create mode 100644 src/beast/include/beast/http/type_check.hpp rename src/beast/{beast/http/write.h => include/beast/http/write.hpp} (63%) rename src/beast/{beast/asio => include/beast}/impl/basic_streambuf.ipp (94%) rename src/beast/{beast/asio => include/beast}/impl/streambuf_readstream.ipp (83%) create mode 100644 src/beast/include/beast/placeholders.hpp rename src/beast/{beast/asio/prepare_buffers.h => include/beast/prepare_buffers.hpp} (87%) rename src/beast/{beast/asio/static_streambuf.h => include/beast/static_streambuf.hpp} (89%) rename src/beast/{test/asio.cpp => include/beast/streambuf.hpp} (55%) rename src/beast/{beast/asio/streambuf_readstream.h => include/beast/streambuf_readstream.hpp} (84%) rename src/beast/{beast/asio/type_check.h => include/beast/type_check.hpp} (81%) rename src/beast/{beast/http/error.h => include/beast/websocket.hpp} (78%) rename src/beast/{beast/wsproto/detail/debug.h => include/beast/websocket/detail/debug.hpp} (99%) rename src/beast/{beast/wsproto/detail/decorator.h => include/beast/websocket/detail/decorator.hpp} (51%) rename src/beast/{beast/wsproto/detail/error.h => include/beast/websocket/detail/error.hpp} (61%) rename src/beast/{beast/wsproto/detail/frame.h => include/beast/websocket/detail/frame.hpp} (84%) create mode 100644 src/beast/include/beast/websocket/detail/hybi13.hpp rename src/beast/{beast/wsproto/detail/invokable.h => include/beast/websocket/detail/invokable.hpp} (69%) rename src/beast/{beast/wsproto/detail/mask.h => include/beast/websocket/detail/mask.hpp} (98%) rename src/beast/{beast/wsproto/detail/socket_base.h => include/beast/websocket/detail/stream_base.hpp} (60%) rename src/beast/{beast/wsproto/detail/utf8_checker.h => include/beast/websocket/detail/utf8_checker.hpp} (80%) create mode 100644 src/beast/include/beast/websocket/error.hpp rename src/beast/{beast/wsproto => include/beast/websocket}/impl/accept_op.ipp (63%) rename src/beast/{beast/wsproto => include/beast/websocket}/impl/close_op.ipp (71%) create mode 100644 src/beast/include/beast/websocket/impl/error.ipp rename src/beast/{beast/wsproto => include/beast/websocket}/impl/handshake_op.ipp (66%) rename src/beast/{beast/wsproto => include/beast/websocket}/impl/read_frame_op.ipp (89%) rename src/beast/{beast/wsproto => include/beast/websocket}/impl/read_op.ipp (62%) rename src/beast/{beast/wsproto => include/beast/websocket}/impl/response_op.ipp (62%) rename src/beast/{beast/wsproto => include/beast/websocket}/impl/socket.ipp (84%) rename src/beast/{beast/wsproto => include/beast/websocket}/impl/ssl.ipp (72%) rename src/beast/{beast/wsproto => include/beast/websocket}/impl/teardown.ipp (72%) rename src/beast/{beast/wsproto => include/beast/websocket}/impl/write_frame_op.ipp (78%) rename src/beast/{beast/wsproto => include/beast/websocket}/impl/write_op.ipp (61%) rename src/beast/{beast/wsproto/option.h => include/beast/websocket/option.hpp} (84%) rename src/beast/{beast/wsproto/rfc6455.h => include/beast/websocket/rfc6455.hpp} (69%) rename src/beast/{beast/wsproto/ssl.h => include/beast/websocket/ssl.hpp} (61%) rename src/beast/{beast/wsproto/static_string.h => include/beast/websocket/static_string.hpp} (98%) rename src/beast/{beast/wsproto/socket.h => include/beast/websocket/stream.hpp} (90%) rename src/beast/{beast/wsproto/teardown.h => include/beast/websocket/teardown.hpp} (93%) create mode 100644 src/beast/src/beast_http_nodejs_parser.cpp rename src/beast/{beast/http/impl => src}/http-parser/AUTHORS (100%) rename src/beast/{beast/http/impl => src}/http-parser/LICENSE-MIT (100%) rename src/beast/{beast/http/impl => src}/http-parser/README.md (100%) rename src/beast/{beast/http/impl => src}/http-parser/http_parser.c (99%) rename src/beast/{beast/crypto/tests/beast_base64_test.cpp => test/base64.cpp} (84%) delete mode 100644 src/beast/test/beast_wsproto_ws_test.cpp rename src/beast/test/{append_buffers.cpp => buffer_cat.cpp} (81%) rename src/beast/{beast/http/src/test/beast_http_chunked_encoder_test.cpp => test/chunk_encode.cpp} (96%) rename src/beast/{beast/test/beast_empty_base_optimization_test.cpp => test/empty_base_optimization.cpp} (90%) rename src/beast/{beast/unit_test/src => test}/main.cpp (88%) rename src/beast/{beast/http/src/test/beast_http_message_test.cpp => test/message.cpp} (88%) rename src/beast/{beast/http/src/test/beast_http_rfc2616_test.cpp => test/rfc2616.cpp} (96%) delete mode 100644 src/beast/test/ssl_error.cpp rename src/{beast => ripple}/beast/asio/io_latency_probe.h (100%) rename src/{beast => ripple}/beast/asio/ssl_bundle.h (100%) rename src/{beast => ripple}/beast/asio/ssl_error.h (100%) rename src/{beast => ripple}/beast/clock/abstract_clock.h (100%) rename src/{beast => ripple}/beast/clock/basic_seconds_clock.h (99%) rename src/{beast => ripple}/beast/clock/chrono_util.h (100%) rename src/{beast => ripple}/beast/clock/manual_clock.h (98%) rename src/{beast => ripple}/beast/clock/tests/beast_abstract_clock_test.cpp (95%) rename src/{beast => ripple}/beast/clock/tests/beast_basic_seconds_clock_test.cpp (93%) rename src/{beast => ripple}/beast/crypto/detail/mac_facade.h (96%) rename src/{beast => ripple}/beast/crypto/detail/ripemd_context.h (100%) rename src/{beast => ripple}/beast/crypto/detail/sha2_context.h (100%) rename src/{beast => ripple}/beast/crypto/ripemd.h (92%) rename src/{beast => ripple}/beast/crypto/secure_erase.h (100%) rename src/{beast => ripple}/beast/crypto/sha2.h (93%) rename src/{beast => ripple}/beast/cxx17/type_traits.h (100%) rename src/{beast/beast/http/message.h => ripple/beast/deprecated_http.h} (54%) rename src/{beast => ripple}/beast/hash/endian.h (100%) rename src/{beast => ripple}/beast/hash/fnv1a.h (100%) rename src/{beast => ripple}/beast/hash/hash_append.h (99%) rename src/{beast => ripple}/beast/hash/impl/hash_speed_test.cpp (100%) rename src/{beast => ripple}/beast/hash/impl/siphash.cpp (99%) rename src/{beast => ripple}/beast/hash/impl/spookyv2.cpp (99%) rename src/{beast => ripple}/beast/hash/impl/spookyv2.h (100%) rename src/{beast => ripple}/beast/hash/impl/xxhash.c (99%) rename src/{beast => ripple}/beast/hash/impl/xxhash.h (100%) rename src/{beast => ripple}/beast/hash/meta.h (100%) rename src/{beast => ripple}/beast/hash/siphash.h (100%) rename src/{beast => ripple}/beast/hash/spooky.h (95%) rename src/{beast => ripple}/beast/hash/tests/hash_append_test.cpp (98%) rename src/{beast => ripple}/beast/hash/tests/hash_metrics.h (100%) rename src/{beast => ripple}/beast/hash/tests/hash_speed_test.cpp (94%) rename src/{beast => ripple}/beast/hash/uhash.h (94%) rename src/{beast => ripple}/beast/hash/xxhasher.h (96%) delete mode 100644 src/ripple/beast/net/URL.h delete mode 100644 src/ripple/beast/net/impl/URL.cpp rename src/{beast/beast/asio/src/test => ripple/beast/net/tests}/beast_asio_error_test.cpp (95%) delete mode 100644 src/ripple/beast/net/tests/beast_http_URL_test.cpp rename src/{ => ripple}/beast/site_scons/Beast.py (100%) rename src/{ => ripple}/beast/site_scons/site_tools/Protoc.py (100%) rename src/{ => ripple}/beast/site_scons/site_tools/VSProject.py (100%) rename src/{beast => ripple}/beast/type_name.h (100%) rename src/{beast => ripple}/beast/unit_test.h (64%) rename src/{beast => ripple}/beast/unity/beast_clock_unity.cpp (88%) rename src/{beast => ripple}/beast/unity/beast_hash_unity.cpp (79%) rename src/{beast => ripple}/beast/xor_shift_engine.h (100%) diff --git a/Builds/VisualStudio2015/RippleD.vcxproj b/Builds/VisualStudio2015/RippleD.vcxproj index ea09ebfb50..9bf9b17222 100644 --- a/Builds/VisualStudio2015/RippleD.vcxproj +++ b/Builds/VisualStudio2015/RippleD.vcxproj @@ -87,7 +87,7 @@ HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;BOOST_NO_AUTO_PTR;DEBUG;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;_DEBUG;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions) - ..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories) + ..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\beast\include;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories) 4800;4244;4267;4018 Async MultiThreadedDebug @@ -124,7 +124,7 @@ HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;BOOST_NO_AUTO_PTR;DEBUG;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRTDBG_MAP_ALLOC;_CRT_SECURE_NO_WARNINGS;_DEBUG;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions) - ..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories) + ..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\beast\include;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories) 4800;4244;4267;4018 Async MultiThreadedDebug @@ -161,7 +161,7 @@ HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;BOOST_NO_AUTO_PTR;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NDEBUG;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions) - ..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories) + ..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\beast\include;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories) 4800;4244;4267;4018 Async Precise @@ -196,7 +196,7 @@ HAVE_USLEEP=1;SOCI_CXX_C11=1;_WIN32_WINNT=0x6000;BOOST_NO_AUTO_PTR;DEPRECATED_IN_MAC_OS_X_VERSION_10_7_AND_LATER;NDEBUG;NOMINMAX;OPENSSL_NO_SSL2;WIN32_CONSOLE;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS;%(PreprocessorDefinitions) - ..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories) + ..\..\build\proto;..\..\src;..\..\src\beast;..\..\src\beast\include;..\..\src\protobuf\src;..\..\src\protobuf\vsprojects;..\..\src\soci\include;..\..\src\soci\src;%(AdditionalIncludeDirectories) 4800;4244;4267;4018 Async Precise @@ -236,377 +236,200 @@ - + - + - + - + - + - + - + - + - - - - - + - + - + - - True - True - - - True - True - - - True - True - - + - + - + - + - + - + - + - + - - - - - - - - - - True - True - - - True - True - - - - - - - - - - - - - - - - - - - - - True - True - - - - - - - - - - - - + True - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True - - - - True - - - - - - - - - - - True - - - - - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - - - - - - - - - - - - - - - - - - - - - - - - - True - True - - - - - True - True - - - True - True - - - True - True - - - True - True - - - - - - - - - - - - - - - - - - - - - - - True - True - - - True - True - - - - - True - True - - - True - True - - - True - True - - - - - True - True - - - True - True - - - True - True - - - True - True - - - - - - - - - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - - - True - True - - - - - - - - - - - @@ -1638,6 +1461,28 @@ + + + + + + + + + + + + + + + + True + True + + + True + True + @@ -1756,6 +1601,59 @@ True + + + + + + + + + + + + + + + + + + + + + + + + True + + + True + + + + + True + + + + + + + + + + + True + + + + + True + + + + + @@ -1838,10 +1736,6 @@ True True - - True - True - @@ -1852,7 +1746,7 @@ - + True True @@ -1860,8 +1754,6 @@ True True - - @@ -1934,10 +1826,18 @@ + + + + True + True + True True + + True True @@ -1954,6 +1854,8 @@ True True + + @@ -2000,6 +1902,8 @@ + + diff --git a/Builds/VisualStudio2015/RippleD.vcxproj.filters b/Builds/VisualStudio2015/RippleD.vcxproj.filters index bfd80c81df..b27f9c4608 100644 --- a/Builds/VisualStudio2015/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2015/RippleD.vcxproj.filters @@ -4,96 +4,6 @@ {B4CFBB41-DA25-70B1-E486-4F869E226E12} - - {6DD9EDCB-63DB-D377-3F12-12825FA8437E} - - - {7CF592DC-67BE-59E6-DB95-6C0B3062746D} - - - {FF54D3F4-A81E-22BE-41BE-3B9033F5D19F} - - - {D091E064-34B3-D521-C542-E4CB4E1DB6B0} - - - {1C9418C5-092B-040C-16B7-1FA56E86CAF6} - - - {4570DEF7-7325-D45D-57DE-6B99056FE3FC} - - - {B2E3A420-7A16-217D-C355-617FA18F5AD2} - - - {ED78E906-CE72-CDEF-3018-99E02603C37E} - - - {80B5AA79-B513-6410-D468-472E3E393BAA} - - - {FF9CBE50-56A0-7B59-C99F-C873605C844B} - - - {DED08E50-BA3F-9E32-7501-3B77F31A5C11} - - - {FE3C8FFD-FEE1-BDEA-DE7F-24A8DEDCAD20} - - - {5D0A694C-9709-709C-EDCB-4332E2457AE4} - - - {2B06CD3F-1F3C-7832-DB4E-112BDCE74C94} - - - {7138D215-DA65-98D5-EF7D-C9896685201E} - - - {3E84AA4C-CB48-99F0-EB35-5603FF633A51} - - - {932F732F-F09E-5C50-C8A1-D62342CCAA1F} - - - {59E40DE8-464F-35ED-5F22-E7B52FDE3ECD} - - - {CCA07C08-BF91-95E2-4980-7D56A618C37E} - - - {5F7F2E0C-4CDE-B1E1-1668-E06768D6FFD3} - - - {7944CEAB-F8F9-1E2B-CD03-B3D9F78B20E9} - - - {70E19DD6-FF10-6564-8AC0-8EBA14B40DDF} - - - {0ED4CDBE-296D-2599-04B3-095BFD1668A4} - - - {40FDA51E-20C4-4A72-83C3-A4B08C596A82} - - - {2762284D-66E5-8B48-1F8E-67116DB1FC6B} - - - {53D8D640-BEB0-1F2C-61D4-5459CDAC7EB4} - - - {E8E91EF5-9155-8F58-4249-3EF221768BCE} - - - {63AB4C85-5B2E-B2A7-9E4F-9F0899402D1D} - - - {E5986CF5-37A8-1EE5-1085-645EBEE517B6} - - - {28A822FF-4532-9678-23F2-D844CB0FE207} - {65697F48-7FC6-2A4B-DB6C-56781F3990B5} @@ -103,6 +13,42 @@ {9DEED977-2072-A182-5BD9-CEBF206E8C91} + + {BFB5FB0D-E563-77CD-68EA-A6E186D6240D} + + + {0959FCA5-589F-980F-57AF-AB859F5A61AA} + + + {42B1E98B-3FD0-CA4B-41E1-1BF2B5548847} + + + {111F5668-0DD0-400E-97B7-0B01809D8BF2} + + + {7A85C6E8-9F03-F94D-4302-A43773BF7E61} + + + {78230F53-2814-6C7D-1558-87709A2F6090} + + + {617AF364-CB0C-87ED-DA43-668BB1D6F6FC} + + + {DDE347C4-F990-B1A8-1D36-357D36685D1F} + + + {3CFD7EE6-5D12-16E4-B83A-B16BA89B931D} + + + {A3314CD5-8DAB-E905-89CA-0DBAEF8A4FFF} + + + {5BB26F63-320D-F26F-D2F3-3466F745C6AD} + + + {2A5AEEC4-AF29-1B47-F2EE-8A478584EE5D} + {B211F8F1-22D2-47BA-C39E-F9846A844D11} @@ -187,6 +133,15 @@ {B75D9C70-388A-3FA5-53E7-8F37FDF4704B} + + {18E2EE25-691B-C8C6-CE50-559012D120C5} + + + {B19A7492-A21F-6398-8E2C-CB226DAB2AB5} + + + {38AA3F5F-3BC0-8C85-337C-6125D5CA0C95} + {55CEA641-A406-D50E-17E4-0617F38C4279} @@ -199,6 +154,24 @@ {2878154F-A12B-FAF9-2731-F1E554045252} + + {FD4D1806-56C7-EFD3-8177-B77ECCB62673} + + + {D2FEF8DB-10F1-40FD-149C-2929726AB662} + + + {462217CD-F700-FBAF-6337-9B66824D1964} + + + {EFCF517A-692C-C748-5A6B-E7A80A245AE8} + + + {A434A188-4373-CE55-6995-BA4EC86D2125} + + + {A0CD1F88-1FA8-FDBF-8C82-A5427B6E10AE} + {1CB945B8-4655-2C56-1C03-24281400ABD8} @@ -505,6 +478,12 @@ {D2A046B6-8986-92AC-082F-15B3A01B8E40} + + {04C492A5-B8E8-3B1F-4337-A067B40F268A} + + + {1E761797-5D00-57DD-FEBA-D17E07E1788D} + {96CE200F-2670-323E-3B37-B90DBC0EDA11} @@ -555,486 +534,294 @@ . - - beast\asio + + include\beast - - beast\asio + + include\beast - - beast\asio + + include\beast - - beast\asio + + include\beast - - beast\asio + + include\beast - - beast\asio + + include\beast - - beast\asio + + include\beast\detail - - beast\asio + + include\beast\detail - - beast\asio\impl + + include\beast\detail + + + include\beast\detail + + + include\beast\detail + + + include\beast\detail + + + include\beast\detail\stream + + + include\beast\detail\stream + + + include\beast\detail\stream + + + include\beast\detail\stream + + + include\beast\detail\stream + + + include\beast\detail + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast\detail\unit_test + + + include\beast + + + include\beast\http + + + include\beast\http + + + include\beast\http + + + include\beast\http\detail + + + include\beast\http\detail + + + include\beast\http\detail + + + include\beast\http + + + include\beast\http + + + include\beast\http + + + include\beast\http\impl - - beast\asio\impl + + include\beast\http\impl - - beast\asio + + include\beast\http\impl - - beast\asio - - - beast\asio - - - beast\asio\src\test - - - beast\asio\src\test - - - beast\asio\src\test - - - beast\asio - - - beast\asio - - - beast\asio - - - beast\asio - - - beast\asio - - - beast\asio - - - beast\asio - - - beast - - - beast\clock - - - beast\clock - - - beast\clock - - - beast\clock - - - beast\clock\tests - - - beast\clock\tests - - - beast\crypto - - - beast\crypto\detail - - - beast\crypto\detail - - - beast\crypto\detail - - - beast\crypto\detail - - - beast\crypto - - - beast\crypto - - - beast\crypto - - - beast\crypto - - - beast\crypto\tests - - - beast\cxx17 - - - beast - - - beast\hash - - - beast\hash - - - beast\hash - - - beast\hash\impl - - - beast\hash\impl - - - beast\hash\impl - - - beast\hash\impl - - - beast\hash\impl - - - beast\hash - - - beast\hash - - - beast\hash - - - beast\hash\tests - - - beast\hash\tests - - - beast\hash\tests - - - beast\hash - - - beast\hash - - - beast - - - beast\http - - - beast\http - - - beast\http - - - beast\http - - - beast\http\detail - - - beast\http\detail - - - beast\http\detail - - - beast\http - - - beast\http - - - beast\http - - - beast\http - - - beast\http\impl + + include\beast\http\impl - - beast\http\impl + + include\beast\http\impl - - beast\http\impl\http-parser - - - beast\http\impl\http-parser - - - beast\http\impl + + include\beast\http\impl - - beast\http\impl + + include\beast\http + + + include\beast\http + + + include\beast\http + + + include\beast\http + + + include\beast\http + + + include\beast\http + + + include\beast\http + + + include\beast\http + + + include\beast\http + + + include\beast\http + + + include\beast\http + + + include\beast\impl - - beast\http\impl + + include\beast\impl - - beast\http + + include\beast - - beast\http + + include\beast - - beast\http + + include\beast - - beast\http + + include\beast - - beast\http + + include\beast - - beast\http + + include\beast - - beast\http + + include\beast - - beast\http\src - - - beast\http\src + + include\beast\websocket\detail - - beast\http\src\test - - - beast\http\src\test - - - beast\http\src\test - - - beast\http\src\test - - - beast\http + + include\beast\websocket\detail - - beast\http + + include\beast\websocket\detail - - beast\http + + include\beast\websocket\detail - - beast\http + + include\beast\websocket\detail - - beast + + include\beast\websocket\detail - - beast\streams + + include\beast\websocket\detail - - beast\streams + + include\beast\websocket\detail - - beast\streams + + include\beast\websocket - - beast\streams - - - beast\streams - - - beast\streams\tests - - - beast\test - - - beast - - - beast\unity - - - beast\unity - - - beast\unity - - - beast\unity - - - beast\unity - - - beast\unity - - - beast\unity - - - beast\unity - - - beast - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast\unit_test - - - beast - - - beast\wsproto\detail - - - beast\wsproto\detail - - - beast\wsproto\detail - - - beast\wsproto\detail - - - beast\wsproto\detail - - - beast\wsproto\detail - - - beast\wsproto\detail - - - beast\wsproto\detail - - - beast\wsproto - - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto\impl + + include\beast\websocket\impl - - beast\wsproto + + include\beast\websocket - - beast\wsproto + + include\beast\websocket - - beast\wsproto + + include\beast\websocket - - beast\wsproto\src\test + + include\beast\websocket - - beast\wsproto\src\test + + include\beast\websocket + + + include\beast\websocket + + + src - - beast\wsproto\src\test + + src\http-parser - - beast\wsproto\src\test - - - beast\wsproto - - - beast\wsproto - - - beast\wsproto - - - beast - ed25519-donna @@ -2136,6 +1923,33 @@ ripple\basics + + ripple\beast\asio + + + ripple\beast\asio + + + ripple\beast\asio + + + ripple\beast\clock + + + ripple\beast\clock + + + ripple\beast\clock + + + ripple\beast\clock + + + ripple\beast\clock\tests + + + ripple\beast\clock\tests + ripple\beast\container @@ -2292,6 +2106,78 @@ ripple\beast\core + + ripple\beast\crypto\detail + + + ripple\beast\crypto\detail + + + ripple\beast\crypto\detail + + + ripple\beast\crypto + + + ripple\beast\crypto + + + ripple\beast\crypto + + + ripple\beast\cxx17 + + + ripple\beast + + + ripple\beast\hash + + + ripple\beast\hash + + + ripple\beast\hash + + + ripple\beast\hash\impl + + + ripple\beast\hash\impl + + + ripple\beast\hash\impl + + + ripple\beast\hash\impl + + + ripple\beast\hash\impl + + + ripple\beast\hash + + + ripple\beast\hash + + + ripple\beast\hash + + + ripple\beast\hash\tests + + + ripple\beast\hash\tests + + + ripple\beast\hash\tests + + + ripple\beast\hash + + + ripple\beast\hash + ripple\beast\insight @@ -2382,9 +2268,6 @@ ripple\beast\net\impl - - ripple\beast\net\impl - ripple\beast\net @@ -2400,15 +2283,12 @@ ripple\beast\net - + ripple\beast\net\tests ripple\beast\net\tests - - ripple\beast\net - ripple\beast @@ -2502,9 +2382,18 @@ ripple\beast\nudb + + ripple\beast + + + ripple\beast\unity + ripple\beast\unity + + ripple\beast\unity + ripple\beast\unity @@ -2517,6 +2406,9 @@ ripple\beast\unity + + ripple\beast + ripple\beast\utility @@ -2565,6 +2457,9 @@ ripple\beast\utility + + ripple\beast + ripple\core diff --git a/SConstruct b/SConstruct index ca6c95f288..b3b9f63351 100644 --- a/SConstruct +++ b/SConstruct @@ -121,7 +121,7 @@ import textwrap import time import SCons.Action -sys.path.append(os.path.join('src', 'beast', 'site_scons')) +sys.path.append(os.path.join('src', 'ripple', 'beast', 'site_scons')) sys.path.append(os.path.join('src', 'ripple', 'site_scons')) import Beast @@ -759,7 +759,7 @@ root_dir = Dir('#').srcnode().get_abspath() # Path to this SConstruct file build_dir = os.path.join('build') base = Environment( - toolpath=[os.path.join ('src', 'beast', 'site_scons', 'site_tools')], + toolpath=[os.path.join ('src', 'ripple', 'beast', 'site_scons', 'site_tools')], tools=['default', 'Protoc', 'VSProject'], ENV=os.environ, TARGET_ARCH='x86_64') @@ -768,6 +768,7 @@ config_base(base) base.Append(CPPPATH=[ 'src', os.path.join('src', 'beast'), + os.path.join('src', 'beast', 'include'), os.path.join(build_dir, 'proto'), os.path.join('src','soci','src'), os.path.join('src','soci','include'), @@ -901,13 +902,7 @@ def get_classic_sources(toolchain): 'src/soci/src/core', 'src/sqlite'] ) - append_sources(result, *list_sources('src/beast/beast/asio/src', '.cpp')) - append_sources(result, *list_sources('src/beast/beast/clock', '.cpp')) - append_sources(result, *list_sources('src/beast/beast/crypto', '.cpp')) - append_sources(result, *list_sources('src/beast/beast/http/src', '.cpp')) - append_sources(result, *list_sources('src/beast/beast/streams', '.cpp')) - append_sources(result, *list_sources('src/beast/beast/test', '.cpp')) - append_sources(result, *list_sources('src/beast/beast/wsproto/src', '.cpp')) + append_sources(result, *list_sources('src/ripple/beast/clock', '.cpp')) append_sources(result, *list_sources('src/ripple/beast/container', '.cpp')) append_sources(result, *list_sources('src/ripple/beast/insight', '.cpp')) append_sources(result, *list_sources('src/ripple/beast/net', '.cpp')) @@ -952,13 +947,7 @@ def get_unity_sources(toolchain): result = [] append_sources( result, - 'src/beast/beast/unity/beast_asio_unity.cpp', - 'src/beast/beast/unity/beast_clock_unity.cpp', - 'src/beast/beast/unity/beast_crypto_unity.cpp', - 'src/beast/beast/unity/beast_http_unity.cpp', - 'src/beast/beast/unity/beast_streams_unity.cpp', - 'src/beast/beast/unity/beast_test_unity.cpp', - 'src/beast/beast/unity/beast_wsproto_unity.cpp', + 'src/ripple/beast/unity/beast_clock_unity.cpp', 'src/ripple/beast/unity/beast_container_unity.cpp', 'src/ripple/beast/unity/beast_insight_unity.cpp', 'src/ripple/beast/unity/beast_net_unity.cpp', @@ -1121,7 +1110,8 @@ for tu_style in ['classic', 'unity']: cc_flags = {} object_builder.add_source_files( - 'src/beast/beast/unity/beast_hash_unity.cpp', + 'src/beast/src/beast_http_nodejs_parser.cpp', + 'src/ripple/beast/unity/beast_hash_unity.cpp', 'src/ripple/unity/beast.cpp', 'src/ripple/unity/lz4.c', 'src/ripple/unity/protobuf.cpp', @@ -1212,7 +1202,7 @@ for key, value in aliases.iteritems(): vcxproj = base.VSProject( os.path.join('Builds', 'VisualStudio2015', 'RippleD'), source = [], - VSPROJECT_ROOT_DIRS = ['src/beast', 'src', '.'], + VSPROJECT_ROOT_DIRS = ['src/beast', 'src/beast/include', 'src', '.'], VSPROJECT_CONFIGS = msvc_configs) base.Alias('vcxproj', vcxproj) diff --git a/src/beast/.gitignore b/src/beast/.gitignore index f2c52757cf..cc8f6cb399 100644 --- a/src/beast/.gitignore +++ b/src/beast/.gitignore @@ -23,8 +23,4 @@ contents.xcworkspacedata .DS_Store .svn profile -Builds/VisualStudio2012/Debug -Builds/VisualStudio2012/Release -project.xcworkspace -modules/beast_cryptopp bin/ diff --git a/src/beast/.travis.yml b/src/beast/.travis.yml deleted file mode 100644 index a322d54864..0000000000 --- a/src/beast/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: cpp - -compiler: - - gcc - - clang -before_install: - - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - - sudo add-apt-repository -y ppa:boost-latest/ppa - - sudo apt-get update -qq - - sudo apt-get install -qq python-software-properties - - sudo apt-get install -qq g++-4.8 - - sudo apt-get install -qq libboost1.55-all-dev - - sudo apt-get install -qq libssl-dev - - sudo apt-get install -qq gcc-4.8 - - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 - - sudo update-alternatives --set gcc /usr/bin/gcc-4.8 -# - sudo apt-get -y install binutils-gold - - g++ -v - - clang -v -script: - # Abort build on failure - - set -e - - scons -notifications: - email: - false diff --git a/src/beast/BeastConfig.h b/src/beast/BeastConfig.h deleted file mode 100644 index db9792f1c7..0000000000 --- a/src/beast/BeastConfig.h +++ /dev/null @@ -1,139 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_BEASTCONFIG_H_INCLUDED -#define BEAST_BEASTCONFIG_H_INCLUDED - -/** Configuration file for Beast. - This sets various configurable options for Beast. In order to compile you - must place a copy of this file in a location where your build environment - can find it, and then customize its contents to suit your needs. - @file BeastConfig.h -*/ - -//------------------------------------------------------------------------------ -// -// Unit Tests -// -//------------------------------------------------------------------------------ - -/** Config: BEAST_NO_UNIT_TEST_INLINE - Prevents unit test definitions from being inserted into a global table. -*/ -#ifndef BEAST_NO_UNIT_TEST_INLINE -#define BEAST_NO_UNIT_TEST_INLINE 0 -#endif - -//------------------------------------------------------------------------------ -// -// Diagnostics -// -//------------------------------------------------------------------------------ - -/** Config: BEAST_FORCE_DEBUG - Normally, BEAST_DEBUG is set to 1 or 0 based on compiler and project - settings, but if you define this value, you can override this to force it - to be true or false. -*/ -#ifndef BEAST_FORCE_DEBUG -//#define BEAST_FORCE_DEBUG 1 -#endif - -/** Config: BEAST_CHECK_MEMORY_LEAKS - Enables a memory-leak check for certain objects when the app terminates. - See the LeakChecked class for more details about enabling leak checking for - specific classes. -*/ -#ifndef BEAST_CHECK_MEMORY_LEAKS -//#define BEAST_CHECK_MEMORY_LEAKS 0 -#endif - -//------------------------------------------------------------------------------ -// -// Libraries -// -//------------------------------------------------------------------------------ - -/** Config: BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES - In a Visual C++ build, this can be used to stop the required system libs - being automatically added to the link stage. -*/ -#ifndef BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES -//#define BEAST_DONT_AUTOLINK_TO_WIN32_LIBRARIES 1 -#endif - -/** Config: BEAST_INCLUDE_ZLIB_CODE - This can be used to disable Beast's embedded 3rd-party zlib code. - You might need to tweak this if you're linking to an external zlib library - in your app, but for normal apps, this option should be left alone. - - If you disable this, you might also want to set a value for - BEAST_ZLIB_INCLUDE_PATH, to specify the path where your zlib headers live. -*/ -#ifndef BEAST_INCLUDE_ZLIB_CODE -//#define BEAST_INCLUDE_ZLIB_CODE 1 -#endif - -/** Config: BEAST_ZLIB_INCLUDE_PATH - This is included when BEAST_INCLUDE_ZLIB_CODE is set to zero. -*/ -#ifndef BEAST_ZLIB_INCLUDE_PATH -#define BEAST_ZLIB_INCLUDE_PATH -#endif - -/** Config: BEAST_SQLITE_FORCE_NDEBUG - Setting this option forces sqlite into release mode even if NDEBUG is not set -*/ -#ifndef BEAST_SQLITE_FORCE_NDEBUG -//#define BEAST_SQLITE_FORCE_NDEBUG 1 -#endif - -/** Config: BEAST_FUNCTIONAL_USES_### - source configuration. - Set one of these to manually force a particular implementation of bind(). - If nothing is chosen then beast will use whatever is appropriate for your - environment based on what is available. - If you override these, set ONE to 1 and the rest to 0 -*/ -#ifndef BEAST_FUNCTIONAL_USES_STD -//#define BEAST_FUNCTIONAL_USES_STD 0 -#endif -#ifndef BEAST_FUNCTIONAL_USES_TR1 -//#define BEAST_FUNCTIONAL_USES_TR1 0 -#endif -#ifndef BEAST_FUNCTIONAL_USES_BOOST -//#define BEAST_FUNCTIONAL_USES_BOOST 0 -#endif - -//------------------------------------------------------------------------------ -// -// Boost -// -//------------------------------------------------------------------------------ - -/** Config: BEAST_USE_BOOST_FEATURES - This activates boost specific features and improvements. If this is - turned on, the include paths for your build environment must be set - correctly to find the boost headers. -*/ -#ifndef BEAST_USE_BOOST_FEATURES -//#define BEAST_USE_BOOST_FEATURES 1 -#endif - -#endif diff --git a/src/beast/Jamroot b/src/beast/Jamroot index aed04ce28e..5a032af582 100644 --- a/src/beast/Jamroot +++ b/src/beast/Jamroot @@ -48,6 +48,7 @@ else project beast : requirements . + ./include #/boost//headers /boost/system//boost_system /boost/filesystem//boost_filesystem diff --git a/src/beast/README.md b/src/beast/README.md index 32e2029926..f681da34d6 100644 --- a/src/beast/README.md +++ b/src/beast/README.md @@ -1 +1,12 @@ -# Beast: A C++ Library +# Beast + +Beast provides implementations of the HTTP and WebSocket protocols +built on top of Boost.Asio and other parts of boost. + +Requirements: + +* Boost +* C++11 or greater +* OpenSSL (optional) + +Documentation: http://vinniefalco.github.io/beast/ diff --git a/src/beast/TODO.txt b/src/beast/TODO.txt index d5767cb808..399a2baf5b 100644 --- a/src/beast/TODO.txt +++ b/src/beast/TODO.txt @@ -1,8 +1,22 @@ * kick out non-beast code - * redo directory structure - * Change build options to C++11 only - * Replace Jamroot with Jamfile +* Switch source material to Boost license +* Fix failing test/message.cpp +* Complete allocator testing in basic_streambuf, basic_headers +* Tidy up type_checks + - Derive from std::integral_constant +* Check DOXYGEN, GENERATIC_DOCS directives in source + - See if we can include them now that xsl is fixed +* Go over each header and split header material into detail and impl files +* Make buffers_debug a detail +* Ensure each public header has a unit test .cpp file +* Roll header-only http parser +* Define Parser concept in HTTP +* melpon sandbox? +* invokable unit test +* trim public interface of rfc2616.h to essentials only +* Use new http routines in JSONRPCClient +* Remove or change http::headers alias diff --git a/src/beast/beast/asio.h b/src/beast/beast/asio.h deleted file mode 100644 index 607b12a7c3..0000000000 --- a/src/beast/beast/asio.h +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_H_INCLUDED -#define BEAST_ASIO_H_INCLUDED - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/src/beast/beast/asio/buffers_debug.h b/src/beast/beast/asio/buffers_debug.h deleted file mode 100644 index e536179962..0000000000 --- a/src/beast/beast/asio/buffers_debug.h +++ /dev/null @@ -1,51 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_BUFFERS_DEBUG_H_INLUDED -#define BEAST_ASIO_BUFFERS_DEBUG_H_INLUDED - -#include -#include - -namespace beast { -namespace debug { - -template -std::string -buffers_to_string(Buffers const& bs) -{ - using boost::asio::buffer_cast; - using boost::asio::buffer_size; - std::string s; - s.reserve(buffer_size(bs)); - for(auto const& b : bs) - s.append(buffer_cast(b), - buffer_size(b)); - for(auto i = s.size(); i-- > 0;) - if(s[i] == '\r') - s.replace(i, 1, "\\r"); - else if(s[i] == '\n') - s.replace(i, 1, "\\n\n"); - return s; -} - -} // debug -} // beast - -#endif diff --git a/src/beast/beast/asio/placeholders.h b/src/beast/beast/asio/placeholders.h deleted file mode 100644 index 03633b9f34..0000000000 --- a/src/beast/beast/asio/placeholders.h +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_PLACEHOLDERS_H_INCLUDED -#define BEAST_ASIO_PLACEHOLDERS_H_INCLUDED - -#include - -namespace beast { -namespace asio { - -namespace placeholders { -// asio placeholders that work with std::bind -namespace { -static auto const error (std::placeholders::_1); -static auto const bytes_transferred (std::placeholders::_2); -static auto const iterator (std::placeholders::_2); -static auto const signal_number (std::placeholders::_2); -} -} - -} -} - -#endif diff --git a/src/beast/beast/asio/src/test/beast_asio_bind_handler_test.cpp b/src/beast/beast/asio/src/test/beast_asio_bind_handler_test.cpp deleted file mode 100644 index 826de07ac0..0000000000 --- a/src/beast/beast/asio/src/test/beast_asio_bind_handler_test.cpp +++ /dev/null @@ -1,48 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include - -namespace beast { -namespace test { - -class bind_handler_test : public unit_test::suite -{ -public: - static void foo (int) - { - } - - void run() - { - auto f (bind_handler ( - std::bind (&foo, std::placeholders::_1), - 42)); - f(); - pass(); - } -}; - -BEAST_DEFINE_TESTSUITE(bind_handler,asio,beast); - -} // test -} // beast - diff --git a/src/beast/beast/asio/src/test/beast_asio_buffers_test.cpp b/src/beast/beast/asio/src/test/beast_asio_buffers_test.cpp deleted file mode 100644 index c0686cec49..0000000000 --- a/src/beast/beast/asio/src/test/beast_asio_buffers_test.cpp +++ /dev/null @@ -1,362 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace beast { -namespace test { - -class buffers_test : public unit_test::suite -{ -public: - template - static - std::string - to_string(ConstBufferSequence const& bs) - { - using boost::asio::buffer_cast; - using boost::asio::buffer_size; - std::string s; - s.reserve(buffer_size(bs)); - for(auto const& b : bs) - s.append(buffer_cast(b), - buffer_size(b)); - return s; - } - - void testStreambuf() - { - using boost::asio::buffer; - using boost::asio::buffer_cast; - using boost::asio::buffer_size; - std::string const s = "Hello, world"; - expect(s.size() == 12); - for(std::size_t i = 1; i < 12; ++i) { - for(std::size_t x = 1; x < 4; ++x) { - for(std::size_t y = 1; y < 4; ++y) { - for(std::size_t t = 1; t < 4; ++ t) { - for(std::size_t u = 1; u < 4; ++ u) { - std::size_t z = s.size() - (x + y); - std::size_t v = s.size() - (t + u); - { - streambuf sb(i); - decltype(sb)::mutable_buffers_type d; - d = sb.prepare(z); expect(buffer_size(d) == z); - d = sb.prepare(0); expect(buffer_size(d) == 0); - d = sb.prepare(y); expect(buffer_size(d) == y); - d = sb.prepare(x); expect(buffer_size(d) == x); - sb.commit(buffer_copy(d, buffer(s.data(), x))); - expect(sb.size() == x); - expect(buffer_size(sb.data()) == sb.size()); - d = sb.prepare(x); expect(buffer_size(d) == x); - d = sb.prepare(0); expect(buffer_size(d) == 0); - d = sb.prepare(z); expect(buffer_size(d) == z); - d = sb.prepare(y); expect(buffer_size(d) == y); - sb.commit(buffer_copy(d, buffer(s.data()+x, y))); - sb.commit(1); - expect(sb.size() == x + y); - expect(buffer_size(sb.data()) == sb.size()); - d = sb.prepare(x); expect(buffer_size(d) == x); - d = sb.prepare(y); expect(buffer_size(d) == y); - d = sb.prepare(0); expect(buffer_size(d) == 0); - d = sb.prepare(z); expect(buffer_size(d) == z); - sb.commit(buffer_copy(d, buffer(s.data()+x+y, z))); - sb.commit(2); - expect(sb.size() == x + y + z); - expect(buffer_size(sb.data()) == sb.size()); - expect(to_string(sb.data()) == s); - sb.consume(t); - d = sb.prepare(0); expect(buffer_size(d) == 0); - expect(to_string(sb.data()) == s.substr(t, std::string::npos)); - sb.consume(u); - expect(to_string(sb.data()) == s.substr(t + u, std::string::npos)); - sb.consume(v); - expect(to_string(sb.data()) == ""); - sb.consume(1); - d = sb.prepare(0); expect(buffer_size(d) == 0); - } - }}}}} - } - - void testBuffersAdapter() - { - using boost::asio::buffer; - using boost::asio::buffer_cast; - using boost::asio::buffer_size; - using boost::asio::const_buffer; - using boost::asio::mutable_buffer; - char buf[12]; - std::string const s = "Hello, world"; - expect(s.size() == sizeof(buf)); - for(std::size_t i = 1; i < 4; ++i) { - for(std::size_t j = 1; j < 4; ++j) { - for(std::size_t x = 1; x < 4; ++x) { - for(std::size_t y = 1; y < 4; ++y) { - for(std::size_t t = 1; t < 4; ++ t) { - for(std::size_t u = 1; u < 4; ++ u) { - std::size_t k = sizeof(buf) - (i + j); - std::size_t z = sizeof(buf) - (x + y); - std::size_t v = sizeof(buf) - (t + u); - { - std::memset(buf, 0, sizeof(buf)); - std::array bs{{ - mutable_buffer{&buf[0], i}, - mutable_buffer{&buf[i], j}, - mutable_buffer{&buf[i+j], k}}}; - buffers_adapter ba(std::move(bs)); - expect(ba.max_size() == sizeof(buf)); - decltype(ba)::mutable_buffers_type d; - d = ba.prepare(z); expect(buffer_size(d) == z); - d = ba.prepare(0); expect(buffer_size(d) == 0); - d = ba.prepare(y); expect(buffer_size(d) == y); - d = ba.prepare(x); expect(buffer_size(d) == x); - ba.commit(buffer_copy(d, buffer(s.data(), x))); - expect(ba.size() == x); - expect(ba.max_size() == sizeof(buf) - x); - expect(buffer_size(ba.data()) == ba.size()); - d = ba.prepare(x); expect(buffer_size(d) == x); - d = ba.prepare(0); expect(buffer_size(d) == 0); - d = ba.prepare(z); expect(buffer_size(d) == z); - d = ba.prepare(y); expect(buffer_size(d) == y); - ba.commit(buffer_copy(d, buffer(s.data()+x, y))); - ba.commit(1); - expect(ba.size() == x + y); - expect(ba.max_size() == sizeof(buf) - (x + y)); - expect(buffer_size(ba.data()) == ba.size()); - d = ba.prepare(x); expect(buffer_size(d) == x); - d = ba.prepare(y); expect(buffer_size(d) == y); - d = ba.prepare(0); expect(buffer_size(d) == 0); - d = ba.prepare(z); expect(buffer_size(d) == z); - ba.commit(buffer_copy(d, buffer(s.data()+x+y, z))); - ba.commit(2); - expect(ba.size() == x + y + z); - expect(ba.max_size() == 0); - expect(buffer_size(ba.data()) == ba.size()); - expect(to_string(ba.data()) == s); - ba.consume(t); - d = ba.prepare(0); expect(buffer_size(d) == 0); - expect(to_string(ba.data()) == s.substr(t, std::string::npos)); - ba.consume(u); - expect(to_string(ba.data()) == s.substr(t + u, std::string::npos)); - ba.consume(v); - expect(to_string(ba.data()) == ""); - ba.consume(1); - d = ba.prepare(0); expect(buffer_size(d) == 0); - try - { - ba.prepare(1); - fail(); - } - catch(...) - { - pass(); - } - } - }}}}}} - } - - void testConsuming() - { - using boost::asio::buffer; - using boost::asio::const_buffer; - char buf[12]; - std::string const s = "Hello, world"; - expect(s.size() == sizeof(buf)); - buffer_copy(buffer(buf), buffer(s)); - expect(to_string(buffer(buf)) == s); - for(std::size_t i = 1; i < 4; ++i) { - for(std::size_t j = 1; j < 4; ++j) { - for(std::size_t x = 1; x < 4; ++x) { - for(std::size_t y = 1; y < 4; ++y) { - std::size_t k = sizeof(buf) - (i + j); - std::size_t z = sizeof(buf) - (x + y); - { - std::array bs{{ - const_buffer{&buf[0], i}, - const_buffer{&buf[i], j}, - const_buffer{&buf[i+j], k}}}; - consuming_buffers cb(bs); - expect(to_string(cb) == s); - cb.consume(0); - expect(to_string(cb) == s); - cb.consume(x); - expect(to_string(cb) == s.substr(x)); - cb.consume(y); - expect(to_string(cb) == s.substr(x+y)); - cb.consume(z); - expect(to_string(cb) == ""); - cb.consume(1); - expect(to_string(cb) == ""); - } - }}}} - } - - void testStaticBuffers() - { - using boost::asio::buffer; - using boost::asio::buffer_cast; - using boost::asio::buffer_size; - char buf[12]; - std::string const s = "Hello, world"; - expect(s.size() == sizeof(buf)); - for(std::size_t i = 1; i < 4; ++i) { - for(std::size_t j = 1; j < 4; ++j) { - for(std::size_t x = 1; x < 4; ++x) { - for(std::size_t y = 1; y < 4; ++y) { - for(std::size_t t = 1; t < 4; ++ t) { - for(std::size_t u = 1; u < 4; ++ u) { - std::size_t z = sizeof(buf) - (x + y); - std::size_t v = sizeof(buf) - (t + u); - { - std::memset(buf, 0, sizeof(buf)); - static_streambuf_n ba; - decltype(ba)::mutable_buffers_type d; - d = ba.prepare(z); expect(buffer_size(d) == z); - d = ba.prepare(0); expect(buffer_size(d) == 0); - d = ba.prepare(y); expect(buffer_size(d) == y); - d = ba.prepare(x); expect(buffer_size(d) == x); - ba.commit(buffer_copy(d, buffer(s.data(), x))); - expect(ba.size() == x); - expect(buffer_size(ba.data()) == ba.size()); - d = ba.prepare(x); expect(buffer_size(d) == x); - d = ba.prepare(0); expect(buffer_size(d) == 0); - d = ba.prepare(z); expect(buffer_size(d) == z); - d = ba.prepare(y); expect(buffer_size(d) == y); - ba.commit(buffer_copy(d, buffer(s.data()+x, y))); - ba.commit(1); - expect(ba.size() == x + y); - expect(buffer_size(ba.data()) == ba.size()); - d = ba.prepare(x); expect(buffer_size(d) == x); - d = ba.prepare(y); expect(buffer_size(d) == y); - d = ba.prepare(0); expect(buffer_size(d) == 0); - d = ba.prepare(z); expect(buffer_size(d) == z); - ba.commit(buffer_copy(d, buffer(s.data()+x+y, z))); - ba.commit(2); - expect(ba.size() == x + y + z); - expect(buffer_size(ba.data()) == ba.size()); - expect(to_string(ba.data()) == s); - ba.consume(t); - d = ba.prepare(0); expect(buffer_size(d) == 0); - expect(to_string(ba.data()) == s.substr(t, std::string::npos)); - ba.consume(u); - expect(to_string(ba.data()) == s.substr(t + u, std::string::npos)); - ba.consume(v); - expect(to_string(ba.data()) == ""); - ba.consume(1); - d = ba.prepare(0); expect(buffer_size(d) == 0); - try - { - ba.prepare(1); - fail(); - } - catch(...) - { - pass(); - } - } - }}}}}} - } - - void testAppendBuffers() - { - using boost::asio::buffer_size; - using boost::asio::const_buffer; - char buf[10]; - std::list b1; - std::vector b2{ - const_buffer{buf+0, 1}, - const_buffer{buf+1, 2}}; - std::list b3; - std::array b4{{ - const_buffer{buf+3, 1}, - const_buffer{buf+4, 2}, - const_buffer{buf+6, 3}}}; - std::list b5{ - const_buffer{buf+9, 1}}; - std::list b6; - auto bs = append_buffers( - b1, b2, b3, b4, b5, b6); - expect(buffer_size(bs) == 10); - std::vector v; - for(auto iter = std::make_reverse_iterator(bs.end()); - iter != std::make_reverse_iterator(bs.begin()); ++iter) - v.emplace_back(*iter); - expect(buffer_size(bs) == 10); - decltype(bs) bs2(bs); - auto bs3(std::move(bs)); - bs = bs2; - bs3 = std::move(bs2); - { - streambuf sb1, sb2; - expect(buffer_size(append_buffers( - sb1.prepare(5), sb2.prepare(7))) == 12); - sb1.commit(5); - sb2.commit(7); - expect(buffer_size(append_buffers( - sb1.data(), sb2.data())) == 12); - } - } - - void testClipBuffers() - { - using boost::asio::const_buffer; - std::string const s = "Hello, world"; - expect(s.size() == 12); - for(std::size_t x = 1; x < 4; ++x) { - for(std::size_t y = 1; y < 4; ++y) { - std::size_t z = s.size() - (x + y); - { - std::array bs{{ - const_buffer{&s[0], x}, - const_buffer{&s[x], y}, - const_buffer{&s[x+y], z}}}; - for(std::size_t i = 0; i <= s.size() + 1; ++i) - expect(to_string(prepare_buffers(i, bs)) == - s.substr(0, i)); - } - }} - } - - void run() override - { - testStreambuf(); - testBuffersAdapter(); - testConsuming(); - testStaticBuffers(); - - testAppendBuffers(); - testClipBuffers(); - } -}; - -BEAST_DEFINE_TESTSUITE(buffers,asio,beast); - -} // test -} // beast diff --git a/src/beast/beast/asio/streambuf.h b/src/beast/beast/asio/streambuf.h deleted file mode 100644 index 22031930cc..0000000000 --- a/src/beast/beast/asio/streambuf.h +++ /dev/null @@ -1,31 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_STREAMBUF_H_INCLUDED -#define BEAST_ASIO_STREAMBUF_H_INCLUDED - -#include - -namespace beast { - -using streambuf = basic_streambuf>; - -} // beast - -#endif diff --git a/src/beast/beast/asio/temp_buffer.h b/src/beast/beast/asio/temp_buffer.h deleted file mode 100644 index a36b9fb621..0000000000 --- a/src/beast/beast/asio/temp_buffer.h +++ /dev/null @@ -1,109 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_TEMP_BUFFER_H_INCLUDED -#define BEAST_ASIO_TEMP_BUFFER_H_INCLUDED - -#include -#include -#include -#include -#include - -namespace beast { - -template -class temp_buffer -{ - Handler& h_; - std::size_t n_ = 0; - std::uint8_t* p_ = nullptr; - -public: - explicit - temp_buffer(Handler& h) - : h_(h) - { - } - - ~temp_buffer() - { - if(p_) - dealloc(); - } - - operator - boost::asio::const_buffer() const - { - return boost::asio::const_buffer{p_, n_}; - } - - operator - boost::asio::mutable_buffer() const - { - return boost::asio::mutable_buffer{p_, n_}; - } - - std::uint8_t* - data() const - { - return p_; - } - - std::size_t - size() - { - return n_; - } - - boost::asio::mutable_buffers_1 - buffers() const - { - return boost::asio::mutable_buffers_1{ - p_, n_}; - } - - void - alloc(std::size_t size) - { - if(n_ != size) - { - if(p_) - dealloc(); - n_ = size; - if(n_ > 0) - p_ = reinterpret_cast( - boost_asio_handler_alloc_helpers:: - allocate(n_, h_)); - } - } - - void - dealloc() - { - boost_asio_handler_alloc_helpers:: - deallocate(p_, n_, h_); - p_ = nullptr; - n_ = 0; - } -}; - -} // beast - -#endif diff --git a/src/beast/beast/crypto/sha.h b/src/beast/beast/crypto/sha.h deleted file mode 100644 index 7d9b05a6c3..0000000000 --- a/src/beast/beast/crypto/sha.h +++ /dev/null @@ -1,34 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_CRYPTO_SHA_H_INCLUDED -#define BEAST_CRYPTO_SHA_H_INCLUDED - -#include -#include - -namespace beast { - -// non-secure -using sha_hasher = detail::mac_facade< - detail::sha_context, false>; - -} - -#endif diff --git a/src/beast/beast/empty_base_optimization.h b/src/beast/beast/empty_base_optimization.h deleted file mode 100644 index 199021bad4..0000000000 --- a/src/beast/beast/empty_base_optimization.h +++ /dev/null @@ -1,111 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2014, Howard Hinnant , - Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_EMPTY_BASE_OPTIMIZATION_H_INCLUDED -#define BEAST_EMPTY_BASE_OPTIMIZATION_H_INCLUDED - -#include -#include - -namespace beast { - -namespace detail { - -template -struct empty_base_optimization_decide - : std::integral_constant ::value -#ifdef __clang__ - && !__is_final(T) -#endif - > -{ -}; - -} - -//------------------------------------------------------------------------------ - -template < - class T, - int UniqueID = 0, - bool ShouldDeriveFrom = - detail::empty_base_optimization_decide ::value -> -class empty_base_optimization : private T -{ -public: - empty_base_optimization() = default; - - empty_base_optimization(T const& t) - : T (t) - {} - - empty_base_optimization(T&& t) - : T (std::move (t)) - {} - - T& member() noexcept - { - return *this; - } - - T const& member() const noexcept - { - return *this; - } -}; - -//------------------------------------------------------------------------------ - -template < - class T, - int UniqueID -> -class empty_base_optimization -{ -public: - empty_base_optimization() = default; - - empty_base_optimization(T const& t) - : m_t (t) - {} - - empty_base_optimization(T&& t) - : m_t (std::move (t)) - {} - - T& member() noexcept - { - return m_t; - } - - T const& member() const noexcept - { - return m_t; - } - -private: - T m_t; -}; - -} - -#endif diff --git a/src/beast/beast/http.h b/src/beast/beast/http.h deleted file mode 100644 index f9ead2b69e..0000000000 --- a/src/beast/beast/http.h +++ /dev/null @@ -1,39 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_H_INCLUDED -#define BEAST_HTTP_H_INCLUDED - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/src/beast/beast/http/body.h b/src/beast/beast/http/body.h deleted file mode 100644 index 90511d2d06..0000000000 --- a/src/beast/beast/http/body.h +++ /dev/null @@ -1,150 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_BODY_H_INCLUDED -#define BEAST_HTTP_BODY_H_INCLUDED - -#include -#include -#include -#include -#include -#include -#include - -namespace beast { -namespace deprecated_http { - -/** Container for the HTTP content-body. */ -class body -{ -private: - using buffer_type = boost::asio::streambuf; - - // Hack: use unique_ptr because streambuf cant be moved - std::unique_ptr buf_; - -public: - using const_buffers_type = buffer_type::const_buffers_type; - - body(); - body (body&& other); - body& operator= (body&& other); - - body (body const&) = delete; - body& operator= (body const&) = delete; - - template - void - clear(); - - void - write (void const* data, std::size_t bytes); - - template - void - write (ConstBufferSequence const& buffers); - - std::size_t - size() const; - - const_buffers_type - data() const; -}; - -template -std::string -to_string (body const& b) -{ - std::string s; - auto const& data (b.data()); - auto const n (boost::asio::buffer_size (data)); - s.resize (n); - boost::asio::buffer_copy ( - boost::asio::buffer (&s[0], n), data); - return s; -} - -//------------------------------------------------------------------------------ - -inline -body::body() - : buf_ (std::make_unique ()) -{ -} - -inline -body::body (body&& other) - : buf_ (std::move(other.buf_)) -{ - other.clear(); -} - -inline -body& -body::operator= (body&& other) -{ - buf_ = std::move(other.buf_); - other.clear(); - return *this; -} - -template -void -body::clear() -{ - buf_ = std::make_unique (); -} - -inline -void -body::write (void const* data, std::size_t bytes) -{ - buf_->commit (boost::asio::buffer_copy (buf_->prepare (bytes), - boost::asio::const_buffers_1 (data, bytes))); -} - -template -void -body::write (ConstBufferSequence const& buffers) -{ - for (auto const& buffer : buffers) - write (boost::asio::buffer_cast (buffer), - boost::asio::buffer_size (buffer)); -} - -inline -std::size_t -body::size() const -{ - return buf_->size(); -} - -inline -auto -body::data() const - -> const_buffers_type -{ - return buf_->data(); -} - -} // deprecated_http -} // beast - -#endif diff --git a/src/beast/beast/http/empty_body.h b/src/beast/beast/http/empty_body.h deleted file mode 100644 index ffe74fd458..0000000000 --- a/src/beast/beast/http/empty_body.h +++ /dev/null @@ -1,87 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_EMPTY_BODY_H_INCLUDED -#define BEAST_HTTP_EMPTY_BODY_H_INCLUDED - -#include -#include -#include -#include -#include -#include - -namespace beast { -namespace http { - -/** An empty content-body. -*/ -struct empty_body -{ - struct value_type - { - }; - - struct reader - { - template - explicit - reader(message&) - { - } - - void - write(void const*, std::size_t, error_code&) - { - } - }; - - struct writer - { - template - explicit - writer(message const& m) - { - } - - void - init(error_code& ec) - { - } - - std::size_t - content_length() const - { - return 0; - } - - template - boost::tribool - operator()(resume_context&&, error_code&, Write&& write) - { - write(boost::asio::null_buffers{}); - return true; - } - }; -}; - -} // http -} // beast - -#endif diff --git a/src/beast/beast/http/headers.h b/src/beast/beast/http/headers.h deleted file mode 100644 index 7457b8111f..0000000000 --- a/src/beast/beast/http/headers.h +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_HEADERS_H_INCLUDED -#define BEAST_HTTP_HEADERS_H_INCLUDED - -#include -#include - -namespace beast { -namespace http { - -template -using headers = basic_headers; - -using http_headers = - basic_headers>; - -} // http -} // beast - -#endif diff --git a/src/beast/beast/http/impl/README.md b/src/beast/beast/http/impl/README.md deleted file mode 100644 index ab82bbba99..0000000000 --- a/src/beast/beast/http/impl/README.md +++ /dev/null @@ -1,3 +0,0 @@ -git-subtree: "http-parser" -remote: https://github.com/joyent/http-parser.git -branch: master diff --git a/src/beast/beast/http/impl/http-parser/.gitignore b/src/beast/beast/http/impl/http-parser/.gitignore deleted file mode 100644 index c122e76fb9..0000000000 --- a/src/beast/beast/http/impl/http-parser/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -/out/ -core -tags -*.o -test -test_g -test_fast -bench -url_parser -parsertrace -parsertrace_g -*.mk -*.Makefile -*.so.* -*.exe.* -*.exe -*.a - - -# Visual Studio uglies -*.suo -*.sln -*.vcxproj -*.vcxproj.filters -*.vcxproj.user -*.opensdf -*.ncrunchsolution* -*.sdf -*.vsp -*.psess diff --git a/src/beast/beast/http/impl/http-parser/.mailmap b/src/beast/beast/http/impl/http-parser/.mailmap deleted file mode 100644 index 278d141263..0000000000 --- a/src/beast/beast/http/impl/http-parser/.mailmap +++ /dev/null @@ -1,8 +0,0 @@ -# update AUTHORS with: -# git log --all --reverse --format='%aN <%aE>' | perl -ne 'BEGIN{print "# Authors ordered by first contribution.\n"} print unless $h{$_}; $h{$_} = 1' > AUTHORS -Ryan Dahl -Salman Haq -Simon Zimmermann -Thomas LE ROUX LE ROUX Thomas -Thomas LE ROUX Thomas LE ROUX -Fedor Indutny diff --git a/src/beast/beast/http/impl/http-parser/.travis.yml b/src/beast/beast/http/impl/http-parser/.travis.yml deleted file mode 100644 index 4b038e6e62..0000000000 --- a/src/beast/beast/http/impl/http-parser/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: c - -compiler: - - clang - - gcc - -script: - - "make" - -notifications: - email: false - irc: - - "irc.freenode.net#node-ci" diff --git a/src/beast/beast/http/impl/http-parser/Makefile b/src/beast/beast/http/impl/http-parser/Makefile deleted file mode 100644 index b3e0ff4ae0..0000000000 --- a/src/beast/beast/http/impl/http-parser/Makefile +++ /dev/null @@ -1,149 +0,0 @@ -# Copyright Joyent, Inc. and other Node contributors. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. - -PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"') -HELPER ?= -BINEXT ?= -ifeq (darwin,$(PLATFORM)) -SONAME ?= libhttp_parser.2.6.1.dylib -SOEXT ?= dylib -else ifeq (wine,$(PLATFORM)) -CC = winegcc -BINEXT = .exe.so -HELPER = wine -else -SONAME ?= libhttp_parser.so.2.6.1 -SOEXT ?= so -endif - -CC?=gcc -AR?=ar - -CPPFLAGS ?= -LDFLAGS ?= - -CPPFLAGS += -I. -CPPFLAGS_DEBUG = $(CPPFLAGS) -DHTTP_PARSER_STRICT=1 -CPPFLAGS_DEBUG += $(CPPFLAGS_DEBUG_EXTRA) -CPPFLAGS_FAST = $(CPPFLAGS) -DHTTP_PARSER_STRICT=0 -CPPFLAGS_FAST += $(CPPFLAGS_FAST_EXTRA) -CPPFLAGS_BENCH = $(CPPFLAGS_FAST) - -CFLAGS += -Wall -Wextra -Werror -CFLAGS_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA) -CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA) -CFLAGS_BENCH = $(CFLAGS_FAST) -Wno-unused-parameter -CFLAGS_LIB = $(CFLAGS_FAST) -fPIC - -LDFLAGS_LIB = $(LDFLAGS) -shared - -INSTALL ?= install -PREFIX ?= $(DESTDIR)/usr/local -LIBDIR = $(PREFIX)/lib -INCLUDEDIR = $(PREFIX)/include - -ifneq (darwin,$(PLATFORM)) -# TODO(bnoordhuis) The native SunOS linker expects -h rather than -soname... -LDFLAGS_LIB += -Wl,-soname=$(SONAME) -endif - -test: test_g test_fast - $(HELPER) ./test_g$(BINEXT) - $(HELPER) ./test_fast$(BINEXT) - -test_g: http_parser_g.o test_g.o - $(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@ - -test_g.o: test.c http_parser.h Makefile - $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c test.c -o $@ - -http_parser_g.o: http_parser.c http_parser.h Makefile - $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c http_parser.c -o $@ - -test_fast: http_parser.o test.o http_parser.h - $(CC) $(CFLAGS_FAST) $(LDFLAGS) http_parser.o test.o -o $@ - -test.o: test.c http_parser.h Makefile - $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c test.c -o $@ - -bench: http_parser.o bench.o - $(CC) $(CFLAGS_BENCH) $(LDFLAGS) http_parser.o bench.o -o $@ - -bench.o: bench.c http_parser.h Makefile - $(CC) $(CPPFLAGS_BENCH) $(CFLAGS_BENCH) -c bench.c -o $@ - -http_parser.o: http_parser.c http_parser.h Makefile - $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c - -test-run-timed: test_fast - while(true) do time $(HELPER) ./test_fast$(BINEXT) > /dev/null; done - -test-valgrind: test_g - valgrind ./test_g - -libhttp_parser.o: http_parser.c http_parser.h Makefile - $(CC) $(CPPFLAGS_FAST) $(CFLAGS_LIB) -c http_parser.c -o libhttp_parser.o - -library: libhttp_parser.o - $(CC) $(LDFLAGS_LIB) -o $(SONAME) $< - -package: http_parser.o - $(AR) rcs libhttp_parser.a http_parser.o - -url_parser: http_parser.o contrib/url_parser.c - $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o $@ - -url_parser_g: http_parser_g.o contrib/url_parser.c - $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o $@ - -parsertrace: http_parser.o contrib/parsertrace.c - $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace$(BINEXT) - -parsertrace_g: http_parser_g.o contrib/parsertrace.c - $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g$(BINEXT) - -tags: http_parser.c http_parser.h test.c - ctags $^ - -install: library - $(INSTALL) -D http_parser.h $(INCLUDEDIR)/http_parser.h - $(INSTALL) -D $(SONAME) $(LIBDIR)/$(SONAME) - ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.$(SOEXT) - -install-strip: library - $(INSTALL) -D http_parser.h $(INCLUDEDIR)/http_parser.h - $(INSTALL) -D -s $(SONAME) $(LIBDIR)/$(SONAME) - ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.$(SOEXT) - -uninstall: - rm $(INCLUDEDIR)/http_parser.h - rm $(LIBDIR)/$(SONAME) - rm $(LIBDIR)/libhttp_parser.so - -clean: - rm -f *.o *.a tags test test_fast test_g \ - http_parser.tar libhttp_parser.so.* \ - url_parser url_parser_g parsertrace parsertrace_g \ - *.exe *.exe.so - -contrib/url_parser.c: http_parser.h -contrib/parsertrace.c: http_parser.h - -.PHONY: clean package test-run test-run-timed test-valgrind install install-strip uninstall diff --git a/src/beast/beast/http/impl/http-parser/bench.c b/src/beast/beast/http/impl/http-parser/bench.c deleted file mode 100644 index 5b452fa1cd..0000000000 --- a/src/beast/beast/http/impl/http-parser/bench.c +++ /dev/null @@ -1,111 +0,0 @@ -/* Copyright Fedor Indutny. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ -#include "http_parser.h" -#include -#include -#include -#include - -static const char data[] = - "POST /joyent/http-parser HTTP/1.1\r\n" - "Host: github.com\r\n" - "DNT: 1\r\n" - "Accept-Encoding: gzip, deflate, sdch\r\n" - "Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4\r\n" - "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) " - "AppleWebKit/537.36 (KHTML, like Gecko) " - "Chrome/39.0.2171.65 Safari/537.36\r\n" - "Accept: text/html,application/xhtml+xml,application/xml;q=0.9," - "image/webp,*/*;q=0.8\r\n" - "Referer: https://github.com/joyent/http-parser\r\n" - "Connection: keep-alive\r\n" - "Transfer-Encoding: chunked\r\n" - "Cache-Control: max-age=0\r\n\r\nb\r\nhello world\r\n0\r\n\r\n"; -static const size_t data_len = sizeof(data) - 1; - -static int on_info(http_parser* p) { - return 0; -} - - -static int on_data(http_parser* p, const char *at, size_t length) { - return 0; -} - -static http_parser_settings settings = { - .on_message_begin = on_info, - .on_headers_complete = on_info, - .on_message_complete = on_info, - .on_header_field = on_data, - .on_header_value = on_data, - .on_url = on_data, - .on_status = on_data, - .on_body = on_data -}; - -int bench(int iter_count, int silent) { - struct http_parser parser; - int i; - int err; - struct timeval start; - struct timeval end; - float rps; - - if (!silent) { - err = gettimeofday(&start, NULL); - assert(err == 0); - } - - for (i = 0; i < iter_count; i++) { - size_t parsed; - http_parser_init(&parser, HTTP_REQUEST); - - parsed = http_parser_execute(&parser, &settings, data, data_len); - assert(parsed == data_len); - } - - if (!silent) { - err = gettimeofday(&end, NULL); - assert(err == 0); - - fprintf(stdout, "Benchmark result:\n"); - - rps = (float) (end.tv_sec - start.tv_sec) + - (end.tv_usec - start.tv_usec) * 1e-6f; - fprintf(stdout, "Took %f seconds to run\n", rps); - - rps = (float) iter_count / rps; - fprintf(stdout, "%f req/sec\n", rps); - fflush(stdout); - } - - return 0; -} - -int main(int argc, char** argv) { - if (argc == 2 && strcmp(argv[1], "infinite") == 0) { - for (;;) - bench(5000000, 1); - return 0; - } else { - return bench(5000000, 0); - } -} diff --git a/src/beast/beast/http/impl/http-parser/contrib/parsertrace.c b/src/beast/beast/http/impl/http-parser/contrib/parsertrace.c deleted file mode 100644 index e7153680f4..0000000000 --- a/src/beast/beast/http/impl/http-parser/contrib/parsertrace.c +++ /dev/null @@ -1,160 +0,0 @@ -/* Based on src/http/ngx_http_parse.c from NGINX copyright Igor Sysoev - * - * Additional changes are licensed under the same terms as NGINX and - * copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -/* Dump what the parser finds to stdout as it happen */ - -#include "http_parser.h" -#include -#include -#include - -int on_message_begin(http_parser* _) { - (void)_; - printf("\n***MESSAGE BEGIN***\n\n"); - return 0; -} - -int on_headers_complete(http_parser* _) { - (void)_; - printf("\n***HEADERS COMPLETE***\n\n"); - return 0; -} - -int on_message_complete(http_parser* _) { - (void)_; - printf("\n***MESSAGE COMPLETE***\n\n"); - return 0; -} - -int on_url(http_parser* _, const char* at, size_t length) { - (void)_; - printf("Url: %.*s\n", (int)length, at); - return 0; -} - -int on_header_field(http_parser* _, const char* at, size_t length) { - (void)_; - printf("Header field: %.*s\n", (int)length, at); - return 0; -} - -int on_header_value(http_parser* _, const char* at, size_t length) { - (void)_; - printf("Header value: %.*s\n", (int)length, at); - return 0; -} - -int on_body(http_parser* _, const char* at, size_t length) { - (void)_; - printf("Body: %.*s\n", (int)length, at); - return 0; -} - -void usage(const char* name) { - fprintf(stderr, - "Usage: %s $type $filename\n" - " type: -x, where x is one of {r,b,q}\n" - " parses file as a Response, reQuest, or Both\n", - name); - exit(EXIT_FAILURE); -} - -int main(int argc, char* argv[]) { - enum http_parser_type file_type; - - if (argc != 3) { - usage(argv[0]); - } - - char* type = argv[1]; - if (type[0] != '-') { - usage(argv[0]); - } - - switch (type[1]) { - /* in the case of "-", type[1] will be NUL */ - case 'r': - file_type = HTTP_RESPONSE; - break; - case 'q': - file_type = HTTP_REQUEST; - break; - case 'b': - file_type = HTTP_BOTH; - break; - default: - usage(argv[0]); - } - - char* filename = argv[2]; - FILE* file = fopen(filename, "r"); - if (file == NULL) { - perror("fopen"); - goto fail; - } - - fseek(file, 0, SEEK_END); - long file_length = ftell(file); - if (file_length == -1) { - perror("ftell"); - goto fail; - } - fseek(file, 0, SEEK_SET); - - char* data = malloc(file_length); - if (fread(data, 1, file_length, file) != (size_t)file_length) { - fprintf(stderr, "couldn't read entire file\n"); - free(data); - goto fail; - } - - http_parser_settings settings; - memset(&settings, 0, sizeof(settings)); - settings.on_message_begin = on_message_begin; - settings.on_url = on_url; - settings.on_header_field = on_header_field; - settings.on_header_value = on_header_value; - settings.on_headers_complete = on_headers_complete; - settings.on_body = on_body; - settings.on_message_complete = on_message_complete; - - http_parser parser; - http_parser_init(&parser, file_type); - size_t nparsed = http_parser_execute(&parser, &settings, data, file_length); - free(data); - - if (nparsed != (size_t)file_length) { - fprintf(stderr, - "Error: %s (%s)\n", - http_errno_description(HTTP_PARSER_ERRNO(&parser)), - http_errno_name(HTTP_PARSER_ERRNO(&parser))); - goto fail; - } - - return EXIT_SUCCESS; - -fail: - fclose(file); - return EXIT_FAILURE; -} diff --git a/src/beast/beast/http/impl/http-parser/contrib/url_parser.c b/src/beast/beast/http/impl/http-parser/contrib/url_parser.c deleted file mode 100644 index f235bed9e4..0000000000 --- a/src/beast/beast/http/impl/http-parser/contrib/url_parser.c +++ /dev/null @@ -1,47 +0,0 @@ -#include "http_parser.h" -#include -#include - -void -dump_url (const char *url, const struct http_parser_url *u) -{ - unsigned int i; - - printf("\tfield_set: 0x%x, port: %u\n", u->field_set, u->port); - for (i = 0; i < UF_MAX; i++) { - if ((u->field_set & (1 << i)) == 0) { - printf("\tfield_data[%u]: unset\n", i); - continue; - } - - printf("\tfield_data[%u]: off: %u, len: %u, part: %.*s\n", - i, - u->field_data[i].off, - u->field_data[i].len, - u->field_data[i].len, - url + u->field_data[i].off); - } -} - -int main(int argc, char ** argv) { - struct http_parser_url u; - int len, connect, result; - - if (argc != 3) { - printf("Syntax : %s connect|get url\n", argv[0]); - return 1; - } - len = strlen(argv[2]); - connect = strcmp("connect", argv[1]) == 0 ? 1 : 0; - printf("Parsing %s, connect %d\n", argv[2], connect); - - http_parser_url_init(&u); - result = http_parser_parse_url(argv[2], len, connect, &u); - if (result != 0) { - printf("Parse error : %d\n", result); - return result; - } - printf("Parse ok, result : \n"); - dump_url(argv[2], &u); - return 0; -} diff --git a/src/beast/beast/http/impl/http-parser/http_parser.gyp b/src/beast/beast/http/impl/http-parser/http_parser.gyp deleted file mode 100644 index ef34ecaeae..0000000000 --- a/src/beast/beast/http/impl/http-parser/http_parser.gyp +++ /dev/null @@ -1,111 +0,0 @@ -# This file is used with the GYP meta build system. -# http://code.google.com/p/gyp/ -# To build try this: -# svn co http://gyp.googlecode.com/svn/trunk gyp -# ./gyp/gyp -f make --depth=`pwd` http_parser.gyp -# ./out/Debug/test -{ - 'target_defaults': { - 'default_configuration': 'Debug', - 'configurations': { - # TODO: hoist these out and put them somewhere common, because - # RuntimeLibrary MUST MATCH across the entire project - 'Debug': { - 'defines': [ 'DEBUG', '_DEBUG' ], - 'cflags': [ '-Wall', '-Wextra', '-O0', '-g', '-ftrapv' ], - 'msvs_settings': { - 'VCCLCompilerTool': { - 'RuntimeLibrary': 1, # static debug - }, - }, - }, - 'Release': { - 'defines': [ 'NDEBUG' ], - 'cflags': [ '-Wall', '-Wextra', '-O3' ], - 'msvs_settings': { - 'VCCLCompilerTool': { - 'RuntimeLibrary': 0, # static release - }, - }, - } - }, - 'msvs_settings': { - 'VCCLCompilerTool': { - }, - 'VCLibrarianTool': { - }, - 'VCLinkerTool': { - 'GenerateDebugInformation': 'true', - }, - }, - 'conditions': [ - ['OS == "win"', { - 'defines': [ - 'WIN32' - ], - }] - ], - }, - - 'targets': [ - { - 'target_name': 'http_parser', - 'type': 'static_library', - 'include_dirs': [ '.' ], - 'direct_dependent_settings': { - 'defines': [ 'HTTP_PARSER_STRICT=0' ], - 'include_dirs': [ '.' ], - }, - 'defines': [ 'HTTP_PARSER_STRICT=0' ], - 'sources': [ './http_parser.c', ], - 'conditions': [ - ['OS=="win"', { - 'msvs_settings': { - 'VCCLCompilerTool': { - # Compile as C++. http_parser.c is actually C99, but C++ is - # close enough in this case. - 'CompileAs': 2, - }, - }, - }] - ], - }, - - { - 'target_name': 'http_parser_strict', - 'type': 'static_library', - 'include_dirs': [ '.' ], - 'direct_dependent_settings': { - 'defines': [ 'HTTP_PARSER_STRICT=1' ], - 'include_dirs': [ '.' ], - }, - 'defines': [ 'HTTP_PARSER_STRICT=1' ], - 'sources': [ './http_parser.c', ], - 'conditions': [ - ['OS=="win"', { - 'msvs_settings': { - 'VCCLCompilerTool': { - # Compile as C++. http_parser.c is actually C99, but C++ is - # close enough in this case. - 'CompileAs': 2, - }, - }, - }] - ], - }, - - { - 'target_name': 'test-nonstrict', - 'type': 'executable', - 'dependencies': [ 'http_parser' ], - 'sources': [ 'test.c' ] - }, - - { - 'target_name': 'test-strict', - 'type': 'executable', - 'dependencies': [ 'http_parser_strict' ], - 'sources': [ 'test.c' ] - } - ] -} diff --git a/src/beast/beast/http/impl/http-parser/test.c b/src/beast/beast/http/impl/http-parser/test.c deleted file mode 100644 index 4fcebaf79e..0000000000 --- a/src/beast/beast/http/impl/http-parser/test.c +++ /dev/null @@ -1,4127 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ -#include "http_parser.h" -#include -#include -#include -#include /* rand */ -#include -#include - -#if defined(__APPLE__) -# undef strlcat -# undef strlncpy -# undef strlcpy -#endif /* defined(__APPLE__) */ - -#undef TRUE -#define TRUE 1 -#undef FALSE -#define FALSE 0 - -#define MAX_HEADERS 13 -#define MAX_ELEMENT_SIZE 2048 -#define MAX_CHUNKS 16 - -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - -static http_parser *parser; - -struct message { - const char *name; // for debugging purposes - const char *raw; - enum http_parser_type type; - enum http_method method; - int status_code; - char response_status[MAX_ELEMENT_SIZE]; - char request_path[MAX_ELEMENT_SIZE]; - char request_url[MAX_ELEMENT_SIZE]; - char fragment[MAX_ELEMENT_SIZE]; - char query_string[MAX_ELEMENT_SIZE]; - char body[MAX_ELEMENT_SIZE]; - size_t body_size; - const char *host; - const char *userinfo; - uint16_t port; - int num_headers; - enum { NONE=0, FIELD, VALUE } last_header_element; - char headers [MAX_HEADERS][2][MAX_ELEMENT_SIZE]; - int should_keep_alive; - - int num_chunks; - int num_chunks_complete; - int chunk_lengths[MAX_CHUNKS]; - - const char *upgrade; // upgraded body - - unsigned short http_major; - unsigned short http_minor; - - int message_begin_cb_called; - int headers_complete_cb_called; - int message_complete_cb_called; - int message_complete_on_eof; - int body_is_final; -}; - -static int currently_parsing_eof; - -static struct message messages[5]; -static int num_messages; -static http_parser_settings *current_pause_parser; - -/* * R E Q U E S T S * */ -const struct message requests[] = -#define CURL_GET 0 -{ {.name= "curl get" - ,.type= HTTP_REQUEST - ,.raw= "GET /test HTTP/1.1\r\n" - "User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1\r\n" - "Host: 0.0.0.0=5000\r\n" - "Accept: */*\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/test" - ,.request_url= "/test" - ,.num_headers= 3 - ,.headers= - { { "User-Agent", "curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1" } - , { "Host", "0.0.0.0=5000" } - , { "Accept", "*/*" } - } - ,.body= "" - } - -#define FIREFOX_GET 1 -, {.name= "firefox get" - ,.type= HTTP_REQUEST - ,.raw= "GET /favicon.ico HTTP/1.1\r\n" - "Host: 0.0.0.0=5000\r\n" - "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0\r\n" - "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n" - "Accept-Language: en-us,en;q=0.5\r\n" - "Accept-Encoding: gzip,deflate\r\n" - "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" - "Keep-Alive: 300\r\n" - "Connection: keep-alive\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/favicon.ico" - ,.request_url= "/favicon.ico" - ,.num_headers= 8 - ,.headers= - { { "Host", "0.0.0.0=5000" } - , { "User-Agent", "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0" } - , { "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" } - , { "Accept-Language", "en-us,en;q=0.5" } - , { "Accept-Encoding", "gzip,deflate" } - , { "Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7" } - , { "Keep-Alive", "300" } - , { "Connection", "keep-alive" } - } - ,.body= "" - } - -#define DUMBFUCK 2 -, {.name= "dumbfuck" - ,.type= HTTP_REQUEST - ,.raw= "GET /dumbfuck HTTP/1.1\r\n" - "aaaaaaaaaaaaa:++++++++++\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/dumbfuck" - ,.request_url= "/dumbfuck" - ,.num_headers= 1 - ,.headers= - { { "aaaaaaaaaaaaa", "++++++++++" } - } - ,.body= "" - } - -#define FRAGMENT_IN_URI 3 -, {.name= "fragment in url" - ,.type= HTTP_REQUEST - ,.raw= "GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "page=1" - ,.fragment= "posts-17408" - ,.request_path= "/forums/1/topics/2375" - /* XXX request url does include fragment? */ - ,.request_url= "/forums/1/topics/2375?page=1#posts-17408" - ,.num_headers= 0 - ,.body= "" - } - -#define GET_NO_HEADERS_NO_BODY 4 -, {.name= "get no headers no body" - ,.type= HTTP_REQUEST - ,.raw= "GET /get_no_headers_no_body/world HTTP/1.1\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE /* would need Connection: close */ - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/get_no_headers_no_body/world" - ,.request_url= "/get_no_headers_no_body/world" - ,.num_headers= 0 - ,.body= "" - } - -#define GET_ONE_HEADER_NO_BODY 5 -, {.name= "get one header no body" - ,.type= HTTP_REQUEST - ,.raw= "GET /get_one_header_no_body HTTP/1.1\r\n" - "Accept: */*\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE /* would need Connection: close */ - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/get_one_header_no_body" - ,.request_url= "/get_one_header_no_body" - ,.num_headers= 1 - ,.headers= - { { "Accept" , "*/*" } - } - ,.body= "" - } - -#define GET_FUNKY_CONTENT_LENGTH 6 -, {.name= "get funky content length body hello" - ,.type= HTTP_REQUEST - ,.raw= "GET /get_funky_content_length_body_hello HTTP/1.0\r\n" - "conTENT-Length: 5\r\n" - "\r\n" - "HELLO" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 0 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/get_funky_content_length_body_hello" - ,.request_url= "/get_funky_content_length_body_hello" - ,.num_headers= 1 - ,.headers= - { { "conTENT-Length" , "5" } - } - ,.body= "HELLO" - } - -#define POST_IDENTITY_BODY_WORLD 7 -, {.name= "post identity body world" - ,.type= HTTP_REQUEST - ,.raw= "POST /post_identity_body_world?q=search#hey HTTP/1.1\r\n" - "Accept: */*\r\n" - "Transfer-Encoding: identity\r\n" - "Content-Length: 5\r\n" - "\r\n" - "World" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_POST - ,.query_string= "q=search" - ,.fragment= "hey" - ,.request_path= "/post_identity_body_world" - ,.request_url= "/post_identity_body_world?q=search#hey" - ,.num_headers= 3 - ,.headers= - { { "Accept", "*/*" } - , { "Transfer-Encoding", "identity" } - , { "Content-Length", "5" } - } - ,.body= "World" - } - -#define POST_CHUNKED_ALL_YOUR_BASE 8 -, {.name= "post - chunked body: all your base are belong to us" - ,.type= HTTP_REQUEST - ,.raw= "POST /post_chunked_all_your_base HTTP/1.1\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "1e\r\nall your base are belong to us\r\n" - "0\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_POST - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/post_chunked_all_your_base" - ,.request_url= "/post_chunked_all_your_base" - ,.num_headers= 1 - ,.headers= - { { "Transfer-Encoding" , "chunked" } - } - ,.body= "all your base are belong to us" - ,.num_chunks_complete= 2 - ,.chunk_lengths= { 0x1e } - } - -#define TWO_CHUNKS_MULT_ZERO_END 9 -, {.name= "two chunks ; triple zero ending" - ,.type= HTTP_REQUEST - ,.raw= "POST /two_chunks_mult_zero_end HTTP/1.1\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "5\r\nhello\r\n" - "6\r\n world\r\n" - "000\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_POST - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/two_chunks_mult_zero_end" - ,.request_url= "/two_chunks_mult_zero_end" - ,.num_headers= 1 - ,.headers= - { { "Transfer-Encoding", "chunked" } - } - ,.body= "hello world" - ,.num_chunks_complete= 3 - ,.chunk_lengths= { 5, 6 } - } - -#define CHUNKED_W_TRAILING_HEADERS 10 -, {.name= "chunked with trailing headers. blech." - ,.type= HTTP_REQUEST - ,.raw= "POST /chunked_w_trailing_headers HTTP/1.1\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "5\r\nhello\r\n" - "6\r\n world\r\n" - "0\r\n" - "Vary: *\r\n" - "Content-Type: text/plain\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_POST - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/chunked_w_trailing_headers" - ,.request_url= "/chunked_w_trailing_headers" - ,.num_headers= 3 - ,.headers= - { { "Transfer-Encoding", "chunked" } - , { "Vary", "*" } - , { "Content-Type", "text/plain" } - } - ,.body= "hello world" - ,.num_chunks_complete= 3 - ,.chunk_lengths= { 5, 6 } - } - -#define CHUNKED_W_BULLSHIT_AFTER_LENGTH 11 -, {.name= "with bullshit after the length" - ,.type= HTTP_REQUEST - ,.raw= "POST /chunked_w_bullshit_after_length HTTP/1.1\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "5; ihatew3;whatthefuck=aretheseparametersfor\r\nhello\r\n" - "6; blahblah; blah\r\n world\r\n" - "0\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_POST - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/chunked_w_bullshit_after_length" - ,.request_url= "/chunked_w_bullshit_after_length" - ,.num_headers= 1 - ,.headers= - { { "Transfer-Encoding", "chunked" } - } - ,.body= "hello world" - ,.num_chunks_complete= 3 - ,.chunk_lengths= { 5, 6 } - } - -#define WITH_QUOTES 12 -, {.name= "with quotes" - ,.type= HTTP_REQUEST - ,.raw= "GET /with_\"stupid\"_quotes?foo=\"bar\" HTTP/1.1\r\n\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "foo=\"bar\"" - ,.fragment= "" - ,.request_path= "/with_\"stupid\"_quotes" - ,.request_url= "/with_\"stupid\"_quotes?foo=\"bar\"" - ,.num_headers= 0 - ,.headers= { } - ,.body= "" - } - -#define APACHEBENCH_GET 13 -/* The server receiving this request SHOULD NOT wait for EOF - * to know that content-length == 0. - * How to represent this in a unit test? message_complete_on_eof - * Compare with NO_CONTENT_LENGTH_RESPONSE. - */ -, {.name = "apachebench get" - ,.type= HTTP_REQUEST - ,.raw= "GET /test HTTP/1.0\r\n" - "Host: 0.0.0.0:5000\r\n" - "User-Agent: ApacheBench/2.3\r\n" - "Accept: */*\r\n\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 0 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/test" - ,.request_url= "/test" - ,.num_headers= 3 - ,.headers= { { "Host", "0.0.0.0:5000" } - , { "User-Agent", "ApacheBench/2.3" } - , { "Accept", "*/*" } - } - ,.body= "" - } - -#define QUERY_URL_WITH_QUESTION_MARK_GET 14 -/* Some clients include '?' characters in query strings. - */ -, {.name = "query url with question mark" - ,.type= HTTP_REQUEST - ,.raw= "GET /test.cgi?foo=bar?baz HTTP/1.1\r\n\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "foo=bar?baz" - ,.fragment= "" - ,.request_path= "/test.cgi" - ,.request_url= "/test.cgi?foo=bar?baz" - ,.num_headers= 0 - ,.headers= {} - ,.body= "" - } - -#define PREFIX_NEWLINE_GET 15 -/* Some clients, especially after a POST in a keep-alive connection, - * will send an extra CRLF before the next request - */ -, {.name = "newline prefix get" - ,.type= HTTP_REQUEST - ,.raw= "\r\nGET /test HTTP/1.1\r\n\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/test" - ,.request_url= "/test" - ,.num_headers= 0 - ,.headers= { } - ,.body= "" - } - -#define UPGRADE_REQUEST 16 -, {.name = "upgrade request" - ,.type= HTTP_REQUEST - ,.raw= "GET /demo HTTP/1.1\r\n" - "Host: example.com\r\n" - "Connection: Upgrade\r\n" - "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" - "Sec-WebSocket-Protocol: sample\r\n" - "Upgrade: WebSocket\r\n" - "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" - "Origin: http://example.com\r\n" - "\r\n" - "Hot diggity dogg" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/demo" - ,.request_url= "/demo" - ,.num_headers= 7 - ,.upgrade="Hot diggity dogg" - ,.headers= { { "Host", "example.com" } - , { "Connection", "Upgrade" } - , { "Sec-WebSocket-Key2", "12998 5 Y3 1 .P00" } - , { "Sec-WebSocket-Protocol", "sample" } - , { "Upgrade", "WebSocket" } - , { "Sec-WebSocket-Key1", "4 @1 46546xW%0l 1 5" } - , { "Origin", "http://example.com" } - } - ,.body= "" - } - -#define CONNECT_REQUEST 17 -, {.name = "connect request" - ,.type= HTTP_REQUEST - ,.raw= "CONNECT 0-home0.netscape.com:443 HTTP/1.0\r\n" - "User-agent: Mozilla/1.1N\r\n" - "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" - "\r\n" - "some data\r\n" - "and yet even more data" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 0 - ,.method= HTTP_CONNECT - ,.query_string= "" - ,.fragment= "" - ,.request_path= "" - ,.request_url= "0-home0.netscape.com:443" - ,.num_headers= 2 - ,.upgrade="some data\r\nand yet even more data" - ,.headers= { { "User-agent", "Mozilla/1.1N" } - , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } - } - ,.body= "" - } - -#define REPORT_REQ 18 -, {.name= "report request" - ,.type= HTTP_REQUEST - ,.raw= "REPORT /test HTTP/1.1\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_REPORT - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/test" - ,.request_url= "/test" - ,.num_headers= 0 - ,.headers= {} - ,.body= "" - } - -#define NO_HTTP_VERSION 19 -, {.name= "request with no http version" - ,.type= HTTP_REQUEST - ,.raw= "GET /\r\n" - "\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 0 - ,.http_minor= 9 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/" - ,.request_url= "/" - ,.num_headers= 0 - ,.headers= {} - ,.body= "" - } - -#define MSEARCH_REQ 20 -, {.name= "m-search request" - ,.type= HTTP_REQUEST - ,.raw= "M-SEARCH * HTTP/1.1\r\n" - "HOST: 239.255.255.250:1900\r\n" - "MAN: \"ssdp:discover\"\r\n" - "ST: \"ssdp:all\"\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_MSEARCH - ,.query_string= "" - ,.fragment= "" - ,.request_path= "*" - ,.request_url= "*" - ,.num_headers= 3 - ,.headers= { { "HOST", "239.255.255.250:1900" } - , { "MAN", "\"ssdp:discover\"" } - , { "ST", "\"ssdp:all\"" } - } - ,.body= "" - } - -#define LINE_FOLDING_IN_HEADER 21 -, {.name= "line folding in header value" - ,.type= HTTP_REQUEST - ,.raw= "GET / HTTP/1.1\r\n" - "Line1: abc\r\n" - "\tdef\r\n" - " ghi\r\n" - "\t\tjkl\r\n" - " mno \r\n" - "\t \tqrs\r\n" - "Line2: \t line2\t\r\n" - "Line3:\r\n" - " line3\r\n" - "Line4: \r\n" - " \r\n" - "Connection:\r\n" - " close\r\n" - "\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/" - ,.request_url= "/" - ,.num_headers= 5 - ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" } - , { "Line2", "line2\t" } - , { "Line3", "line3" } - , { "Line4", "" } - , { "Connection", "close" }, - } - ,.body= "" - } - - -#define QUERY_TERMINATED_HOST 22 -, {.name= "host terminated by a query string" - ,.type= HTTP_REQUEST - ,.raw= "GET http://hypnotoad.org?hail=all HTTP/1.1\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "hail=all" - ,.fragment= "" - ,.request_path= "" - ,.request_url= "http://hypnotoad.org?hail=all" - ,.host= "hypnotoad.org" - ,.num_headers= 0 - ,.headers= { } - ,.body= "" - } - -#define QUERY_TERMINATED_HOSTPORT 23 -, {.name= "host:port terminated by a query string" - ,.type= HTTP_REQUEST - ,.raw= "GET http://hypnotoad.org:1234?hail=all HTTP/1.1\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "hail=all" - ,.fragment= "" - ,.request_path= "" - ,.request_url= "http://hypnotoad.org:1234?hail=all" - ,.host= "hypnotoad.org" - ,.port= 1234 - ,.num_headers= 0 - ,.headers= { } - ,.body= "" - } - -#define SPACE_TERMINATED_HOSTPORT 24 -, {.name= "host:port terminated by a space" - ,.type= HTTP_REQUEST - ,.raw= "GET http://hypnotoad.org:1234 HTTP/1.1\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "" - ,.request_url= "http://hypnotoad.org:1234" - ,.host= "hypnotoad.org" - ,.port= 1234 - ,.num_headers= 0 - ,.headers= { } - ,.body= "" - } - -#define PATCH_REQ 25 -, {.name = "PATCH request" - ,.type= HTTP_REQUEST - ,.raw= "PATCH /file.txt HTTP/1.1\r\n" - "Host: www.example.com\r\n" - "Content-Type: application/example\r\n" - "If-Match: \"e0023aa4e\"\r\n" - "Content-Length: 10\r\n" - "\r\n" - "cccccccccc" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_PATCH - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/file.txt" - ,.request_url= "/file.txt" - ,.num_headers= 4 - ,.headers= { { "Host", "www.example.com" } - , { "Content-Type", "application/example" } - , { "If-Match", "\"e0023aa4e\"" } - , { "Content-Length", "10" } - } - ,.body= "cccccccccc" - } - -#define CONNECT_CAPS_REQUEST 26 -, {.name = "connect caps request" - ,.type= HTTP_REQUEST - ,.raw= "CONNECT HOME0.NETSCAPE.COM:443 HTTP/1.0\r\n" - "User-agent: Mozilla/1.1N\r\n" - "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" - "\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 0 - ,.method= HTTP_CONNECT - ,.query_string= "" - ,.fragment= "" - ,.request_path= "" - ,.request_url= "HOME0.NETSCAPE.COM:443" - ,.num_headers= 2 - ,.upgrade="" - ,.headers= { { "User-agent", "Mozilla/1.1N" } - , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } - } - ,.body= "" - } - -#if !HTTP_PARSER_STRICT -#define UTF8_PATH_REQ 27 -, {.name= "utf-8 path request" - ,.type= HTTP_REQUEST - ,.raw= "GET /δ¶/δt/pope?q=1#narf HTTP/1.1\r\n" - "Host: github.com\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "q=1" - ,.fragment= "narf" - ,.request_path= "/δ¶/δt/pope" - ,.request_url= "/δ¶/δt/pope?q=1#narf" - ,.num_headers= 1 - ,.headers= { {"Host", "github.com" } - } - ,.body= "" - } - -#define HOSTNAME_UNDERSCORE 28 -, {.name = "hostname underscore" - ,.type= HTTP_REQUEST - ,.raw= "CONNECT home_0.netscape.com:443 HTTP/1.0\r\n" - "User-agent: Mozilla/1.1N\r\n" - "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" - "\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 0 - ,.method= HTTP_CONNECT - ,.query_string= "" - ,.fragment= "" - ,.request_path= "" - ,.request_url= "home_0.netscape.com:443" - ,.num_headers= 2 - ,.upgrade="" - ,.headers= { { "User-agent", "Mozilla/1.1N" } - , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } - } - ,.body= "" - } -#endif /* !HTTP_PARSER_STRICT */ - -/* see https://github.com/ry/http-parser/issues/47 */ -#define EAT_TRAILING_CRLF_NO_CONNECTION_CLOSE 29 -, {.name = "eat CRLF between requests, no \"Connection: close\" header" - ,.raw= "POST / HTTP/1.1\r\n" - "Host: www.example.com\r\n" - "Content-Type: application/x-www-form-urlencoded\r\n" - "Content-Length: 4\r\n" - "\r\n" - "q=42\r\n" /* note the trailing CRLF */ - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_POST - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/" - ,.request_url= "/" - ,.num_headers= 3 - ,.upgrade= 0 - ,.headers= { { "Host", "www.example.com" } - , { "Content-Type", "application/x-www-form-urlencoded" } - , { "Content-Length", "4" } - } - ,.body= "q=42" - } - -/* see https://github.com/ry/http-parser/issues/47 */ -#define EAT_TRAILING_CRLF_WITH_CONNECTION_CLOSE 30 -, {.name = "eat CRLF between requests even if \"Connection: close\" is set" - ,.raw= "POST / HTTP/1.1\r\n" - "Host: www.example.com\r\n" - "Content-Type: application/x-www-form-urlencoded\r\n" - "Content-Length: 4\r\n" - "Connection: close\r\n" - "\r\n" - "q=42\r\n" /* note the trailing CRLF */ - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE /* input buffer isn't empty when on_message_complete is called */ - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_POST - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/" - ,.request_url= "/" - ,.num_headers= 4 - ,.upgrade= 0 - ,.headers= { { "Host", "www.example.com" } - , { "Content-Type", "application/x-www-form-urlencoded" } - , { "Content-Length", "4" } - , { "Connection", "close" } - } - ,.body= "q=42" - } - -#define PURGE_REQ 31 -, {.name = "PURGE request" - ,.type= HTTP_REQUEST - ,.raw= "PURGE /file.txt HTTP/1.1\r\n" - "Host: www.example.com\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_PURGE - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/file.txt" - ,.request_url= "/file.txt" - ,.num_headers= 1 - ,.headers= { { "Host", "www.example.com" } } - ,.body= "" - } - -#define SEARCH_REQ 32 -, {.name = "SEARCH request" - ,.type= HTTP_REQUEST - ,.raw= "SEARCH / HTTP/1.1\r\n" - "Host: www.example.com\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_SEARCH - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/" - ,.request_url= "/" - ,.num_headers= 1 - ,.headers= { { "Host", "www.example.com" } } - ,.body= "" - } - -#define PROXY_WITH_BASIC_AUTH 33 -, {.name= "host:port and basic_auth" - ,.type= HTTP_REQUEST - ,.raw= "GET http://a%12:b!&*$@hypnotoad.org:1234/toto HTTP/1.1\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.fragment= "" - ,.request_path= "/toto" - ,.request_url= "http://a%12:b!&*$@hypnotoad.org:1234/toto" - ,.host= "hypnotoad.org" - ,.userinfo= "a%12:b!&*$" - ,.port= 1234 - ,.num_headers= 0 - ,.headers= { } - ,.body= "" - } - -#define LINE_FOLDING_IN_HEADER_WITH_LF 34 -, {.name= "line folding in header value" - ,.type= HTTP_REQUEST - ,.raw= "GET / HTTP/1.1\n" - "Line1: abc\n" - "\tdef\n" - " ghi\n" - "\t\tjkl\n" - " mno \n" - "\t \tqrs\n" - "Line2: \t line2\t\n" - "Line3:\n" - " line3\n" - "Line4: \n" - " \n" - "Connection:\n" - " close\n" - "\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/" - ,.request_url= "/" - ,.num_headers= 5 - ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" } - , { "Line2", "line2\t" } - , { "Line3", "line3" } - , { "Line4", "" } - , { "Connection", "close" }, - } - ,.body= "" - } - -#define CONNECTION_MULTI 35 -, {.name = "multiple connection header values with folding" - ,.type= HTTP_REQUEST - ,.raw= "GET /demo HTTP/1.1\r\n" - "Host: example.com\r\n" - "Connection: Something,\r\n" - " Upgrade, ,Keep-Alive\r\n" - "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" - "Sec-WebSocket-Protocol: sample\r\n" - "Upgrade: WebSocket\r\n" - "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" - "Origin: http://example.com\r\n" - "\r\n" - "Hot diggity dogg" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/demo" - ,.request_url= "/demo" - ,.num_headers= 7 - ,.upgrade="Hot diggity dogg" - ,.headers= { { "Host", "example.com" } - , { "Connection", "Something, Upgrade, ,Keep-Alive" } - , { "Sec-WebSocket-Key2", "12998 5 Y3 1 .P00" } - , { "Sec-WebSocket-Protocol", "sample" } - , { "Upgrade", "WebSocket" } - , { "Sec-WebSocket-Key1", "4 @1 46546xW%0l 1 5" } - , { "Origin", "http://example.com" } - } - ,.body= "" - } - -#define CONNECTION_MULTI_LWS 36 -, {.name = "multiple connection header values with folding and lws" - ,.type= HTTP_REQUEST - ,.raw= "GET /demo HTTP/1.1\r\n" - "Connection: keep-alive, upgrade\r\n" - "Upgrade: WebSocket\r\n" - "\r\n" - "Hot diggity dogg" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/demo" - ,.request_url= "/demo" - ,.num_headers= 2 - ,.upgrade="Hot diggity dogg" - ,.headers= { { "Connection", "keep-alive, upgrade" } - , { "Upgrade", "WebSocket" } - } - ,.body= "" - } - -#define CONNECTION_MULTI_LWS_CRLF 37 -, {.name = "multiple connection header values with folding and lws" - ,.type= HTTP_REQUEST - ,.raw= "GET /demo HTTP/1.1\r\n" - "Connection: keep-alive, \r\n upgrade\r\n" - "Upgrade: WebSocket\r\n" - "\r\n" - "Hot diggity dogg" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_GET - ,.query_string= "" - ,.fragment= "" - ,.request_path= "/demo" - ,.request_url= "/demo" - ,.num_headers= 2 - ,.upgrade="Hot diggity dogg" - ,.headers= { { "Connection", "keep-alive, upgrade" } - , { "Upgrade", "WebSocket" } - } - ,.body= "" - } - -#define UPGRADE_POST_REQUEST 38 -, {.name = "upgrade post request" - ,.type= HTTP_REQUEST - ,.raw= "POST /demo HTTP/1.1\r\n" - "Host: example.com\r\n" - "Connection: Upgrade\r\n" - "Upgrade: HTTP/2.0\r\n" - "Content-Length: 15\r\n" - "\r\n" - "sweet post body" - "Hot diggity dogg" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_POST - ,.request_path= "/demo" - ,.request_url= "/demo" - ,.num_headers= 4 - ,.upgrade="Hot diggity dogg" - ,.headers= { { "Host", "example.com" } - , { "Connection", "Upgrade" } - , { "Upgrade", "HTTP/2.0" } - , { "Content-Length", "15" } - } - ,.body= "sweet post body" - } - -#define CONNECT_WITH_BODY_REQUEST 39 -, {.name = "connect with body request" - ,.type= HTTP_REQUEST - ,.raw= "CONNECT foo.bar.com:443 HTTP/1.0\r\n" - "User-agent: Mozilla/1.1N\r\n" - "Proxy-authorization: basic aGVsbG86d29ybGQ=\r\n" - "Content-Length: 10\r\n" - "\r\n" - "blarfcicle" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 0 - ,.method= HTTP_CONNECT - ,.request_url= "foo.bar.com:443" - ,.num_headers= 3 - ,.upgrade="blarfcicle" - ,.headers= { { "User-agent", "Mozilla/1.1N" } - , { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" } - , { "Content-Length", "10" } - } - ,.body= "" - } - -/* Examples from the Internet draft for LINK/UNLINK methods: - * https://tools.ietf.org/id/draft-snell-link-method-01.html#rfc.section.5 - */ - -#define LINK_REQUEST 40 -, {.name = "link request" - ,.type= HTTP_REQUEST - ,.raw= "LINK /images/my_dog.jpg HTTP/1.1\r\n" - "Host: example.com\r\n" - "Link: ; rel=\"tag\"\r\n" - "Link: ; rel=\"tag\"\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_LINK - ,.request_path= "/images/my_dog.jpg" - ,.request_url= "/images/my_dog.jpg" - ,.query_string= "" - ,.fragment= "" - ,.num_headers= 3 - ,.headers= { { "Host", "example.com" } - , { "Link", "; rel=\"tag\"" } - , { "Link", "; rel=\"tag\"" } - } - ,.body= "" - } - -#define UNLINK_REQUEST 41 -, {.name = "link request" - ,.type= HTTP_REQUEST - ,.raw= "UNLINK /images/my_dog.jpg HTTP/1.1\r\n" - "Host: example.com\r\n" - "Link: ; rel=\"tag\"\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.method= HTTP_UNLINK - ,.request_path= "/images/my_dog.jpg" - ,.request_url= "/images/my_dog.jpg" - ,.query_string= "" - ,.fragment= "" - ,.num_headers= 2 - ,.headers= { { "Host", "example.com" } - , { "Link", "; rel=\"tag\"" } - } - ,.body= "" - } - -, {.name= NULL } /* sentinel */ -}; - -/* * R E S P O N S E S * */ -const struct message responses[] = -#define GOOGLE_301 0 -{ {.name= "google 301" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 301 Moved Permanently\r\n" - "Location: http://www.google.com/\r\n" - "Content-Type: text/html; charset=UTF-8\r\n" - "Date: Sun, 26 Apr 2009 11:11:49 GMT\r\n" - "Expires: Tue, 26 May 2009 11:11:49 GMT\r\n" - "X-$PrototypeBI-Version: 1.6.0.3\r\n" /* $ char in header field */ - "Cache-Control: public, max-age=2592000\r\n" - "Server: gws\r\n" - "Content-Length: 219 \r\n" - "\r\n" - "\n" - "301 Moved\n" - "

301 Moved

\n" - "The document has moved\n" - "here.\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 301 - ,.response_status= "Moved Permanently" - ,.num_headers= 8 - ,.headers= - { { "Location", "http://www.google.com/" } - , { "Content-Type", "text/html; charset=UTF-8" } - , { "Date", "Sun, 26 Apr 2009 11:11:49 GMT" } - , { "Expires", "Tue, 26 May 2009 11:11:49 GMT" } - , { "X-$PrototypeBI-Version", "1.6.0.3" } - , { "Cache-Control", "public, max-age=2592000" } - , { "Server", "gws" } - , { "Content-Length", "219 " } - } - ,.body= "\n" - "301 Moved\n" - "

301 Moved

\n" - "The document has moved\n" - "here.\r\n" - "\r\n" - } - -#define NO_CONTENT_LENGTH_RESPONSE 1 -/* The client should wait for the server's EOF. That is, when content-length - * is not specified, and "Connection: close", the end of body is specified - * by the EOF. - * Compare with APACHEBENCH_GET - */ -, {.name= "no content-length response" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\r\n" - "Date: Tue, 04 Aug 2009 07:59:32 GMT\r\n" - "Server: Apache\r\n" - "X-Powered-By: Servlet/2.5 JSP/2.1\r\n" - "Content-Type: text/xml; charset=utf-8\r\n" - "Connection: close\r\n" - "\r\n" - "\n" - "\n" - " \n" - " \n" - " SOAP-ENV:Client\n" - " Client Error\n" - " \n" - " \n" - "" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= TRUE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 5 - ,.headers= - { { "Date", "Tue, 04 Aug 2009 07:59:32 GMT" } - , { "Server", "Apache" } - , { "X-Powered-By", "Servlet/2.5 JSP/2.1" } - , { "Content-Type", "text/xml; charset=utf-8" } - , { "Connection", "close" } - } - ,.body= "\n" - "\n" - " \n" - " \n" - " SOAP-ENV:Client\n" - " Client Error\n" - " \n" - " \n" - "" - } - -#define NO_HEADERS_NO_BODY_404 2 -, {.name= "404 no headers no body" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 404 Not Found\r\n\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= TRUE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 404 - ,.response_status= "Not Found" - ,.num_headers= 0 - ,.headers= {} - ,.body_size= 0 - ,.body= "" - } - -#define NO_REASON_PHRASE 3 -, {.name= "301 no response phrase" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 301\r\n\r\n" - ,.should_keep_alive = FALSE - ,.message_complete_on_eof= TRUE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 301 - ,.response_status= "" - ,.num_headers= 0 - ,.headers= {} - ,.body= "" - } - -#define TRAILING_SPACE_ON_CHUNKED_BODY 4 -, {.name="200 trailing space on chunked body" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\r\n" - "Content-Type: text/plain\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "25 \r\n" - "This is the data in the first chunk\r\n" - "\r\n" - "1C\r\n" - "and this is the second one\r\n" - "\r\n" - "0 \r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 2 - ,.headers= - { {"Content-Type", "text/plain" } - , {"Transfer-Encoding", "chunked" } - } - ,.body_size = 37+28 - ,.body = - "This is the data in the first chunk\r\n" - "and this is the second one\r\n" - ,.num_chunks_complete= 3 - ,.chunk_lengths= { 0x25, 0x1c } - } - -#define NO_CARRIAGE_RET 5 -, {.name="no carriage ret" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\n" - "Content-Type: text/html; charset=utf-8\n" - "Connection: close\n" - "\n" - "these headers are from http://news.ycombinator.com/" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= TRUE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 2 - ,.headers= - { {"Content-Type", "text/html; charset=utf-8" } - , {"Connection", "close" } - } - ,.body= "these headers are from http://news.ycombinator.com/" - } - -#define PROXY_CONNECTION 6 -, {.name="proxy connection" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\r\n" - "Content-Type: text/html; charset=UTF-8\r\n" - "Content-Length: 11\r\n" - "Proxy-Connection: close\r\n" - "Date: Thu, 31 Dec 2009 20:55:48 +0000\r\n" - "\r\n" - "hello world" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 4 - ,.headers= - { {"Content-Type", "text/html; charset=UTF-8" } - , {"Content-Length", "11" } - , {"Proxy-Connection", "close" } - , {"Date", "Thu, 31 Dec 2009 20:55:48 +0000"} - } - ,.body= "hello world" - } - -#define UNDERSTORE_HEADER_KEY 7 - // shown by - // curl -o /dev/null -v "http://ad.doubleclick.net/pfadx/DARTSHELLCONFIGXML;dcmt=text/xml;" -, {.name="underscore header key" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\r\n" - "Server: DCLK-AdSvr\r\n" - "Content-Type: text/xml\r\n" - "Content-Length: 0\r\n" - "DCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o\r\n\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 4 - ,.headers= - { {"Server", "DCLK-AdSvr" } - , {"Content-Type", "text/xml" } - , {"Content-Length", "0" } - , {"DCLK_imp", "v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o" } - } - ,.body= "" - } - -#define BONJOUR_MADAME_FR 8 -/* The client should not merge two headers fields when the first one doesn't - * have a value. - */ -, {.name= "bonjourmadame.fr" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.0 301 Moved Permanently\r\n" - "Date: Thu, 03 Jun 2010 09:56:32 GMT\r\n" - "Server: Apache/2.2.3 (Red Hat)\r\n" - "Cache-Control: public\r\n" - "Pragma: \r\n" - "Location: http://www.bonjourmadame.fr/\r\n" - "Vary: Accept-Encoding\r\n" - "Content-Length: 0\r\n" - "Content-Type: text/html; charset=UTF-8\r\n" - "Connection: keep-alive\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 0 - ,.status_code= 301 - ,.response_status= "Moved Permanently" - ,.num_headers= 9 - ,.headers= - { { "Date", "Thu, 03 Jun 2010 09:56:32 GMT" } - , { "Server", "Apache/2.2.3 (Red Hat)" } - , { "Cache-Control", "public" } - , { "Pragma", "" } - , { "Location", "http://www.bonjourmadame.fr/" } - , { "Vary", "Accept-Encoding" } - , { "Content-Length", "0" } - , { "Content-Type", "text/html; charset=UTF-8" } - , { "Connection", "keep-alive" } - } - ,.body= "" - } - -#define RES_FIELD_UNDERSCORE 9 -/* Should handle spaces in header fields */ -, {.name= "field underscore" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\r\n" - "Date: Tue, 28 Sep 2010 01:14:13 GMT\r\n" - "Server: Apache\r\n" - "Cache-Control: no-cache, must-revalidate\r\n" - "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n" - ".et-Cookie: PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com\r\n" - "Vary: Accept-Encoding\r\n" - "_eep-Alive: timeout=45\r\n" /* semantic value ignored */ - "_onnection: Keep-Alive\r\n" /* semantic value ignored */ - "Transfer-Encoding: chunked\r\n" - "Content-Type: text/html\r\n" - "Connection: close\r\n" - "\r\n" - "0\r\n\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 11 - ,.headers= - { { "Date", "Tue, 28 Sep 2010 01:14:13 GMT" } - , { "Server", "Apache" } - , { "Cache-Control", "no-cache, must-revalidate" } - , { "Expires", "Mon, 26 Jul 1997 05:00:00 GMT" } - , { ".et-Cookie", "PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com" } - , { "Vary", "Accept-Encoding" } - , { "_eep-Alive", "timeout=45" } - , { "_onnection", "Keep-Alive" } - , { "Transfer-Encoding", "chunked" } - , { "Content-Type", "text/html" } - , { "Connection", "close" } - } - ,.body= "" - ,.num_chunks_complete= 1 - ,.chunk_lengths= {} - } - -#define NON_ASCII_IN_STATUS_LINE 10 -/* Should handle non-ASCII in status line */ -, {.name= "non-ASCII in status line" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 500 Oriëntatieprobleem\r\n" - "Date: Fri, 5 Nov 2010 23:07:12 GMT+2\r\n" - "Content-Length: 0\r\n" - "Connection: close\r\n" - "\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 500 - ,.response_status= "Oriëntatieprobleem" - ,.num_headers= 3 - ,.headers= - { { "Date", "Fri, 5 Nov 2010 23:07:12 GMT+2" } - , { "Content-Length", "0" } - , { "Connection", "close" } - } - ,.body= "" - } - -#define HTTP_VERSION_0_9 11 -/* Should handle HTTP/0.9 */ -, {.name= "http version 0.9" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/0.9 200 OK\r\n" - "\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= TRUE - ,.http_major= 0 - ,.http_minor= 9 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 0 - ,.headers= - {} - ,.body= "" - } - -#define NO_CONTENT_LENGTH_NO_TRANSFER_ENCODING_RESPONSE 12 -/* The client should wait for the server's EOF. That is, when neither - * content-length nor transfer-encoding is specified, the end of body - * is specified by the EOF. - */ -, {.name= "neither content-length nor transfer-encoding response" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\r\n" - "Content-Type: text/plain\r\n" - "\r\n" - "hello world" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= TRUE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 1 - ,.headers= - { { "Content-Type", "text/plain" } - } - ,.body= "hello world" - } - -#define NO_BODY_HTTP10_KA_200 13 -, {.name= "HTTP/1.0 with keep-alive and EOF-terminated 200 status" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.0 200 OK\r\n" - "Connection: keep-alive\r\n" - "\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= TRUE - ,.http_major= 1 - ,.http_minor= 0 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 1 - ,.headers= - { { "Connection", "keep-alive" } - } - ,.body_size= 0 - ,.body= "" - } - -#define NO_BODY_HTTP10_KA_204 14 -, {.name= "HTTP/1.0 with keep-alive and a 204 status" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.0 204 No content\r\n" - "Connection: keep-alive\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 0 - ,.status_code= 204 - ,.response_status= "No content" - ,.num_headers= 1 - ,.headers= - { { "Connection", "keep-alive" } - } - ,.body_size= 0 - ,.body= "" - } - -#define NO_BODY_HTTP11_KA_200 15 -, {.name= "HTTP/1.1 with an EOF-terminated 200 status" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\r\n" - "\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= TRUE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 0 - ,.headers={} - ,.body_size= 0 - ,.body= "" - } - -#define NO_BODY_HTTP11_KA_204 16 -, {.name= "HTTP/1.1 with a 204 status" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 204 No content\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 204 - ,.response_status= "No content" - ,.num_headers= 0 - ,.headers={} - ,.body_size= 0 - ,.body= "" - } - -#define NO_BODY_HTTP11_NOKA_204 17 -, {.name= "HTTP/1.1 with a 204 status and keep-alive disabled" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 204 No content\r\n" - "Connection: close\r\n" - "\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 204 - ,.response_status= "No content" - ,.num_headers= 1 - ,.headers= - { { "Connection", "close" } - } - ,.body_size= 0 - ,.body= "" - } - -#define NO_BODY_HTTP11_KA_CHUNKED_200 18 -, {.name= "HTTP/1.1 with chunked endocing and a 200 response" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "0\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 1 - ,.headers= - { { "Transfer-Encoding", "chunked" } - } - ,.body_size= 0 - ,.body= "" - ,.num_chunks_complete= 1 - } - -#if !HTTP_PARSER_STRICT -#define SPACE_IN_FIELD_RES 19 -/* Should handle spaces in header fields */ -, {.name= "field space" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 OK\r\n" - "Server: Microsoft-IIS/6.0\r\n" - "X-Powered-By: ASP.NET\r\n" - "en-US Content-Type: text/xml\r\n" /* this is the problem */ - "Content-Type: text/xml\r\n" - "Content-Length: 16\r\n" - "Date: Fri, 23 Jul 2010 18:45:38 GMT\r\n" - "Connection: keep-alive\r\n" - "\r\n" - "hello" /* fake body */ - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 7 - ,.headers= - { { "Server", "Microsoft-IIS/6.0" } - , { "X-Powered-By", "ASP.NET" } - , { "en-US Content-Type", "text/xml" } - , { "Content-Type", "text/xml" } - , { "Content-Length", "16" } - , { "Date", "Fri, 23 Jul 2010 18:45:38 GMT" } - , { "Connection", "keep-alive" } - } - ,.body= "hello" - } -#endif /* !HTTP_PARSER_STRICT */ - -#define AMAZON_COM 20 -, {.name= "amazon.com" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 301 MovedPermanently\r\n" - "Date: Wed, 15 May 2013 17:06:33 GMT\r\n" - "Server: Server\r\n" - "x-amz-id-1: 0GPHKXSJQ826RK7GZEB2\r\n" - "p3p: policyref=\"http://www.amazon.com/w3c/p3p.xml\",CP=\"CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC \"\r\n" - "x-amz-id-2: STN69VZxIFSz9YJLbz1GDbxpbjG6Qjmmq5E3DxRhOUw+Et0p4hr7c/Q8qNcx4oAD\r\n" - "Location: http://www.amazon.com/Dan-Brown/e/B000AP9DSU/ref=s9_pop_gw_al1?_encoding=UTF8&refinementId=618073011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-2&pf_rd_r=0SHYY5BZXN3KR20BNFAY&pf_rd_t=101&pf_rd_p=1263340922&pf_rd_i=507846\r\n" - "Vary: Accept-Encoding,User-Agent\r\n" - "Content-Type: text/html; charset=ISO-8859-1\r\n" - "Transfer-Encoding: chunked\r\n" - "\r\n" - "1\r\n" - "\n\r\n" - "0\r\n" - "\r\n" - ,.should_keep_alive= TRUE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 301 - ,.response_status= "MovedPermanently" - ,.num_headers= 9 - ,.headers= { { "Date", "Wed, 15 May 2013 17:06:33 GMT" } - , { "Server", "Server" } - , { "x-amz-id-1", "0GPHKXSJQ826RK7GZEB2" } - , { "p3p", "policyref=\"http://www.amazon.com/w3c/p3p.xml\",CP=\"CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC \"" } - , { "x-amz-id-2", "STN69VZxIFSz9YJLbz1GDbxpbjG6Qjmmq5E3DxRhOUw+Et0p4hr7c/Q8qNcx4oAD" } - , { "Location", "http://www.amazon.com/Dan-Brown/e/B000AP9DSU/ref=s9_pop_gw_al1?_encoding=UTF8&refinementId=618073011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-2&pf_rd_r=0SHYY5BZXN3KR20BNFAY&pf_rd_t=101&pf_rd_p=1263340922&pf_rd_i=507846" } - , { "Vary", "Accept-Encoding,User-Agent" } - , { "Content-Type", "text/html; charset=ISO-8859-1" } - , { "Transfer-Encoding", "chunked" } - } - ,.body= "\n" - ,.num_chunks_complete= 2 - ,.chunk_lengths= { 1 } - } - -#define EMPTY_REASON_PHRASE_AFTER_SPACE 20 -, {.name= "empty reason phrase after space" - ,.type= HTTP_RESPONSE - ,.raw= "HTTP/1.1 200 \r\n" - "\r\n" - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= TRUE - ,.http_major= 1 - ,.http_minor= 1 - ,.status_code= 200 - ,.response_status= "" - ,.num_headers= 0 - ,.headers= {} - ,.body= "" - } - -, {.name= NULL } /* sentinel */ -}; - -/* strnlen() is a POSIX.2008 addition. Can't rely on it being available so - * define it ourselves. - */ -size_t -strnlen(const char *s, size_t maxlen) -{ - const char *p; - - p = memchr(s, '\0', maxlen); - if (p == NULL) - return maxlen; - - return p - s; -} - -size_t -strlncat(char *dst, size_t len, const char *src, size_t n) -{ - size_t slen; - size_t dlen; - size_t rlen; - size_t ncpy; - - slen = strnlen(src, n); - dlen = strnlen(dst, len); - - if (dlen < len) { - rlen = len - dlen; - ncpy = slen < rlen ? slen : (rlen - 1); - memcpy(dst + dlen, src, ncpy); - dst[dlen + ncpy] = '\0'; - } - - assert(len > slen + dlen); - return slen + dlen; -} - -size_t -strlcat(char *dst, const char *src, size_t len) -{ - return strlncat(dst, len, src, (size_t) -1); -} - -size_t -strlncpy(char *dst, size_t len, const char *src, size_t n) -{ - size_t slen; - size_t ncpy; - - slen = strnlen(src, n); - - if (len > 0) { - ncpy = slen < len ? slen : (len - 1); - memcpy(dst, src, ncpy); - dst[ncpy] = '\0'; - } - - assert(len > slen); - return slen; -} - -size_t -strlcpy(char *dst, const char *src, size_t len) -{ - return strlncpy(dst, len, src, (size_t) -1); -} - -int -request_url_cb (http_parser *p, const char *buf, size_t len) -{ - assert(p == parser); - strlncat(messages[num_messages].request_url, - sizeof(messages[num_messages].request_url), - buf, - len); - return 0; -} - -int -header_field_cb (http_parser *p, const char *buf, size_t len) -{ - assert(p == parser); - struct message *m = &messages[num_messages]; - - if (m->last_header_element != FIELD) - m->num_headers++; - - strlncat(m->headers[m->num_headers-1][0], - sizeof(m->headers[m->num_headers-1][0]), - buf, - len); - - m->last_header_element = FIELD; - - return 0; -} - -int -header_value_cb (http_parser *p, const char *buf, size_t len) -{ - assert(p == parser); - struct message *m = &messages[num_messages]; - - strlncat(m->headers[m->num_headers-1][1], - sizeof(m->headers[m->num_headers-1][1]), - buf, - len); - - m->last_header_element = VALUE; - - return 0; -} - -void -check_body_is_final (const http_parser *p) -{ - if (messages[num_messages].body_is_final) { - fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 " - "on last on_body callback call " - "but it doesn't! ***\n\n"); - assert(0); - abort(); - } - messages[num_messages].body_is_final = http_body_is_final(p); -} - -int -body_cb (http_parser *p, const char *buf, size_t len) -{ - assert(p == parser); - strlncat(messages[num_messages].body, - sizeof(messages[num_messages].body), - buf, - len); - messages[num_messages].body_size += len; - check_body_is_final(p); - // printf("body_cb: '%s'\n", requests[num_messages].body); - return 0; -} - -int -count_body_cb (http_parser *p, const char *buf, size_t len) -{ - assert(p == parser); - assert(buf); - messages[num_messages].body_size += len; - check_body_is_final(p); - return 0; -} - -int -message_begin_cb (http_parser *p) -{ - assert(p == parser); - messages[num_messages].message_begin_cb_called = TRUE; - return 0; -} - -int -headers_complete_cb (http_parser *p) -{ - assert(p == parser); - messages[num_messages].method = parser->method; - messages[num_messages].status_code = parser->status_code; - messages[num_messages].http_major = parser->http_major; - messages[num_messages].http_minor = parser->http_minor; - messages[num_messages].headers_complete_cb_called = TRUE; - messages[num_messages].should_keep_alive = http_should_keep_alive(parser); - return 0; -} - -int -message_complete_cb (http_parser *p) -{ - assert(p == parser); - if (messages[num_messages].should_keep_alive != http_should_keep_alive(parser)) - { - fprintf(stderr, "\n\n *** Error http_should_keep_alive() should have same " - "value in both on_message_complete and on_headers_complete " - "but it doesn't! ***\n\n"); - assert(0); - abort(); - } - - if (messages[num_messages].body_size && - http_body_is_final(p) && - !messages[num_messages].body_is_final) - { - fprintf(stderr, "\n\n *** Error http_body_is_final() should return 1 " - "on last on_body callback call " - "but it doesn't! ***\n\n"); - assert(0); - abort(); - } - - messages[num_messages].message_complete_cb_called = TRUE; - - messages[num_messages].message_complete_on_eof = currently_parsing_eof; - - num_messages++; - return 0; -} - -int -response_status_cb (http_parser *p, const char *buf, size_t len) -{ - assert(p == parser); - strlncat(messages[num_messages].response_status, - sizeof(messages[num_messages].response_status), - buf, - len); - return 0; -} - -int -chunk_header_cb (http_parser *p) -{ - assert(p == parser); - int chunk_idx = messages[num_messages].num_chunks; - messages[num_messages].num_chunks++; - if (chunk_idx < MAX_CHUNKS) { - messages[num_messages].chunk_lengths[chunk_idx] = p->content_length; - } - - return 0; -} - -int -chunk_complete_cb (http_parser *p) -{ - assert(p == parser); - - /* Here we want to verify that each chunk_header_cb is matched by a - * chunk_complete_cb, so not only should the total number of calls to - * both callbacks be the same, but they also should be interleaved - * properly */ - assert(messages[num_messages].num_chunks == - messages[num_messages].num_chunks_complete + 1); - - messages[num_messages].num_chunks_complete++; - return 0; -} - -/* These dontcall_* callbacks exist so that we can verify that when we're - * paused, no additional callbacks are invoked */ -int -dontcall_message_begin_cb (http_parser *p) -{ - if (p) { } // gcc - fprintf(stderr, "\n\n*** on_message_begin() called on paused parser ***\n\n"); - abort(); -} - -int -dontcall_header_field_cb (http_parser *p, const char *buf, size_t len) -{ - if (p || buf || len) { } // gcc - fprintf(stderr, "\n\n*** on_header_field() called on paused parser ***\n\n"); - abort(); -} - -int -dontcall_header_value_cb (http_parser *p, const char *buf, size_t len) -{ - if (p || buf || len) { } // gcc - fprintf(stderr, "\n\n*** on_header_value() called on paused parser ***\n\n"); - abort(); -} - -int -dontcall_request_url_cb (http_parser *p, const char *buf, size_t len) -{ - if (p || buf || len) { } // gcc - fprintf(stderr, "\n\n*** on_request_url() called on paused parser ***\n\n"); - abort(); -} - -int -dontcall_body_cb (http_parser *p, const char *buf, size_t len) -{ - if (p || buf || len) { } // gcc - fprintf(stderr, "\n\n*** on_body_cb() called on paused parser ***\n\n"); - abort(); -} - -int -dontcall_headers_complete_cb (http_parser *p) -{ - if (p) { } // gcc - fprintf(stderr, "\n\n*** on_headers_complete() called on paused " - "parser ***\n\n"); - abort(); -} - -int -dontcall_message_complete_cb (http_parser *p) -{ - if (p) { } // gcc - fprintf(stderr, "\n\n*** on_message_complete() called on paused " - "parser ***\n\n"); - abort(); -} - -int -dontcall_response_status_cb (http_parser *p, const char *buf, size_t len) -{ - if (p || buf || len) { } // gcc - fprintf(stderr, "\n\n*** on_status() called on paused parser ***\n\n"); - abort(); -} - -int -dontcall_chunk_header_cb (http_parser *p) -{ - if (p) { } // gcc - fprintf(stderr, "\n\n*** on_chunk_header() called on paused parser ***\n\n"); - exit(1); -} - -int -dontcall_chunk_complete_cb (http_parser *p) -{ - if (p) { } // gcc - fprintf(stderr, "\n\n*** on_chunk_complete() " - "called on paused parser ***\n\n"); - exit(1); -} - -static http_parser_settings settings_dontcall = - {.on_message_begin = dontcall_message_begin_cb - ,.on_header_field = dontcall_header_field_cb - ,.on_header_value = dontcall_header_value_cb - ,.on_url = dontcall_request_url_cb - ,.on_status = dontcall_response_status_cb - ,.on_body = dontcall_body_cb - ,.on_headers_complete = dontcall_headers_complete_cb - ,.on_message_complete = dontcall_message_complete_cb - ,.on_chunk_header = dontcall_chunk_header_cb - ,.on_chunk_complete = dontcall_chunk_complete_cb - }; - -/* These pause_* callbacks always pause the parser and just invoke the regular - * callback that tracks content. Before returning, we overwrite the parser - * settings to point to the _dontcall variety so that we can verify that - * the pause actually did, you know, pause. */ -int -pause_message_begin_cb (http_parser *p) -{ - http_parser_pause(p, 1); - *current_pause_parser = settings_dontcall; - return message_begin_cb(p); -} - -int -pause_header_field_cb (http_parser *p, const char *buf, size_t len) -{ - http_parser_pause(p, 1); - *current_pause_parser = settings_dontcall; - return header_field_cb(p, buf, len); -} - -int -pause_header_value_cb (http_parser *p, const char *buf, size_t len) -{ - http_parser_pause(p, 1); - *current_pause_parser = settings_dontcall; - return header_value_cb(p, buf, len); -} - -int -pause_request_url_cb (http_parser *p, const char *buf, size_t len) -{ - http_parser_pause(p, 1); - *current_pause_parser = settings_dontcall; - return request_url_cb(p, buf, len); -} - -int -pause_body_cb (http_parser *p, const char *buf, size_t len) -{ - http_parser_pause(p, 1); - *current_pause_parser = settings_dontcall; - return body_cb(p, buf, len); -} - -int -pause_headers_complete_cb (http_parser *p) -{ - http_parser_pause(p, 1); - *current_pause_parser = settings_dontcall; - return headers_complete_cb(p); -} - -int -pause_message_complete_cb (http_parser *p) -{ - http_parser_pause(p, 1); - *current_pause_parser = settings_dontcall; - return message_complete_cb(p); -} - -int -pause_response_status_cb (http_parser *p, const char *buf, size_t len) -{ - http_parser_pause(p, 1); - *current_pause_parser = settings_dontcall; - return response_status_cb(p, buf, len); -} - -int -pause_chunk_header_cb (http_parser *p) -{ - http_parser_pause(p, 1); - *current_pause_parser = settings_dontcall; - return chunk_header_cb(p); -} - -int -pause_chunk_complete_cb (http_parser *p) -{ - http_parser_pause(p, 1); - *current_pause_parser = settings_dontcall; - return chunk_complete_cb(p); -} - -static http_parser_settings settings_pause = - {.on_message_begin = pause_message_begin_cb - ,.on_header_field = pause_header_field_cb - ,.on_header_value = pause_header_value_cb - ,.on_url = pause_request_url_cb - ,.on_status = pause_response_status_cb - ,.on_body = pause_body_cb - ,.on_headers_complete = pause_headers_complete_cb - ,.on_message_complete = pause_message_complete_cb - ,.on_chunk_header = pause_chunk_header_cb - ,.on_chunk_complete = pause_chunk_complete_cb - }; - -static http_parser_settings settings = - {.on_message_begin = message_begin_cb - ,.on_header_field = header_field_cb - ,.on_header_value = header_value_cb - ,.on_url = request_url_cb - ,.on_status = response_status_cb - ,.on_body = body_cb - ,.on_headers_complete = headers_complete_cb - ,.on_message_complete = message_complete_cb - ,.on_chunk_header = chunk_header_cb - ,.on_chunk_complete = chunk_complete_cb - }; - -static http_parser_settings settings_count_body = - {.on_message_begin = message_begin_cb - ,.on_header_field = header_field_cb - ,.on_header_value = header_value_cb - ,.on_url = request_url_cb - ,.on_status = response_status_cb - ,.on_body = count_body_cb - ,.on_headers_complete = headers_complete_cb - ,.on_message_complete = message_complete_cb - ,.on_chunk_header = chunk_header_cb - ,.on_chunk_complete = chunk_complete_cb - }; - -static http_parser_settings settings_null = - {.on_message_begin = 0 - ,.on_header_field = 0 - ,.on_header_value = 0 - ,.on_url = 0 - ,.on_status = 0 - ,.on_body = 0 - ,.on_headers_complete = 0 - ,.on_message_complete = 0 - ,.on_chunk_header = 0 - ,.on_chunk_complete = 0 - }; - -void -parser_init (enum http_parser_type type) -{ - num_messages = 0; - - assert(parser == NULL); - - parser = malloc(sizeof(http_parser)); - - http_parser_init(parser, type); - - memset(&messages, 0, sizeof messages); - -} - -void -parser_free () -{ - assert(parser); - free(parser); - parser = NULL; -} - -size_t parse (const char *buf, size_t len) -{ - size_t nparsed; - currently_parsing_eof = (len == 0); - nparsed = http_parser_execute(parser, &settings, buf, len); - return nparsed; -} - -size_t parse_count_body (const char *buf, size_t len) -{ - size_t nparsed; - currently_parsing_eof = (len == 0); - nparsed = http_parser_execute(parser, &settings_count_body, buf, len); - return nparsed; -} - -size_t parse_pause (const char *buf, size_t len) -{ - size_t nparsed; - http_parser_settings s = settings_pause; - - currently_parsing_eof = (len == 0); - current_pause_parser = &s; - nparsed = http_parser_execute(parser, current_pause_parser, buf, len); - return nparsed; -} - -static inline int -check_str_eq (const struct message *m, - const char *prop, - const char *expected, - const char *found) { - if ((expected == NULL) != (found == NULL)) { - printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); - printf("expected %s\n", (expected == NULL) ? "NULL" : expected); - printf(" found %s\n", (found == NULL) ? "NULL" : found); - return 0; - } - if (expected != NULL && 0 != strcmp(expected, found)) { - printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); - printf("expected '%s'\n", expected); - printf(" found '%s'\n", found); - return 0; - } - return 1; -} - -static inline int -check_num_eq (const struct message *m, - const char *prop, - int expected, - int found) { - if (expected != found) { - printf("\n*** Error: %s in '%s' ***\n\n", prop, m->name); - printf("expected %d\n", expected); - printf(" found %d\n", found); - return 0; - } - return 1; -} - -#define MESSAGE_CHECK_STR_EQ(expected, found, prop) \ - if (!check_str_eq(expected, #prop, expected->prop, found->prop)) return 0 - -#define MESSAGE_CHECK_NUM_EQ(expected, found, prop) \ - if (!check_num_eq(expected, #prop, expected->prop, found->prop)) return 0 - -#define MESSAGE_CHECK_URL_EQ(u, expected, found, prop, fn) \ -do { \ - char ubuf[256]; \ - \ - if ((u)->field_set & (1 << (fn))) { \ - memcpy(ubuf, (found)->request_url + (u)->field_data[(fn)].off, \ - (u)->field_data[(fn)].len); \ - ubuf[(u)->field_data[(fn)].len] = '\0'; \ - } else { \ - ubuf[0] = '\0'; \ - } \ - \ - check_str_eq(expected, #prop, expected->prop, ubuf); \ -} while(0) - -int -message_eq (int index, const struct message *expected) -{ - int i; - struct message *m = &messages[index]; - - MESSAGE_CHECK_NUM_EQ(expected, m, http_major); - MESSAGE_CHECK_NUM_EQ(expected, m, http_minor); - - if (expected->type == HTTP_REQUEST) { - MESSAGE_CHECK_NUM_EQ(expected, m, method); - } else { - MESSAGE_CHECK_NUM_EQ(expected, m, status_code); - MESSAGE_CHECK_STR_EQ(expected, m, response_status); - } - - MESSAGE_CHECK_NUM_EQ(expected, m, should_keep_alive); - MESSAGE_CHECK_NUM_EQ(expected, m, message_complete_on_eof); - - assert(m->message_begin_cb_called); - assert(m->headers_complete_cb_called); - assert(m->message_complete_cb_called); - - - MESSAGE_CHECK_STR_EQ(expected, m, request_url); - - /* Check URL components; we can't do this w/ CONNECT since it doesn't - * send us a well-formed URL. - */ - if (*m->request_url && m->method != HTTP_CONNECT) { - struct http_parser_url u; - - if (http_parser_parse_url(m->request_url, strlen(m->request_url), 0, &u)) { - fprintf(stderr, "\n\n*** failed to parse URL %s ***\n\n", - m->request_url); - abort(); - } - - if (expected->host) { - MESSAGE_CHECK_URL_EQ(&u, expected, m, host, UF_HOST); - } - - if (expected->userinfo) { - MESSAGE_CHECK_URL_EQ(&u, expected, m, userinfo, UF_USERINFO); - } - - m->port = (u.field_set & (1 << UF_PORT)) ? - u.port : 0; - - MESSAGE_CHECK_URL_EQ(&u, expected, m, query_string, UF_QUERY); - MESSAGE_CHECK_URL_EQ(&u, expected, m, fragment, UF_FRAGMENT); - MESSAGE_CHECK_URL_EQ(&u, expected, m, request_path, UF_PATH); - MESSAGE_CHECK_NUM_EQ(expected, m, port); - } - - if (expected->body_size) { - MESSAGE_CHECK_NUM_EQ(expected, m, body_size); - } else { - MESSAGE_CHECK_STR_EQ(expected, m, body); - } - - assert(m->num_chunks == m->num_chunks_complete); - MESSAGE_CHECK_NUM_EQ(expected, m, num_chunks_complete); - for (i = 0; i < m->num_chunks && i < MAX_CHUNKS; i++) { - MESSAGE_CHECK_NUM_EQ(expected, m, chunk_lengths[i]); - } - - MESSAGE_CHECK_NUM_EQ(expected, m, num_headers); - - int r; - for (i = 0; i < m->num_headers; i++) { - r = check_str_eq(expected, "header field", expected->headers[i][0], m->headers[i][0]); - if (!r) return 0; - r = check_str_eq(expected, "header value", expected->headers[i][1], m->headers[i][1]); - if (!r) return 0; - } - - MESSAGE_CHECK_STR_EQ(expected, m, upgrade); - - return 1; -} - -/* Given a sequence of varargs messages, return the number of them that the - * parser should successfully parse, taking into account that upgraded - * messages prevent all subsequent messages from being parsed. - */ -size_t -count_parsed_messages(const size_t nmsgs, ...) { - size_t i; - va_list ap; - - va_start(ap, nmsgs); - - for (i = 0; i < nmsgs; i++) { - struct message *m = va_arg(ap, struct message *); - - if (m->upgrade) { - va_end(ap); - return i + 1; - } - } - - va_end(ap); - return nmsgs; -} - -/* Given a sequence of bytes and the number of these that we were able to - * parse, verify that upgrade bodies are correct. - */ -void -upgrade_message_fix(char *body, const size_t nread, const size_t nmsgs, ...) { - va_list ap; - size_t i; - size_t off = 0; - - va_start(ap, nmsgs); - - for (i = 0; i < nmsgs; i++) { - struct message *m = va_arg(ap, struct message *); - - off += strlen(m->raw); - - if (m->upgrade) { - off -= strlen(m->upgrade); - - /* Check the portion of the response after its specified upgrade */ - if (!check_str_eq(m, "upgrade", body + off, body + nread)) { - abort(); - } - - /* Fix up the response so that message_eq() will verify the beginning - * of the upgrade */ - *(body + nread + strlen(m->upgrade)) = '\0'; - messages[num_messages -1 ].upgrade = body + nread; - - va_end(ap); - return; - } - } - - va_end(ap); - printf("\n\n*** Error: expected a message with upgrade ***\n"); - - abort(); -} - -static void -print_error (const char *raw, size_t error_location) -{ - fprintf(stderr, "\n*** %s ***\n\n", - http_errno_description(HTTP_PARSER_ERRNO(parser))); - - int this_line = 0, char_len = 0; - size_t i, j, len = strlen(raw), error_location_line = 0; - for (i = 0; i < len; i++) { - if (i == error_location) this_line = 1; - switch (raw[i]) { - case '\r': - char_len = 2; - fprintf(stderr, "\\r"); - break; - - case '\n': - fprintf(stderr, "\\n\n"); - - if (this_line) goto print; - - error_location_line = 0; - continue; - - default: - char_len = 1; - fputc(raw[i], stderr); - break; - } - if (!this_line) error_location_line += char_len; - } - - fprintf(stderr, "[eof]\n"); - - print: - for (j = 0; j < error_location_line; j++) { - fputc(' ', stderr); - } - fprintf(stderr, "^\n\nerror location: %u\n", (unsigned int)error_location); -} - -void -test_preserve_data (void) -{ - char my_data[] = "application-specific data"; - http_parser parser; - parser.data = my_data; - http_parser_init(&parser, HTTP_REQUEST); - if (parser.data != my_data) { - printf("\n*** parser.data not preserved accross http_parser_init ***\n\n"); - abort(); - } -} - -struct url_test { - const char *name; - const char *url; - int is_connect; - struct http_parser_url u; - int rv; -}; - -const struct url_test url_tests[] = -{ {.name="proxy request" - ,.url="http://hostname/" - ,.is_connect=0 - ,.u= - {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) - ,.port=0 - ,.field_data= - {{ 0, 4 } /* UF_SCHEMA */ - ,{ 7, 8 } /* UF_HOST */ - ,{ 0, 0 } /* UF_PORT */ - ,{ 15, 1 } /* UF_PATH */ - ,{ 0, 0 } /* UF_QUERY */ - ,{ 0, 0 } /* UF_FRAGMENT */ - ,{ 0, 0 } /* UF_USERINFO */ - } - } - ,.rv=0 - } - -, {.name="proxy request with port" - ,.url="http://hostname:444/" - ,.is_connect=0 - ,.u= - {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH) - ,.port=444 - ,.field_data= - {{ 0, 4 } /* UF_SCHEMA */ - ,{ 7, 8 } /* UF_HOST */ - ,{ 16, 3 } /* UF_PORT */ - ,{ 19, 1 } /* UF_PATH */ - ,{ 0, 0 } /* UF_QUERY */ - ,{ 0, 0 } /* UF_FRAGMENT */ - ,{ 0, 0 } /* UF_USERINFO */ - } - } - ,.rv=0 - } - -, {.name="CONNECT request" - ,.url="hostname:443" - ,.is_connect=1 - ,.u= - {.field_set=(1 << UF_HOST) | (1 << UF_PORT) - ,.port=443 - ,.field_data= - {{ 0, 0 } /* UF_SCHEMA */ - ,{ 0, 8 } /* UF_HOST */ - ,{ 9, 3 } /* UF_PORT */ - ,{ 0, 0 } /* UF_PATH */ - ,{ 0, 0 } /* UF_QUERY */ - ,{ 0, 0 } /* UF_FRAGMENT */ - ,{ 0, 0 } /* UF_USERINFO */ - } - } - ,.rv=0 - } - -, {.name="CONNECT request but not connect" - ,.url="hostname:443" - ,.is_connect=0 - ,.rv=1 - } - -, {.name="proxy ipv6 request" - ,.url="http://[1:2::3:4]/" - ,.is_connect=0 - ,.u= - {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) - ,.port=0 - ,.field_data= - {{ 0, 4 } /* UF_SCHEMA */ - ,{ 8, 8 } /* UF_HOST */ - ,{ 0, 0 } /* UF_PORT */ - ,{ 17, 1 } /* UF_PATH */ - ,{ 0, 0 } /* UF_QUERY */ - ,{ 0, 0 } /* UF_FRAGMENT */ - ,{ 0, 0 } /* UF_USERINFO */ - } - } - ,.rv=0 - } - -, {.name="proxy ipv6 request with port" - ,.url="http://[1:2::3:4]:67/" - ,.is_connect=0 - ,.u= - {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PORT) | (1 << UF_PATH) - ,.port=67 - ,.field_data= - {{ 0, 4 } /* UF_SCHEMA */ - ,{ 8, 8 } /* UF_HOST */ - ,{ 18, 2 } /* UF_PORT */ - ,{ 20, 1 } /* UF_PATH */ - ,{ 0, 0 } /* UF_QUERY */ - ,{ 0, 0 } /* UF_FRAGMENT */ - ,{ 0, 0 } /* UF_USERINFO */ - } - } - ,.rv=0 - } - -, {.name="CONNECT ipv6 address" - ,.url="[1:2::3:4]:443" - ,.is_connect=1 - ,.u= - {.field_set=(1 << UF_HOST) | (1 << UF_PORT) - ,.port=443 - ,.field_data= - {{ 0, 0 } /* UF_SCHEMA */ - ,{ 1, 8 } /* UF_HOST */ - ,{ 11, 3 } /* UF_PORT */ - ,{ 0, 0 } /* UF_PATH */ - ,{ 0, 0 } /* UF_QUERY */ - ,{ 0, 0 } /* UF_FRAGMENT */ - ,{ 0, 0 } /* UF_USERINFO */ - } - } - ,.rv=0 - } - -, {.name="ipv4 in ipv6 address" - ,.url="http://[2001:0000:0000:0000:0000:0000:1.9.1.1]/" - ,.is_connect=0 - ,.u= - {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) - ,.port=0 - ,.field_data= - {{ 0, 4 } /* UF_SCHEMA */ - ,{ 8, 37 } /* UF_HOST */ - ,{ 0, 0 } /* UF_PORT */ - ,{ 46, 1 } /* UF_PATH */ - ,{ 0, 0 } /* UF_QUERY */ - ,{ 0, 0 } /* UF_FRAGMENT */ - ,{ 0, 0 } /* UF_USERINFO */ - } - } - ,.rv=0 - } - -, {.name="extra ? in query string" - ,.url="http://a.tbcdn.cn/p/fp/2010c/??fp-header-min.css,fp-base-min.css," - "fp-channel-min.css,fp-product-min.css,fp-mall-min.css,fp-category-min.css," - "fp-sub-min.css,fp-gdp4p-min.css,fp-css3-min.css,fp-misc-min.css?t=20101022.css" - ,.is_connect=0 - ,.u= - {.field_set=(1<field_set, u->port); - for (i = 0; i < UF_MAX; i++) { - if ((u->field_set & (1 << i)) == 0) { - printf("\tfield_data[%u]: unset\n", i); - continue; - } - - printf("\tfield_data[%u]: off: %u len: %u part: \"%.*s\n\"", - i, - u->field_data[i].off, - u->field_data[i].len, - u->field_data[i].len, - url + u->field_data[i].off); - } -} - -void -test_parse_url (void) -{ - struct http_parser_url u; - const struct url_test *test; - unsigned int i; - int rv; - - for (i = 0; i < (sizeof(url_tests) / sizeof(url_tests[0])); i++) { - test = &url_tests[i]; - memset(&u, 0, sizeof(u)); - - rv = http_parser_parse_url(test->url, - strlen(test->url), - test->is_connect, - &u); - - if (test->rv == 0) { - if (rv != 0) { - printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " - "unexpected rv %d ***\n\n", test->url, test->name, rv); - abort(); - } - - if (memcmp(&u, &test->u, sizeof(u)) != 0) { - printf("\n*** http_parser_parse_url(\"%s\") \"%s\" failed ***\n", - test->url, test->name); - - printf("target http_parser_url:\n"); - dump_url(test->url, &test->u); - printf("result http_parser_url:\n"); - dump_url(test->url, &u); - - abort(); - } - } else { - /* test->rv != 0 */ - if (rv == 0) { - printf("\n*** http_parser_parse_url(\"%s\") \"%s\" test failed, " - "unexpected rv %d ***\n\n", test->url, test->name, rv); - abort(); - } - } - } -} - -void -test_method_str (void) -{ - assert(0 == strcmp("GET", http_method_str(HTTP_GET))); - assert(0 == strcmp("", http_method_str(1337))); -} - -void -test_message (const struct message *message) -{ - size_t raw_len = strlen(message->raw); - size_t msg1len; - for (msg1len = 0; msg1len < raw_len; msg1len++) { - parser_init(message->type); - - size_t read; - const char *msg1 = message->raw; - const char *msg2 = msg1 + msg1len; - size_t msg2len = raw_len - msg1len; - - if (msg1len) { - read = parse(msg1, msg1len); - - if (message->upgrade && parser->upgrade && num_messages > 0) { - messages[num_messages - 1].upgrade = msg1 + read; - goto test; - } - - if (read != msg1len) { - print_error(msg1, read); - abort(); - } - } - - - read = parse(msg2, msg2len); - - if (message->upgrade && parser->upgrade) { - messages[num_messages - 1].upgrade = msg2 + read; - goto test; - } - - if (read != msg2len) { - print_error(msg2, read); - abort(); - } - - read = parse(NULL, 0); - - if (read != 0) { - print_error(message->raw, read); - abort(); - } - - test: - - if (num_messages != 1) { - printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name); - abort(); - } - - if(!message_eq(0, message)) abort(); - - parser_free(); - } -} - -void -test_message_count_body (const struct message *message) -{ - parser_init(message->type); - - size_t read; - size_t l = strlen(message->raw); - size_t i, toread; - size_t chunk = 4024; - - for (i = 0; i < l; i+= chunk) { - toread = MIN(l-i, chunk); - read = parse_count_body(message->raw + i, toread); - if (read != toread) { - print_error(message->raw, read); - abort(); - } - } - - - read = parse_count_body(NULL, 0); - if (read != 0) { - print_error(message->raw, read); - abort(); - } - - if (num_messages != 1) { - printf("\n*** num_messages != 1 after testing '%s' ***\n\n", message->name); - abort(); - } - - if(!message_eq(0, message)) abort(); - - parser_free(); -} - -void -test_simple (const char *buf, enum http_errno err_expected) -{ - parser_init(HTTP_REQUEST); - - enum http_errno err; - - parse(buf, strlen(buf)); - err = HTTP_PARSER_ERRNO(parser); - parse(NULL, 0); - - parser_free(); - - /* In strict mode, allow us to pass with an unexpected HPE_STRICT as - * long as the caller isn't expecting success. - */ -#if HTTP_PARSER_STRICT - if (err_expected != err && err_expected != HPE_OK && err != HPE_STRICT) { -#else - if (err_expected != err) { -#endif - fprintf(stderr, "\n*** test_simple expected %s, but saw %s ***\n\n%s\n", - http_errno_name(err_expected), http_errno_name(err), buf); - abort(); - } -} - -void -test_invalid_header_content (int req, const char* str) -{ - http_parser parser; - http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); - size_t parsed; - const char *buf; - buf = req ? - "GET / HTTP/1.1\r\n" : - "HTTP/1.1 200 OK\r\n"; - parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); - assert(parsed == strlen(buf)); - - buf = str; - size_t buflen = strlen(buf); - - parsed = http_parser_execute(&parser, &settings_null, buf, buflen); - if (parsed != buflen) { - assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_HEADER_TOKEN); - return; - } - - fprintf(stderr, - "\n*** Error expected but none in invalid header content test ***\n"); - abort(); -} - -void -test_invalid_header_field_content_error (int req) -{ - test_invalid_header_content(req, "Foo: F\01ailure"); - test_invalid_header_content(req, "Foo: B\02ar"); -} - -void -test_invalid_header_field (int req, const char* str) -{ - http_parser parser; - http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); - size_t parsed; - const char *buf; - buf = req ? - "GET / HTTP/1.1\r\n" : - "HTTP/1.1 200 OK\r\n"; - parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); - assert(parsed == strlen(buf)); - - buf = str; - size_t buflen = strlen(buf); - - parsed = http_parser_execute(&parser, &settings_null, buf, buflen); - if (parsed != buflen) { - assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_HEADER_TOKEN); - return; - } - - fprintf(stderr, - "\n*** Error expected but none in invalid header token test ***\n"); - abort(); -} - -void -test_invalid_header_field_token_error (int req) -{ - test_invalid_header_field(req, "Fo@: Failure"); - test_invalid_header_field(req, "Foo\01\test: Bar"); -} - -void -test_double_content_length_error (int req) -{ - http_parser parser; - http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); - size_t parsed; - const char *buf; - buf = req ? - "GET / HTTP/1.1\r\n" : - "HTTP/1.1 200 OK\r\n"; - parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); - assert(parsed == strlen(buf)); - - buf = "Content-Length: 0\r\nContent-Length: 1\r\n\r\n"; - size_t buflen = strlen(buf); - - parsed = http_parser_execute(&parser, &settings_null, buf, buflen); - if (parsed != buflen) { - assert(HTTP_PARSER_ERRNO(&parser) == HPE_UNEXPECTED_CONTENT_LENGTH); - return; - } - - fprintf(stderr, - "\n*** Error expected but none in double content-length test ***\n"); - abort(); -} - -void -test_chunked_content_length_error (int req) -{ - http_parser parser; - http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); - size_t parsed; - const char *buf; - buf = req ? - "GET / HTTP/1.1\r\n" : - "HTTP/1.1 200 OK\r\n"; - parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); - assert(parsed == strlen(buf)); - - buf = "Transfer-Encoding: chunked\r\nContent-Length: 1\r\n\r\n"; - size_t buflen = strlen(buf); - - parsed = http_parser_execute(&parser, &settings_null, buf, buflen); - if (parsed != buflen) { - assert(HTTP_PARSER_ERRNO(&parser) == HPE_UNEXPECTED_CONTENT_LENGTH); - return; - } - - fprintf(stderr, - "\n*** Error expected but none in chunked content-length test ***\n"); - abort(); -} - -void -test_header_cr_no_lf_error (int req) -{ - http_parser parser; - http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); - size_t parsed; - const char *buf; - buf = req ? - "GET / HTTP/1.1\r\n" : - "HTTP/1.1 200 OK\r\n"; - parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); - assert(parsed == strlen(buf)); - - buf = "Foo: 1\rBar: 1\r\n\r\n"; - size_t buflen = strlen(buf); - - parsed = http_parser_execute(&parser, &settings_null, buf, buflen); - if (parsed != buflen) { - assert(HTTP_PARSER_ERRNO(&parser) == HPE_LF_EXPECTED); - return; - } - - fprintf(stderr, - "\n*** Error expected but none in header whitespace test ***\n"); - abort(); -} - -void -test_header_overflow_error (int req) -{ - http_parser parser; - http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); - size_t parsed; - const char *buf; - buf = req ? "GET / HTTP/1.1\r\n" : "HTTP/1.0 200 OK\r\n"; - parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); - assert(parsed == strlen(buf)); - - buf = "header-key: header-value\r\n"; - size_t buflen = strlen(buf); - - int i; - for (i = 0; i < 10000; i++) { - parsed = http_parser_execute(&parser, &settings_null, buf, buflen); - if (parsed != buflen) { - //fprintf(stderr, "error found on iter %d\n", i); - assert(HTTP_PARSER_ERRNO(&parser) == HPE_HEADER_OVERFLOW); - return; - } - } - - fprintf(stderr, "\n*** Error expected but none in header overflow test ***\n"); - abort(); -} - - -void -test_header_nread_value () -{ - http_parser parser; - http_parser_init(&parser, HTTP_REQUEST); - size_t parsed; - const char *buf; - buf = "GET / HTTP/1.1\r\nheader: value\nhdr: value\r\n"; - parsed = http_parser_execute(&parser, &settings_null, buf, strlen(buf)); - assert(parsed == strlen(buf)); - - assert(parser.nread == strlen(buf)); -} - - -static void -test_content_length_overflow (const char *buf, size_t buflen, int expect_ok) -{ - http_parser parser; - http_parser_init(&parser, HTTP_RESPONSE); - http_parser_execute(&parser, &settings_null, buf, buflen); - - if (expect_ok) - assert(HTTP_PARSER_ERRNO(&parser) == HPE_OK); - else - assert(HTTP_PARSER_ERRNO(&parser) == HPE_INVALID_CONTENT_LENGTH); -} - -void -test_header_content_length_overflow_error (void) -{ -#define X(size) \ - "HTTP/1.1 200 OK\r\n" \ - "Content-Length: " #size "\r\n" \ - "\r\n" - const char a[] = X(1844674407370955160); /* 2^64 / 10 - 1 */ - const char b[] = X(18446744073709551615); /* 2^64-1 */ - const char c[] = X(18446744073709551616); /* 2^64 */ -#undef X - test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */ - test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */ - test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */ -} - -void -test_chunk_content_length_overflow_error (void) -{ -#define X(size) \ - "HTTP/1.1 200 OK\r\n" \ - "Transfer-Encoding: chunked\r\n" \ - "\r\n" \ - #size "\r\n" \ - "..." - const char a[] = X(FFFFFFFFFFFFFFE); /* 2^64 / 16 - 1 */ - const char b[] = X(FFFFFFFFFFFFFFFF); /* 2^64-1 */ - const char c[] = X(10000000000000000); /* 2^64 */ -#undef X - test_content_length_overflow(a, sizeof(a) - 1, 1); /* expect ok */ - test_content_length_overflow(b, sizeof(b) - 1, 0); /* expect failure */ - test_content_length_overflow(c, sizeof(c) - 1, 0); /* expect failure */ -} - -void -test_no_overflow_long_body (int req, size_t length) -{ - http_parser parser; - http_parser_init(&parser, req ? HTTP_REQUEST : HTTP_RESPONSE); - size_t parsed; - size_t i; - char buf1[3000]; - size_t buf1len = sprintf(buf1, "%s\r\nConnection: Keep-Alive\r\nContent-Length: %lu\r\n\r\n", - req ? "POST / HTTP/1.0" : "HTTP/1.0 200 OK", (unsigned long)length); - parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len); - if (parsed != buf1len) - goto err; - - for (i = 0; i < length; i++) { - char foo = 'a'; - parsed = http_parser_execute(&parser, &settings_null, &foo, 1); - if (parsed != 1) - goto err; - } - - parsed = http_parser_execute(&parser, &settings_null, buf1, buf1len); - if (parsed != buf1len) goto err; - return; - - err: - fprintf(stderr, - "\n*** error in test_no_overflow_long_body %s of length %lu ***\n", - req ? "REQUEST" : "RESPONSE", - (unsigned long)length); - abort(); -} - -void -test_multiple3 (const struct message *r1, const struct message *r2, const struct message *r3) -{ - int message_count = count_parsed_messages(3, r1, r2, r3); - - char total[ strlen(r1->raw) - + strlen(r2->raw) - + strlen(r3->raw) - + 1 - ]; - total[0] = '\0'; - - strcat(total, r1->raw); - strcat(total, r2->raw); - strcat(total, r3->raw); - - parser_init(r1->type); - - size_t read; - - read = parse(total, strlen(total)); - - if (parser->upgrade) { - upgrade_message_fix(total, read, 3, r1, r2, r3); - goto test; - } - - if (read != strlen(total)) { - print_error(total, read); - abort(); - } - - read = parse(NULL, 0); - - if (read != 0) { - print_error(total, read); - abort(); - } - -test: - - if (message_count != num_messages) { - fprintf(stderr, "\n\n*** Parser didn't see 3 messages only %d *** \n", num_messages); - abort(); - } - - if (!message_eq(0, r1)) abort(); - if (message_count > 1 && !message_eq(1, r2)) abort(); - if (message_count > 2 && !message_eq(2, r3)) abort(); - - parser_free(); -} - -/* SCAN through every possible breaking to make sure the - * parser can handle getting the content in any chunks that - * might come from the socket - */ -void -test_scan (const struct message *r1, const struct message *r2, const struct message *r3) -{ - char total[80*1024] = "\0"; - char buf1[80*1024] = "\0"; - char buf2[80*1024] = "\0"; - char buf3[80*1024] = "\0"; - - strcat(total, r1->raw); - strcat(total, r2->raw); - strcat(total, r3->raw); - - size_t read; - - int total_len = strlen(total); - - int total_ops = 2 * (total_len - 1) * (total_len - 2) / 2; - int ops = 0 ; - - size_t buf1_len, buf2_len, buf3_len; - int message_count = count_parsed_messages(3, r1, r2, r3); - - int i,j,type_both; - for (type_both = 0; type_both < 2; type_both ++ ) { - for (j = 2; j < total_len; j ++ ) { - for (i = 1; i < j; i ++ ) { - - if (ops % 1000 == 0) { - printf("\b\b\b\b%3.0f%%", 100 * (float)ops /(float)total_ops); - fflush(stdout); - } - ops += 1; - - parser_init(type_both ? HTTP_BOTH : r1->type); - - buf1_len = i; - strlncpy(buf1, sizeof(buf1), total, buf1_len); - buf1[buf1_len] = 0; - - buf2_len = j - i; - strlncpy(buf2, sizeof(buf1), total+i, buf2_len); - buf2[buf2_len] = 0; - - buf3_len = total_len - j; - strlncpy(buf3, sizeof(buf1), total+j, buf3_len); - buf3[buf3_len] = 0; - - read = parse(buf1, buf1_len); - - if (parser->upgrade) goto test; - - if (read != buf1_len) { - print_error(buf1, read); - goto error; - } - - read += parse(buf2, buf2_len); - - if (parser->upgrade) goto test; - - if (read != buf1_len + buf2_len) { - print_error(buf2, read); - goto error; - } - - read += parse(buf3, buf3_len); - - if (parser->upgrade) goto test; - - if (read != buf1_len + buf2_len + buf3_len) { - print_error(buf3, read); - goto error; - } - - parse(NULL, 0); - -test: - if (parser->upgrade) { - upgrade_message_fix(total, read, 3, r1, r2, r3); - } - - if (message_count != num_messages) { - fprintf(stderr, "\n\nParser didn't see %d messages only %d\n", - message_count, num_messages); - goto error; - } - - if (!message_eq(0, r1)) { - fprintf(stderr, "\n\nError matching messages[0] in test_scan.\n"); - goto error; - } - - if (message_count > 1 && !message_eq(1, r2)) { - fprintf(stderr, "\n\nError matching messages[1] in test_scan.\n"); - goto error; - } - - if (message_count > 2 && !message_eq(2, r3)) { - fprintf(stderr, "\n\nError matching messages[2] in test_scan.\n"); - goto error; - } - - parser_free(); - } - } - } - puts("\b\b\b\b100%"); - return; - - error: - fprintf(stderr, "i=%d j=%d\n", i, j); - fprintf(stderr, "buf1 (%u) %s\n\n", (unsigned int)buf1_len, buf1); - fprintf(stderr, "buf2 (%u) %s\n\n", (unsigned int)buf2_len , buf2); - fprintf(stderr, "buf3 (%u) %s\n", (unsigned int)buf3_len, buf3); - abort(); -} - -// user required to free the result -// string terminated by \0 -char * -create_large_chunked_message (int body_size_in_kb, const char* headers) -{ - int i; - size_t wrote = 0; - size_t headers_len = strlen(headers); - size_t bufsize = headers_len + (5+1024+2)*body_size_in_kb + 6; - char * buf = malloc(bufsize); - - memcpy(buf, headers, headers_len); - wrote += headers_len; - - for (i = 0; i < body_size_in_kb; i++) { - // write 1kb chunk into the body. - memcpy(buf + wrote, "400\r\n", 5); - wrote += 5; - memset(buf + wrote, 'C', 1024); - wrote += 1024; - strcpy(buf + wrote, "\r\n"); - wrote += 2; - } - - memcpy(buf + wrote, "0\r\n\r\n", 6); - wrote += 6; - assert(wrote == bufsize); - - return buf; -} - -/* Verify that we can pause parsing at any of the bytes in the - * message and still get the result that we're expecting. */ -void -test_message_pause (const struct message *msg) -{ - char *buf = (char*) msg->raw; - size_t buflen = strlen(msg->raw); - size_t nread; - - parser_init(msg->type); - - do { - nread = parse_pause(buf, buflen); - - // We can only set the upgrade buffer once we've gotten our message - // completion callback. - if (messages[0].message_complete_cb_called && - msg->upgrade && - parser->upgrade) { - messages[0].upgrade = buf + nread; - goto test; - } - - if (nread < buflen) { - - // Not much do to if we failed a strict-mode check - if (HTTP_PARSER_ERRNO(parser) == HPE_STRICT) { - parser_free(); - return; - } - - assert (HTTP_PARSER_ERRNO(parser) == HPE_PAUSED); - } - - buf += nread; - buflen -= nread; - http_parser_pause(parser, 0); - } while (buflen > 0); - - nread = parse_pause(NULL, 0); - assert (nread == 0); - -test: - if (num_messages != 1) { - printf("\n*** num_messages != 1 after testing '%s' ***\n\n", msg->name); - abort(); - } - - if(!message_eq(0, msg)) abort(); - - parser_free(); -} - -int -main (void) -{ - parser = NULL; - int i, j, k; - int request_count; - int response_count; - unsigned long version; - unsigned major; - unsigned minor; - unsigned patch; - - version = http_parser_version(); - major = (version >> 16) & 255; - minor = (version >> 8) & 255; - patch = version & 255; - printf("http_parser v%u.%u.%u (0x%06lx)\n", major, minor, patch, version); - - printf("sizeof(http_parser) = %u\n", (unsigned int)sizeof(http_parser)); - - for (request_count = 0; requests[request_count].name; request_count++); - for (response_count = 0; responses[response_count].name; response_count++); - - //// API - test_preserve_data(); - test_parse_url(); - test_method_str(); - - //// NREAD - test_header_nread_value(); - - //// OVERFLOW CONDITIONS - - test_header_overflow_error(HTTP_REQUEST); - test_no_overflow_long_body(HTTP_REQUEST, 1000); - test_no_overflow_long_body(HTTP_REQUEST, 100000); - - test_header_overflow_error(HTTP_RESPONSE); - test_no_overflow_long_body(HTTP_RESPONSE, 1000); - test_no_overflow_long_body(HTTP_RESPONSE, 100000); - - test_header_content_length_overflow_error(); - test_chunk_content_length_overflow_error(); - - //// HEADER FIELD CONDITIONS - test_double_content_length_error(HTTP_REQUEST); - test_chunked_content_length_error(HTTP_REQUEST); - test_header_cr_no_lf_error(HTTP_REQUEST); - test_invalid_header_field_token_error(HTTP_REQUEST); - test_invalid_header_field_content_error(HTTP_REQUEST); - test_double_content_length_error(HTTP_RESPONSE); - test_chunked_content_length_error(HTTP_RESPONSE); - test_header_cr_no_lf_error(HTTP_RESPONSE); - test_invalid_header_field_token_error(HTTP_RESPONSE); - test_invalid_header_field_content_error(HTTP_RESPONSE); - - //// RESPONSES - - for (i = 0; i < response_count; i++) { - test_message(&responses[i]); - } - - for (i = 0; i < response_count; i++) { - test_message_pause(&responses[i]); - } - - for (i = 0; i < response_count; i++) { - if (!responses[i].should_keep_alive) continue; - for (j = 0; j < response_count; j++) { - if (!responses[j].should_keep_alive) continue; - for (k = 0; k < response_count; k++) { - test_multiple3(&responses[i], &responses[j], &responses[k]); - } - } - } - - test_message_count_body(&responses[NO_HEADERS_NO_BODY_404]); - test_message_count_body(&responses[TRAILING_SPACE_ON_CHUNKED_BODY]); - - // test very large chunked response - { - char * msg = create_large_chunked_message(31337, - "HTTP/1.0 200 OK\r\n" - "Transfer-Encoding: chunked\r\n" - "Content-Type: text/plain\r\n" - "\r\n"); - struct message large_chunked = - {.name= "large chunked" - ,.type= HTTP_RESPONSE - ,.raw= msg - ,.should_keep_alive= FALSE - ,.message_complete_on_eof= FALSE - ,.http_major= 1 - ,.http_minor= 0 - ,.status_code= 200 - ,.response_status= "OK" - ,.num_headers= 2 - ,.headers= - { { "Transfer-Encoding", "chunked" } - , { "Content-Type", "text/plain" } - } - ,.body_size= 31337*1024 - ,.num_chunks_complete= 31338 - }; - for (i = 0; i < MAX_CHUNKS; i++) { - large_chunked.chunk_lengths[i] = 1024; - } - test_message_count_body(&large_chunked); - free(msg); - } - - - - printf("response scan 1/2 "); - test_scan( &responses[TRAILING_SPACE_ON_CHUNKED_BODY] - , &responses[NO_BODY_HTTP10_KA_204] - , &responses[NO_REASON_PHRASE] - ); - - printf("response scan 2/2 "); - test_scan( &responses[BONJOUR_MADAME_FR] - , &responses[UNDERSTORE_HEADER_KEY] - , &responses[NO_CARRIAGE_RET] - ); - - puts("responses okay"); - - - /// REQUESTS - - test_simple("GET / HTP/1.1\r\n\r\n", HPE_INVALID_VERSION); - - // Well-formed but incomplete - test_simple("GET / HTTP/1.1\r\n" - "Content-Type: text/plain\r\n" - "Content-Length: 6\r\n" - "\r\n" - "fooba", - HPE_OK); - - static const char *all_methods[] = { - "DELETE", - "GET", - "HEAD", - "POST", - "PUT", - //"CONNECT", //CONNECT can't be tested like other methods, it's a tunnel - "OPTIONS", - "TRACE", - "COPY", - "LOCK", - "MKCOL", - "MOVE", - "PROPFIND", - "PROPPATCH", - "SEARCH", - "UNLOCK", - "BIND", - "REBIND", - "UNBIND", - "ACL", - "REPORT", - "MKACTIVITY", - "CHECKOUT", - "MERGE", - "M-SEARCH", - "NOTIFY", - "SUBSCRIBE", - "UNSUBSCRIBE", - "PATCH", - "PURGE", - "MKCALENDAR", - "LINK", - "UNLINK", - 0 }; - const char **this_method; - for (this_method = all_methods; *this_method; this_method++) { - char buf[200]; - sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method); - test_simple(buf, HPE_OK); - } - - static const char *bad_methods[] = { - "ASDF", - "C******", - "COLA", - "GEM", - "GETA", - "M****", - "MKCOLA", - "PROPPATCHA", - "PUN", - "PX", - "SA", - "hello world", - 0 }; - for (this_method = bad_methods; *this_method; this_method++) { - char buf[200]; - sprintf(buf, "%s / HTTP/1.1\r\n\r\n", *this_method); - test_simple(buf, HPE_INVALID_METHOD); - } - - // illegal header field name line folding - test_simple("GET / HTTP/1.1\r\n" - "name\r\n" - " : value\r\n" - "\r\n", - HPE_INVALID_HEADER_TOKEN); - - const char *dumbfuck2 = - "GET / HTTP/1.1\r\n" - "X-SSL-Bullshit: -----BEGIN CERTIFICATE-----\r\n" - "\tMIIFbTCCBFWgAwIBAgICH4cwDQYJKoZIhvcNAQEFBQAwcDELMAkGA1UEBhMCVUsx\r\n" - "\tETAPBgNVBAoTCGVTY2llbmNlMRIwEAYDVQQLEwlBdXRob3JpdHkxCzAJBgNVBAMT\r\n" - "\tAkNBMS0wKwYJKoZIhvcNAQkBFh5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMu\r\n" - "\tdWswHhcNMDYwNzI3MTQxMzI4WhcNMDcwNzI3MTQxMzI4WjBbMQswCQYDVQQGEwJV\r\n" - "\tSzERMA8GA1UEChMIZVNjaWVuY2UxEzARBgNVBAsTCk1hbmNoZXN0ZXIxCzAJBgNV\r\n" - "\tBAcTmrsogriqMWLAk1DMRcwFQYDVQQDEw5taWNoYWVsIHBhcmQYJKoZIhvcNAQEB\r\n" - "\tBQADggEPADCCAQoCggEBANPEQBgl1IaKdSS1TbhF3hEXSl72G9J+WC/1R64fAcEF\r\n" - "\tW51rEyFYiIeZGx/BVzwXbeBoNUK41OK65sxGuflMo5gLflbwJtHBRIEKAfVVp3YR\r\n" - "\tgW7cMA/s/XKgL1GEC7rQw8lIZT8RApukCGqOVHSi/F1SiFlPDxuDfmdiNzL31+sL\r\n" - "\t0iwHDdNkGjy5pyBSB8Y79dsSJtCW/iaLB0/n8Sj7HgvvZJ7x0fr+RQjYOUUfrePP\r\n" - "\tu2MSpFyf+9BbC/aXgaZuiCvSR+8Snv3xApQY+fULK/xY8h8Ua51iXoQ5jrgu2SqR\r\n" - "\twgA7BUi3G8LFzMBl8FRCDYGUDy7M6QaHXx1ZWIPWNKsCAwEAAaOCAiQwggIgMAwG\r\n" - "\tA1UdEwEB/wQCMAAwEQYJYIZIAYb4QgHTTPAQDAgWgMA4GA1UdDwEB/wQEAwID6DAs\r\n" - "\tBglghkgBhvhCAQ0EHxYdVUsgZS1TY2llbmNlIFVzZXIgQ2VydGlmaWNhdGUwHQYD\r\n" - "\tVR0OBBYEFDTt/sf9PeMaZDHkUIldrDYMNTBZMIGaBgNVHSMEgZIwgY+AFAI4qxGj\r\n" - "\tloCLDdMVKwiljjDastqooXSkcjBwMQswCQYDVQQGEwJVSzERMA8GA1UEChMIZVNj\r\n" - "\taWVuY2UxEjAQBgNVBAsTCUF1dGhvcml0eTELMAkGA1UEAxMCQ0ExLTArBgkqhkiG\r\n" - "\t9w0BCQEWHmNhLW9wZXJhdG9yQGdyaWQtc3VwcG9ydC5hYy51a4IBADApBgNVHRIE\r\n" - "\tIjAggR5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMudWswGQYDVR0gBBIwEDAO\r\n" - "\tBgwrBgEEAdkvAQEBAQYwPQYJYIZIAYb4QgEEBDAWLmh0dHA6Ly9jYS5ncmlkLXN1\r\n" - "\tcHBvcnQuYWMudmT4sopwqlBWsvcHViL2NybC9jYWNybC5jcmwwPQYJYIZIAYb4QgEDBDAWLmh0\r\n" - "\tdHA6Ly9jYS5ncmlkLXN1cHBvcnQuYWMudWsvcHViL2NybC9jYWNybC5jcmwwPwYD\r\n" - "\tVR0fBDgwNjA0oDKgMIYuaHR0cDovL2NhLmdyaWQt5hYy51ay9wdWIv\r\n" - "\tY3JsL2NhY3JsLmNybDANBgkqhkiG9w0BAQUFAAOCAQEAS/U4iiooBENGW/Hwmmd3\r\n" - "\tXCy6Zrt08YjKCzGNjorT98g8uGsqYjSxv/hmi0qlnlHs+k/3Iobc3LjS5AMYr5L8\r\n" - "\tUO7OSkgFFlLHQyC9JzPfmLCAugvzEbyv4Olnsr8hbxF1MbKZoQxUZtMVu29wjfXk\r\n" - "\thTeApBv7eaKCWpSp7MCbvgzm74izKhu3vlDk9w6qVrxePfGgpKPqfHiOoGhFnbTK\r\n" - "\twTC6o2xq5y0qZ03JonF7OJspEd3I5zKY3E+ov7/ZhW6DqT8UFvsAdjvQbXyhV8Eu\r\n" - "\tYhixw1aKEPzNjNowuIseVogKOLXxWI5vAi5HgXdS0/ES5gDGsABo4fqovUKlgop3\r\n" - "\tRA==\r\n" - "\t-----END CERTIFICATE-----\r\n" - "\r\n"; - test_simple(dumbfuck2, HPE_OK); - - const char *corrupted_connection = - "GET / HTTP/1.1\r\n" - "Host: www.example.com\r\n" - "Connection\r\033\065\325eep-Alive\r\n" - "Accept-Encoding: gzip\r\n" - "\r\n"; - test_simple(corrupted_connection, HPE_INVALID_HEADER_TOKEN); - - const char *corrupted_header_name = - "GET / HTTP/1.1\r\n" - "Host: www.example.com\r\n" - "X-Some-Header\r\033\065\325eep-Alive\r\n" - "Accept-Encoding: gzip\r\n" - "\r\n"; - test_simple(corrupted_header_name, HPE_INVALID_HEADER_TOKEN); - -#if 0 - // NOTE(Wed Nov 18 11:57:27 CET 2009) this seems okay. we just read body - // until EOF. - // - // no content-length - // error if there is a body without content length - const char *bad_get_no_headers_no_body = "GET /bad_get_no_headers_no_body/world HTTP/1.1\r\n" - "Accept: */*\r\n" - "\r\n" - "HELLO"; - test_simple(bad_get_no_headers_no_body, 0); -#endif - /* TODO sending junk and large headers gets rejected */ - - - /* check to make sure our predefined requests are okay */ - for (i = 0; requests[i].name; i++) { - test_message(&requests[i]); - } - - for (i = 0; i < request_count; i++) { - test_message_pause(&requests[i]); - } - - for (i = 0; i < request_count; i++) { - if (!requests[i].should_keep_alive) continue; - for (j = 0; j < request_count; j++) { - if (!requests[j].should_keep_alive) continue; - for (k = 0; k < request_count; k++) { - test_multiple3(&requests[i], &requests[j], &requests[k]); - } - } - } - - printf("request scan 1/4 "); - test_scan( &requests[GET_NO_HEADERS_NO_BODY] - , &requests[GET_ONE_HEADER_NO_BODY] - , &requests[GET_NO_HEADERS_NO_BODY] - ); - - printf("request scan 2/4 "); - test_scan( &requests[POST_CHUNKED_ALL_YOUR_BASE] - , &requests[POST_IDENTITY_BODY_WORLD] - , &requests[GET_FUNKY_CONTENT_LENGTH] - ); - - printf("request scan 3/4 "); - test_scan( &requests[TWO_CHUNKS_MULT_ZERO_END] - , &requests[CHUNKED_W_TRAILING_HEADERS] - , &requests[CHUNKED_W_BULLSHIT_AFTER_LENGTH] - ); - - printf("request scan 4/4 "); - test_scan( &requests[QUERY_URL_WITH_QUESTION_MARK_GET] - , &requests[PREFIX_NEWLINE_GET ] - , &requests[CONNECT_REQUEST] - ); - - puts("requests okay"); - - return 0; -} diff --git a/src/beast/beast/http/parser.h b/src/beast/beast/http/parser.h deleted file mode 100644 index 826803e397..0000000000 --- a/src/beast/beast/http/parser.h +++ /dev/null @@ -1,282 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_PARSER_H_INCLUDED -#define BEAST_HTTP_PARSER_H_INCLUDED - -#include -#include -#include -#include -#include -#include // -#include - -namespace beast { -namespace http { - -/** A HTTP parser. - - The parser may only be used once. -*/ -template -class parser - : public basic_parser> -{ - using message_type = - message; - - message_type m_; - typename message_type::body_type::reader r_; - bool started_ = false; - -public: - parser(parser&&) = default; - - parser() - : http::basic_parser(isRequest) - , r_(m_) - { - } - - /// Returns `true` if at least one byte has been processed - bool - started() - { - return started_; - } - - message_type - release() - { - return std::move(m_); - } - -private: - friend class http::basic_parser; - - void - on_start() - { - started_ = true; - } - - void - on_field(std::string const& field, std::string const& value) - { - m_.headers.insert(field, value); - } - - void - on_headers_complete(error_code&) - { - // vFALCO TODO Decode the Content-Length and - // Transfer-Encoding, see if we can reserve the buffer. - // - // r_.reserve(content_length) - } - - bool - on_request(http::method_t method, std::string const& url, - int major, int minor, bool keep_alive, bool upgrade, - std::true_type) - { - m_.method = method; - m_.url = url; - m_.version = major * 10 + minor; - return true; - } - - bool - on_request(http::method_t, std::string const&, - int, int, bool, bool, - std::false_type) - { - return true; - } - - bool - on_request(http::method_t method, std::string const& url, - int major, int minor, bool keep_alive, bool upgrade) - { - return on_request(method, url, - major, minor, keep_alive, upgrade, - typename message_type::is_request{}); - } - - bool - on_response(int status, std::string const& reason, - int major, int minor, bool keep_alive, bool upgrade, - std::true_type) - { - m_.status = status; - m_.reason = reason; - m_.version = major * 10 + minor; - // VFALCO TODO return expect_body_ - return true; - } - - bool - on_response(int, std::string const&, int, int, bool, bool, - std::false_type) - { - return true; - } - - bool - on_response(int status, std::string const& reason, - int major, int minor, bool keep_alive, bool upgrade) - { - return on_response( - status, reason, major, minor, keep_alive, upgrade, - std::integral_constant{}); - } - - void - on_body(void const* data, - std::size_t size, error_code& ec) - { - r_.write(data, size, ec); - } - - void - on_complete() - { - } -}; - -} // http -} // beast - -//------------------------------------------------------------------------------ - -// -// LEGACY -// - -#include -#include -#include -#include -#include -#include - -namespace beast { -namespace deprecated_http { - -/** Parser for HTTP messages. - The result is stored in a message object. -*/ -class parser - : public beast::http::basic_parser -{ -// friend class basic_parser; - - message& m_; - std::function write_body_; - -public: - parser(parser&&) = default; - parser(parser const&) = delete; - parser& operator=(parser&&) = delete; - parser& operator=(parser const&) = delete; - - /** Construct a parser for HTTP request or response. - The headers plus request or status line are stored in message. - The content-body, if any, is passed as a series of calls to - the write_body function. Transfer encodings are applied before - any data is passed to the write_body function. - */ - parser(std::function write_body, - message& m, bool request) - : basic_parser(request) - , m_(m) - , write_body_(std::move(write_body)) - { - m_.request(request); - } - - parser(message& m, body& b, bool request) - : basic_parser(request) - , m_(m) - { - write_body_ = [&b](void const* data, std::size_t size) - { - b.write(data, size); - }; - m_.request(request); - } - -//private: - void - on_start() - { - } - - void - on_headers_complete(error_code&) - { - } - - bool - on_request(http::method_t method, std::string const& url, - int major, int minor, bool keep_alive, bool upgrade) - { - m_.method(method); - m_.url(url); - m_.version(major, minor); - m_.keep_alive(keep_alive); - m_.upgrade(upgrade); - return true; - } - - bool - on_response(int status, std::string const& text, - int major, int minor, bool keep_alive, bool upgrade) - { - m_.status(status); - m_.reason(text); - m_.version(major, minor); - m_.keep_alive(keep_alive); - m_.upgrade(upgrade); - return true; - } - - void - on_field(std::string const& field, std::string const& value) - { - m_.headers.insert(field, value); - } - - void - on_body(void const* data, std::size_t bytes, error_code&) - { - write_body_(data, bytes); - } - - void - on_complete() - { - } -}; - -} // deprecated_http -} // beast - -#endif diff --git a/src/beast/beast/http/resume_context.h b/src/beast/beast/http/resume_context.h deleted file mode 100644 index 944c712b2f..0000000000 --- a/src/beast/beast/http/resume_context.h +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_RESUME_CONTEXT_H_INCLUDED -#define BEAST_HTTP_RESUME_CONTEXT_H_INCLUDED - -#include - -namespace beast { -namespace http { - -/** A functor that resumes a write operation. - - An rvalue reference to an object of this type is provided by the - write implementation to the `writer` associated with the body of - a message being sent. - - If it is desired that the `writer` suspend the write operation (for - example, to wait until data is ready), it can take ownership of - the resume context using a move. Then, it returns `boost::indeterminate` - to indicate that the write operation should suspend. Later, the calling - code invokes the resume function and the write operation continues - from where it left off. -*/ -using resume_context = std::function; - -} // http -} // beast - -#endif diff --git a/src/beast/beast/http/src/beast_http_nodejs_parser.cpp b/src/beast/beast/http/src/beast_http_nodejs_parser.cpp deleted file mode 100644 index cd0620f971..0000000000 --- a/src/beast/beast/http/src/beast_http_nodejs_parser.cpp +++ /dev/null @@ -1,90 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include - -#ifdef _MSC_VER -# pragma warning (push) -# pragma warning (disable: 4127) // conditional expression is constant -# pragma warning (disable: 4244) // integer conversion, possible loss of data -#endif -#include -#ifdef _MSC_VER -# pragma warning (pop) -#endif - -beast::http::method_t -convert_http_method(http_method m) -{ - using namespace beast; - switch (m) - { - case HTTP_DELETE: return http::method_t::http_delete; - case HTTP_GET: return http::method_t::http_get; - case HTTP_HEAD: return http::method_t::http_head; - case HTTP_POST: return http::method_t::http_post; - case HTTP_PUT: return http::method_t::http_put; - - // pathological - case HTTP_CONNECT: return http::method_t::http_connect; - case HTTP_OPTIONS: return http::method_t::http_options; - case HTTP_TRACE: return http::method_t::http_trace; - - // webdav - case HTTP_COPY: return http::method_t::http_copy; - case HTTP_LOCK: return http::method_t::http_lock; - case HTTP_MKCOL: return http::method_t::http_mkcol; - case HTTP_MOVE: return http::method_t::http_move; - case HTTP_PROPFIND: return http::method_t::http_propfind; - case HTTP_PROPPATCH: return http::method_t::http_proppatch; - case HTTP_SEARCH: return http::method_t::http_search; - case HTTP_UNLOCK: return http::method_t::http_unlock; - case HTTP_BIND: return http::method_t::http_bind; - case HTTP_REBIND: return http::method_t::http_rebind; - case HTTP_UNBIND: return http::method_t::http_unbind; - case HTTP_ACL: return http::method_t::http_acl; - - // subversion - case HTTP_REPORT: return http::method_t::http_report; - case HTTP_MKACTIVITY: return http::method_t::http_mkactivity; - case HTTP_CHECKOUT: return http::method_t::http_checkout; - case HTTP_MERGE: return http::method_t::http_merge; - - // upnp - case HTTP_MSEARCH: return http::method_t::http_msearch; - case HTTP_NOTIFY: return http::method_t::http_notify; - case HTTP_SUBSCRIBE: return http::method_t::http_subscribe; - case HTTP_UNSUBSCRIBE: return http::method_t::http_unsubscribe; - - // RFC-5789 - case HTTP_PATCH: return http::method_t::http_patch; - case HTTP_PURGE: return http::method_t::http_purge; - - // CalDav - case HTTP_MKCALENDAR: return http::method_t::http_mkcalendar; - - // RFC-2068, section 19.6.1.2 - case HTTP_LINK: return http::method_t::http_link; - case HTTP_UNLINK: return http::method_t::http_unlink; - }; - - return http::method_t::http_get; -} diff --git a/src/beast/beast/http/src/nodejs_parser.h b/src/beast/beast/http/src/nodejs_parser.h deleted file mode 100644 index ae5ab9ad69..0000000000 --- a/src/beast/beast/http/src/nodejs_parser.h +++ /dev/null @@ -1,45 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_NODEJS_PARSER_H_INCLUDED -#define BEAST_HTTP_NODEJS_PARSER_H_INCLUDED - -#include -#include -#include - -beast::http::method_t -convert_http_method(http_method m); - -namespace boost { -namespace system { -template<> -struct is_error_code_enum - : std::true_type -{ -}; -template<> -struct is_error_condition_enum - : std::true_type -{ -}; -} // system -} // boost - -#endif diff --git a/src/beast/beast/http/src/test/beast_http_parser_test.cpp b/src/beast/beast/http/src/test/beast_http_parser_test.cpp deleted file mode 100644 index a54e50dc11..0000000000 --- a/src/beast/beast/http/src/test/beast_http_parser_test.cpp +++ /dev/null @@ -1,94 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include -#include - -namespace beast { -namespace deprecated_http { -namespace test { - -class parser_test : public beast::unit_test::suite -{ -public: - message - request(std::string const& text) - { - body b; - message m; - parser p(m, b, true); - auto const used = - p.write(boost::asio::buffer(text)); - expect(used == text.size()); - p.write_eof(); - return m; - } - - void - test_headers() - { - beast::http::headers> h; - h.insert("Field", "Value"); - expect (h.erase("Field") == 1); - } - - void - run() - { - test_headers(); - - { - std::string const text = - "GET / HTTP/1.1\r\n" - "\r\n" - ; - body b; - message m; - parser p (m, b, true); - auto const used = p.write( - boost::asio::buffer(text)); - expect(used == text.size()); - p.write_eof(); - expect(p.complete()); - } - - { - // malformed - std::string const text = - "GET\r\n" - "\r\n" - ; - body b; - message m; - parser p(m, b, true); - boost::system::error_code ec; - p.write(boost::asio::buffer(text), ec); - if(expect(ec)) - expect(ec.message() == "invalid HTTP method"); - } - } -}; - -BEAST_DEFINE_TESTSUITE(parser,http,beast); - -} // test -} // deprecated_http -} // beast diff --git a/src/beast/beast/http/type_check.h b/src/beast/beast/http/type_check.h deleted file mode 100644 index 8bde8001b0..0000000000 --- a/src/beast/beast/http/type_check.h +++ /dev/null @@ -1,84 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_TYPE_CHECK_H_INCLUDED -#define BEAST_HTTP_TYPE_CHECK_H_INCLUDED - -#include -#include -#include -#include -#include -#include -#include -#include -#include // - -namespace beast { -namespace http { - -#if GENERATING_DOCS -namespace detail { -#else -namespace concept { -#endif - -struct Reader -{ - template - Reader(message&) noexcept; - void write(void const*, std::size_t, error_code&) noexcept; -}; - -} // concept - -/// Evaluates to std::true_type if `T` models Body -template -struct is_Body : std::true_type -{ -}; - -/// Evalulates to std::true_type if Body has a reader -template -struct is_ReadableBody : std::true_type -{ -}; - -/// Evalulates to std::true_type if Body has a writer -template -struct is_WritableBody : std::true_type -{ -}; - -/// Evaluates to std::true_type if `T` models HTTPMessage -template -struct is_HTTPMessage : std::false_type -{ -}; - -/// Evaluates to std::true_type if `HTTPMessage` is a request -template -struct is_HTTPRequest : std::true_type -{ -}; - -} // http -} // beast - -#endif diff --git a/src/beast/beast/streams/abstract_ostream.h b/src/beast/beast/streams/abstract_ostream.h deleted file mode 100644 index b4275feff9..0000000000 --- a/src/beast/beast/streams/abstract_ostream.h +++ /dev/null @@ -1,32 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_STREAMS_ABSTRACT_OSTREAM_H_INCLUDED -#define BEAST_STREAMS_ABSTRACT_OSTREAM_H_INCLUDED - -#include - -namespace beast { - -/** An abstract ostream for `char`. */ -using abstract_ostream = basic_abstract_ostream ; - -} - -#endif diff --git a/src/beast/beast/streams/basic_std_ostream.h b/src/beast/beast/streams/basic_std_ostream.h deleted file mode 100644 index 316d53a4d4..0000000000 --- a/src/beast/beast/streams/basic_std_ostream.h +++ /dev/null @@ -1,73 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_STREAMS_BASIC_STD_OSTREAM_H_INCLUDED -#define BEAST_STREAMS_BASIC_STD_OSTREAM_H_INCLUDED - -#include - -#include - -namespace beast { - -/** Wraps an existing std::basic_ostream as an abstract_ostream. */ -template < - class CharT, - class Traits = std::char_traits -> -class basic_std_ostream - : public basic_abstract_ostream -{ -private: - using typename basic_abstract_ostream ::string_type; - - std::reference_wrapper m_stream; - -public: - explicit basic_std_ostream ( - std::basic_ostream & stream) - : m_stream (stream) - { - } - - void - write (string_type const& s) override - { - m_stream.get() << s << std::endl; - } -}; - -using std_ostream = basic_std_ostream ; - -//------------------------------------------------------------------------------ - -/** Returns a basic_std_ostream using template argument deduction. */ -template < - class CharT, - class Traits = std::char_traits -> -basic_std_ostream -make_std_ostream (std::basic_ostream & stream) -{ - return basic_std_ostream (stream); -} - -} - -#endif diff --git a/src/beast/beast/streams/debug_ostream.h b/src/beast/beast/streams/debug_ostream.h deleted file mode 100644 index fc6322f41e..0000000000 --- a/src/beast/beast/streams/debug_ostream.h +++ /dev/null @@ -1,91 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_STREAMS_DEBUG_OSTREAM_H_INCLUDED -#define BEAST_STREAMS_DEBUG_OSTREAM_H_INCLUDED - -#include - -#include - -#ifdef _MSC_VER -# ifndef WIN32_LEAN_AND_MEAN // VC_EXTRALEAN -# define WIN32_LEAN_AND_MEAN -#include -# undef WIN32_LEAN_AND_MEAN -# else -#include -# endif -# ifdef min -# undef min -# endif -# ifdef max -# undef max -# endif -#endif - -namespace beast { - -#ifdef _MSC_VER -/** A basic_abstract_ostream that redirects output to an attached debugger. */ -class debug_ostream - : public abstract_ostream -{ -private: - bool m_debugger; - -public: - debug_ostream() - : m_debugger (IsDebuggerPresent() != FALSE) - { - // Note that the check for an attached debugger is made only - // during construction time, for efficiency. A stream created before - // the debugger is attached will not have output redirected. - } - - void - write (string_type const& s) override - { - if (m_debugger) - { - OutputDebugStringA ((s + "\n").c_str()); - return; - } - - std::cout << s << std::endl; - } -}; - -#else -class debug_ostream - : public abstract_ostream -{ -public: - void - write (string_type const& s) override - { - std::cout << s << std::endl; - } -}; - -#endif - -} - -#endif diff --git a/src/beast/beast/streams/tests/beast_basic_abstract_ostream_test.cpp b/src/beast/beast/streams/tests/beast_basic_abstract_ostream_test.cpp deleted file mode 100644 index df2ea3c021..0000000000 --- a/src/beast/beast/streams/tests/beast_basic_abstract_ostream_test.cpp +++ /dev/null @@ -1,66 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#if BEAST_INCLUDE_BEASTCONFIG -#include "../../BeastConfig.h" -#endif - -#include - -#include - -namespace beast { - -class basic_abstract_ostream_test : public unit_test::suite -{ -public: - class test_stream : public basic_abstract_ostream - { - public: - test_stream& - operator= (test_stream const&) = delete; - - explicit - test_stream (unit_test::suite& suite_) - : m_suite (suite_) - { - } - - void write (string_type const& s) override - { - m_suite.log << s; - } - - private: - unit_test::suite& m_suite; - }; - - void run() - { - test_stream ts (*this); - - ts << "Hello"; - - pass(); - } -}; - -BEAST_DEFINE_TESTSUITE(basic_abstract_ostream,streams,beast); - -} diff --git a/src/beast/beast/unit_test/README.md b/src/beast/beast/unit_test/README.md deleted file mode 100644 index 0382e28270..0000000000 --- a/src/beast/beast/unit_test/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# beast.unit_test - -This provides a framework for defining and running unit tests. diff --git a/src/beast/beast/unit_test/amount.h b/src/beast/beast/unit_test/amount.h deleted file mode 100644 index 317f5be810..0000000000 --- a/src/beast/beast/unit_test/amount.h +++ /dev/null @@ -1,67 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_AMOUNT_H_INCLUDED -#define BEAST_UNIT_TEST_AMOUNT_H_INCLUDED - -#include -#include -#include - -namespace beast { -namespace unit_test { - -/** Utility for producing nicely composed output of amounts with units. */ -class amount -{ -private: - std::size_t n_; - std::string const& what_; - -public: - amount (amount const&) = default; - amount& operator= (amount const&) = delete; - - template - amount (std::size_t n, std::string const& what); - - friend - std::ostream& - operator<< (std::ostream& s, amount const& t); -}; - -template -amount::amount (std::size_t n, std::string const& what) - : n_ (n) - , what_ (what) -{ -} - -inline -std::ostream& -operator<< (std::ostream& s, amount const& t) -{ - s << t.n_ << " " << t.what_ << ((t.n_ != 1) ? "s" : ""); - return s; -} - -} // unit_test -} // beast - -#endif diff --git a/src/beast/beast/unit_test/global_suites.h b/src/beast/beast/unit_test/global_suites.h deleted file mode 100644 index 8a446c91ed..0000000000 --- a/src/beast/beast/unit_test/global_suites.h +++ /dev/null @@ -1,68 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_GLOBAL_SUITES_H_INCLUDED -#define BEAST_UNIT_TEST_GLOBAL_SUITES_H_INCLUDED - -#include - -namespace beast { -namespace unit_test { - -namespace detail { - -template -suite_list& -global_suites() -{ - static suite_list s; - return s; -} - -template -struct insert_suite -{ - template - insert_suite (char const* name, char const* module, - char const* library, bool manual); -}; - -template -template -insert_suite::insert_suite (char const* name, - char const* module, char const* library, bool manual) -{ - global_suites().insert ( - name, module, library, manual); -} - -} // detail - -/** Holds suites registered during static initialization. */ -inline -suite_list const& -global_suites() -{ - return detail::global_suites(); -} - -} -} - -#endif diff --git a/src/beast/beast/unit_test/print.h b/src/beast/beast/unit_test/print.h deleted file mode 100644 index 376cc8686e..0000000000 --- a/src/beast/beast/unit_test/print.h +++ /dev/null @@ -1,80 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_PRINT_H_INCLUDED -#define BEAST_UNIT_TEST_PRINT_H_INCLUDED - -#include -#include - -#include -#include - -#include -#include - -namespace beast { -namespace unit_test { - -/** Write test results to the specified output stream. */ -/** @{ */ -template -void -print (results const& r, abstract_ostream& stream) -{ - for (auto const& s : r) - { - for (auto const& c : s) - { - stream << - s.name() << - (c.name().empty() ? "" : ("." + c.name())); - - std::size_t i (1); - for (auto const& t : c.tests) - { - if (! t.pass) - stream << - "#" << i << - " failed: " << t.reason; - ++i; - } - } - } - - stream << - amount (r.size(), "suite") << ", " << - amount (r.cases(), "case") << ", " << - amount (r.total(), "test") << " total, " << - amount (r.failed(), "failure") - ; -} - -template -void -print (results const& r, std::ostream& stream = std::cout) -{ - auto s (make_std_ostream (stream)); - print (r, s); -} - -} // unit_test -} // beast - -#endif diff --git a/src/beast/beast/unity/beast_asio_unity.cpp b/src/beast/beast/unity/beast_asio_unity.cpp deleted file mode 100644 index 74208df9d0..0000000000 --- a/src/beast/beast/unity/beast_asio_unity.cpp +++ /dev/null @@ -1,22 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include diff --git a/src/beast/beast/unity/beast_crypto_unity.cpp b/src/beast/beast/unity/beast_crypto_unity.cpp deleted file mode 100644 index fdb2e106dd..0000000000 --- a/src/beast/beast/unity/beast_crypto_unity.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include - diff --git a/src/beast/beast/unity/beast_http_unity.cpp b/src/beast/beast/unity/beast_http_unity.cpp deleted file mode 100644 index 8e8684a258..0000000000 --- a/src/beast/beast/unity/beast_http_unity.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include -#include - -// VFALCO Must come last otherwise Windows 10 SDK -// gets a compile error in winnt.h -#include diff --git a/src/beast/beast/unity/beast_streams_unity.cpp b/src/beast/beast/unity/beast_streams_unity.cpp deleted file mode 100644 index 7de0dea249..0000000000 --- a/src/beast/beast/unity/beast_streams_unity.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include diff --git a/src/beast/beast/unity/beast_test_unity.cpp b/src/beast/beast/unity/beast_test_unity.cpp deleted file mode 100644 index 654d00821f..0000000000 --- a/src/beast/beast/unity/beast_test_unity.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include diff --git a/src/beast/beast/unity/beast_wsproto_unity.cpp b/src/beast/beast/unity/beast_wsproto_unity.cpp deleted file mode 100644 index c41bd2ac69..0000000000 --- a/src/beast/beast/unity/beast_wsproto_unity.cpp +++ /dev/null @@ -1,21 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include diff --git a/src/beast/beast/wsproto.h b/src/beast/beast/wsproto.h deleted file mode 100644 index 542b308a3f..0000000000 --- a/src/beast/beast/wsproto.h +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_H_INCLUDED -#define BEAST_WSPROTO_H_INCLUDED - -#include -#include -#include -#include -#include -#include - -#endif diff --git a/src/beast/beast/wsproto/README.md b/src/beast/beast/wsproto/README.md deleted file mode 100644 index 22fc6a518c..0000000000 --- a/src/beast/beast/wsproto/README.md +++ /dev/null @@ -1,232 +0,0 @@ -# Beast.WSProto - --------------------------------------------------------------------------------- - -Beast.WSProto provides developers with a robust WebSocket implementation -built on Boost.Asio with a consistent asynchronous model using a modern -C++ approach. - -## Introduction - -Today's web applications increasingly rely on alternatives to standard HTTP -to achieve performance and/or responsiveness. While WebSocket implementations -are widely available in common web development languages such as Javascript, -good implementations in C++ are scarce. A survey of existing C++ WebSocket -solutions reveals interfaces which have performance limitations, place -unecessary restrictions on callers, exhibit excess complexity, and fail to -take advantage of C++ features or the underlying network transport. - -Beast.WSProto is built on Boost.Asio, a robust cross platform networking -framework that is part of Boost and also offered as a standalone library. -A proposal to add networking functionality to the C++ standard library, -based on Boost.Asio, is under consideration by the standards committee. -Since the final approved networking interface for the C++ standard library -will likely closely resemble the current interface of Boost.Asio, it is -logical for Beast.WSProto to use Boost.Asio as its network transport. - -Beast.WSProto addresses the following goals: - -* **Ease of Use.** WSProto offers only one socket object, whose interface -resembles that of Boost.Asio socket as closely as possible. Users familiar -with Boost.Asio will be immediately comfortable using a `wsproto::socket`. - -* **Flexibility.** Library interfaces should provide callers with maximum -flexibility in implementation; Important decisions such as how to manage -buffers or be notified of completed asynchronous operations should be made -by callers not the library. - -* **Performance.** The implementation should achieve the highest level -of performance possible, with no penalty for using abstractions. - -* **Scalability.** The library should facilitate the development of -network applications that scale to thousands of concurrent connections. - -* **Efficiency.** The library should support techniques such as -scatter-gather I/O, and allow programs to minimise data copying. - -* **Basis for further abstraction.** The library should permit the -development of other libraries that provide higher levels of abstraction. - -Beast.WSProto takes advantage of Boost.Asio's universal Asynchronous -model, handler allocation, and handler invocation hooks. Calls to wsproto -asynchronous initiation functions allow callers the choice of using a -completion handler, stackful or stackless coroutines, futures, or user -defined customizations (for example, Boost.Fiber). The implementation -uses handler invocation hooks (`asio_handler_invoke`), providing -execution guarantees on composed operations in a manner identical to -Boost.Asio. The implementation also uses handler allocation hooks -(`asio_handler_allocate`) when allocating memory internally for composed -operations. - -There is no need for inheritance or virtual members in `wsproto::socket`. -All operations are templated and transparent to the compiler, allowing for -maximum inlining and optimization. - -## Usage - -All examples and identifiers mentioned in this document are written as -if the following declarations are in effect: -```C++ -#include -using namespace beast; -using namespace boost::asio; -``` - -### Creating a Socket - -To participate in a WebSocket connection, callers create an instance -of `wsproto::socket` templated on the `Stream` argument, which must meet -the requirements of `AsyncReadStream`, `AsyncWriteStream`, `SyncReadStream`, -and `SyncWriteStream`. Examples of types that meet these requirements are -`ip::tcp::socket` and `ssl::stream<...>`: -```c++ -io_service ios; -wsproto::socket ws1(ios); // owns the socket - -ssl::context ctx(ssl::context::sslv23); -wsproto::socket> wss(ios, ctx); // owns the socket - -ip::tcp::socket sock(ios); -wsproto::socket ws2(sock); // does not own the socket -``` - -### Connection Establishment - -Callers are responsible for performing tasks such as connection establishment -before attempting websocket activities. -```c++ -io_service ios; -wsproto::socket ws(ios); -ws.next_layer().connect(ip::tcp::endpoint( - ip::tcp::address::from_string("127.0.0.1"), 80)); -``` - -### WebSocket Handshake - -After the connection is established, the socket may be used to initiate -or accept a WebSocket Update request. - -```c++ -// send a WebSocket Upgrade request. -ws.handshake(); -``` - -### Sending and Receiving Messages - -After the WebSocket handshake is accomplished, callers may send and receive -messages using the message oriented interface: -```c++ -void echo(wsproto::socket& ws) -{ - streambuf sb; - wsproto::opcode op; - wsproto::read(ws, op, sb); - wsproto::write(ws, op, sb.data()); - sb.consume(sb.size()); -} -``` - -Alternatively, callers may process incoming message data -incrementally: -```c++ -void echo(wsproto::socket& ws) -{ - streambuf sb; - wsproto::msg_info mi{}; - for(;;) - { - ws.read_some(mi, sb); - if(mi.fin) - break; - } - wsproto::write(ws, op, sb.data()); -} -``` - -### Asynchronous Completions, Coroutines, and Futures - -Asynchronous versions are available for all functions: -```c++ -wsproto::async_read(ws, sb, std::bind( - &on_read, beast::asio::placeholders::error)); -``` - -Calls to WSProto asynchronous initiation functions support -asio-style completion handlers, and other completion tokens -such as support for coroutines or futures: -```c++ -void echo(wsproto::socket& ws, - boost::asio::yield_context yield) -{ - wsproto::async_read(ws, sb, yield); - std::future fut = - wsproto::async_write(ws, sb.data(), boost::use_future); - ... -} -``` - -## Implementation - -### Buffers - -Because calls to read WebSocket data may return a variable amount of bytes, -the interface to calls that read data require an object that meets the -requirements of `Streambuf`. This concept is modeled on -`boost::asio::basic_streambuf`, which meets the requirements of `Streambuf` -defined below. - -The `Streambuf` concept is intended to permit the following implementation -strategies: - -* A single contiguous character array, which is reallocated as necessary to - accommodate changes in the size of the byte sequence. This is the - implementation approach currently used in `boost::asio::basic_streambuf`. -* A sequence of one or more byte arrays, where each array is of the same - size. Additional byte array objects are appended to the sequence to - accommodate changes in the size of the byte sequence. -* A sequence of one or more byte arrays of varying sizes. Additional byte - array objects are appended to the sequence to accommodate changes in the - size of the byte sequence. This is the implementation approach currently - used in `beast::basic_streambuf`. - -#### `Streambuf` requirements: - -In the table below, `X` denotes a class, `a` denotes a value -of type `X`, `n` denotes a value convertible to `std::size_t`, -and `U` and `T` denote unspecified types. - -expression | return | type assertion/note/pre/post-condition -------------------------- | ------------- | -------------------------------------- -`X::const_buffers_type` | `T` | `T` meets the requirements for `ConstBufferSequence`. -`X::mutable_buffers_type` | `U` | `U` meets the requirements for `MutableBufferSequence`. -`a.commit(n)` | | Moves bytes from the output sequence to the input sequence. -`a.consume(n)` | | Removes bytes from the input sequence. -`a.data()` | `T` | Returns a list of buffers that represents the input sequence. -`a.prepare(n)` | `U` | Returns a list of buffers that represents the output sequence, with the given size. -`a.size()` | `std::size_t` | Returns the size of the input sequence. -`a.max_size()` | `std::size_t` | Returns the maximum size of the `Streambuf`. - -### Thread Safety - -Like a regular asio socket, a `wsproto::socket` is not thread safe. Callers are -responsible for synchronizing operations on the socket using an implicit or -explicit strand, as per the Asio documentation. A `wsproto::socket` supports -one active read and one active write at the same time (caller initiated close, -ping, and pong operations count as a write). - -### Buffering - -The implementation does not perform queueing or buffering of messages. If desired, -these features should be implemented by callers. The impact of this design is -that the caller is in full control of the allocation strategy used to store -data and the back-pressure applied on the read and write side of the underlying -TCP/IP connection. - -### The `io_service` - -The creation and operation of the `boost::asio::io_service` associated with the -Stream object underlying the `wsproto::socket` is completely left up to the -user of the library, permitting any implementation strategy including one that -does not require threads for environments where threads are unavailable. -Beast.WSProto itself does not use or require threads. diff --git a/src/beast/beast/wsproto/detail/hybi13.h b/src/beast/beast/wsproto/detail/hybi13.h deleted file mode 100644 index ec7d56559e..0000000000 --- a/src/beast/beast/wsproto/detail/hybi13.h +++ /dev/null @@ -1,66 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_HYBI13_H_INCLUDED -#define BEAST_WSPROTO_HYBI13_H_INCLUDED - -#include -#include -#include -#include -#include -#include - -namespace beast { -namespace wsproto { -namespace detail { - -template -std::string -make_sec_ws_key(Gen& g) -{ - union U - { - std::array a4; - std::array a16; - }; - U u; - for(int i = 0; i < 4; ++i) - u.a4[i] = g(); - return base64_encode(u.a16.data(), u.a16.size()); -} - -template -std::string -make_sec_ws_accept(boost::string_ref const& key) -{ - std::string s(key.data(), key.size()); - s += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; - beast::sha_hasher h; - h(s.data(), s.size()); - auto const digest = static_cast< - beast::sha_hasher::result_type>(h); - return base64_encode(digest.data(), digest.size()); -} - -} // detail -} // wsproto -} // beast - -#endif diff --git a/src/beast/beast/wsproto/error.h b/src/beast/beast/wsproto/error.h deleted file mode 100644 index 1ccb658ab7..0000000000 --- a/src/beast/beast/wsproto/error.h +++ /dev/null @@ -1,72 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_ERROR_H_INCLUDED -#define BEAST_WSPROTO_ERROR_H_INCLUDED - -#include - -namespace beast { -namespace wsproto { - -using error_code = boost::system::error_code; - -/// Error values -enum class error -{ - /// Both sides performed a WebSocket close - closed = 1, - - /// WebSocket connection failed, protocol violation - failed, - - /// Upgrade request failed, connection is closed - handshake_failed, - - /// Upgrade request failed, but connection is still open - keep_alive, - - /// HTTP response is malformed - response_malformed, - - /// HTTP response failed the upgrade - response_failed, - - /// Upgrade request denied for invalid fields. - response_denied, - - /// Upgrade request is malformed - request_malformed, - - /// Upgrade request fields incorrect - request_invalid, - - /// Upgrade request denied - request_denied -}; - -error_code -make_error_code(error e); - -} // wsproto -} // beast - -#include - -#endif diff --git a/src/beast/beast/wsproto/impl/error.ipp b/src/beast/beast/wsproto/impl/error.ipp deleted file mode 100644 index 85a7fe9540..0000000000 --- a/src/beast/beast/wsproto/impl/error.ipp +++ /dev/null @@ -1,39 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_ERROR_IPP_H_INCLUDED -#define BEAST_WSPROTO_ERROR_IPP_H_INCLUDED - -#include - -namespace beast { -namespace wsproto { - -inline -error_code -make_error_code(error e) -{ - return error_code( - static_cast(e), detail::get_error_category()); -} - -} // wsproto -} // beast - -#endif diff --git a/src/beast/beast/wsproto/src/test/async_echo_peer.h b/src/beast/beast/wsproto/src/test/async_echo_peer.h deleted file mode 100644 index b81fc8234c..0000000000 --- a/src/beast/beast/wsproto/src/test/async_echo_peer.h +++ /dev/null @@ -1,285 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_ASYNC_ECHO_PEER_H_INCLUDED -#define BEAST_WSPROTO_ASYNC_ECHO_PEER_H_INCLUDED - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace beast { -namespace wsproto { -namespace test { - -// Asynchronous WebSocket echo client/server -// -class async_echo_peer -{ -public: - static std::size_t constexpr autobahnCycles = 520; - - using error_code = boost::system::error_code; - using endpoint_type = boost::asio::ip::tcp::endpoint; - using address_type = boost::asio::ip::address; - using socket_type = boost::asio::ip::tcp::socket; - -private: - unit_test::suite& suite_; - boost::asio::io_service ios_; - socket_type sock_; - boost::asio::ip::tcp::acceptor acceptor_; - std::vector thread_; - std::size_t n_ = 0; - -public: - async_echo_peer(bool server, - endpoint_type const& ep, unit_test::suite& suite) - : suite_(suite) - , sock_(ios_) - , acceptor_(ios_) - { - if(server) - { - error_code ec; - acceptor_.open(ep.protocol(), ec); - maybe_throw(ec, "open"); - acceptor_.bind(ep, ec); - maybe_throw(ec, "bind"); - acceptor_.listen( - boost::asio::socket_base::max_connections, ec); - maybe_throw(ec, "listen"); - acceptor_.async_accept(sock_, - std::bind(&async_echo_peer::on_accept, this, - beast::asio::placeholders::error)); - } - else - { - Peer{std::move(sock_), ep, suite_}; - } - auto const n = 1; - thread_.reserve(n); - for(int i = 0; i < n; ++i) - thread_.emplace_back(suite_, - [&] { ios_.run(); }); - } - - ~async_echo_peer() - { - error_code ec; - ios_.dispatch( - [&]{ acceptor_.close(ec); }); - for(auto& t : thread_) - t.join(); - } - -private: - class Peer - { - struct data - { - int state = 0; - unit_test::suite& suite; - boost::optional ep; - wsproto::socket ws; - wsproto::opcode op; - beast::streambuf sb; - int id; - - data(socket_type&& sock_, - unit_test::suite& suite_) - : suite(suite_) - , ws(std::move(sock_)) - , id([] - { - static int n = 0; - return ++n; - }()) - { - } - - data(socket_type&& sock_, endpoint_type const& ep_, - unit_test::suite& suite_) - : suite(suite_) - , ep(ep_) - , ws(std::move(sock_)) - , id([] - { - static int n = 0; - return ++n; - }()) - { - } - }; - - std::shared_ptr d_; - - public: - Peer(Peer&&) = default; - Peer(Peer const&) = default; - Peer& operator=(Peer&&) = delete; - Peer& operator=(Peer const&) = delete; - - struct identity - { - template - void - operator()(http::message& req) - { - req.headers.replace("User-Agent", "async_echo_client"); - } - - template - void - operator()(http::message& resp) - { - resp.headers.replace("Server", "async_echo_server"); - } - }; - - template - explicit - Peer(socket_type&& sock, Args&&... args) - : d_(std::make_shared( - std::forward(sock), - std::forward(args)...)) - { - auto& d = *d_; - d.ws.set_option(decorate(identity{})); - //d.ws.set_option(auto_fragment_size(0)); - d.ws.set_option(read_message_max(64 * 1024 * 1024)); - run(); - } - - void run() - { - auto& d = *d_; - if(! d.ep) - { - d.ws.async_accept(std::move(*this)); - } - else - { - d.state = 4; - d.ws.next_layer().async_connect( - *d.ep, std::move(*this)); - } - } - - void operator()(error_code ec) - { - auto& d = *d_; - switch(d_->state) - { - // did accept - case 0: - if(ec) - return fail(ec, "async_accept"); - - // start - case 1: - if(ec) - return fail(ec, "async_handshake"); - d.sb.consume(d.sb.size()); - // read message - d.state = 2; - d.ws.async_read(d.op, d.sb, std::move(*this)); - return; - - // got message - case 2: - if(ec == wsproto::error::closed) - return; - if(ec) - return fail(ec, "async_read"); - // write message - d.state = 1; - d.ws.set_option(wsproto::message_type(d.op)); - d.ws.async_write(d.sb.data(), std::move(*this)); - return; - - // connected - case 4: - if(ec) - return fail(ec, "async_connect"); - d.state = 1; - d.ws.async_handshake( - d.ep->address().to_string() + ":" + - std::to_string(d.ep->port()), - "/", std::move(*this)); - return; - } - } - - private: - void - fail(error_code ec, std::string what) - { - if(ec != wsproto::error::closed) - { - d_->suite.log << - "#" << std::to_string(d_->id) << " " << - what << ": " << ec.message(); - } - } - }; - - void - fail(error_code ec, std::string what) - { - suite_.log << - what << ": " << ec.message(); - } - - void - maybe_throw(error_code ec, std::string what) - { - if(ec) - { - fail(ec, what); - throw ec; - } - } - - void - on_accept(error_code ec) - { - if(! acceptor_.is_open()) - return; - maybe_throw(ec, "accept"); - socket_type sock(std::move(sock_)); - if(n_ < autobahnCycles) - acceptor_.async_accept(sock_, - std::bind(&async_echo_peer::on_accept, this, - beast::asio::placeholders::error)); - Peer{std::move(sock), suite_}; - } -}; - -} // test -} // wsproto -} // beast - -#endif diff --git a/src/beast/beast/wsproto/src/test/beast_wsproto_ws_echo_test.cpp b/src/beast/beast/wsproto/src/test/beast_wsproto_ws_echo_test.cpp deleted file mode 100644 index 188a8200e3..0000000000 --- a/src/beast/beast/wsproto/src/test/beast_wsproto_ws_echo_test.cpp +++ /dev/null @@ -1,94 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include -#include -#include - -namespace beast { -namespace wsproto { -namespace test { - -class ws_echo_test : public unit_test::suite -{ -public: - using endpoint_type = boost::asio::ip::tcp::endpoint; - using address_type = boost::asio::ip::address; - - void - run() override - { - async_echo_peer s1(true, endpoint_type{ - address_type::from_string("127.0.0.1"), - 6000 }, *this); - - sync_echo_peer s2(true, endpoint_type{ - address_type::from_string("127.0.0.1"), - 6001 }, *this); - - boost::asio::io_service ios; - boost::asio::signal_set signals( - ios, SIGINT, SIGTERM); - std::mutex m; - bool stop = false; - std::condition_variable cv; - signals.async_wait( - [&](boost::system::error_code const& ec, - int signal_number) - { - std::lock_guard lock(m); - stop = true; - cv.notify_one(); - }); - std::unique_lock lock(m); - cv.wait(lock, [&]{ return stop; }); - } -}; - -class ws_client_test : public unit_test::suite -{ -public: - using endpoint_type = boost::asio::ip::tcp::endpoint; - using address_type = boost::asio::ip::address; - - void - run() override - { - pass(); - { - async_echo_peer s1(false, endpoint_type{ - address_type::from_string("127.0.0.1"), - 9001 }, *this); - } - { - sync_echo_peer s2(false, endpoint_type{ - address_type::from_string("127.0.0.1"), - 9001 }, *this); - } - } -}; - -BEAST_DEFINE_TESTSUITE_MANUAL(ws_echo, asio, beast); -BEAST_DEFINE_TESTSUITE_MANUAL(ws_client, asio, beast); - -} // test -} // wsproto -} // beast diff --git a/src/beast/beast/wsproto/src/test/beast_wsproto_ws_test.cpp b/src/beast/beast/wsproto/src/test/beast_wsproto_ws_test.cpp deleted file mode 100644 index 05176ce8f0..0000000000 --- a/src/beast/beast/wsproto/src/test/beast_wsproto_ws_test.cpp +++ /dev/null @@ -1,362 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include -#include -#include -#include - -namespace beast { -namespace wsproto { - -class ws_test : public unit_test::suite -{ -public: - using error_code = boost::system::error_code; - using endpoint_type = boost::asio::ip::tcp::endpoint; - using address_type = boost::asio::ip::address; - using socket_type = boost::asio::ip::tcp::socket; - using yield_context = boost::asio::yield_context; - - endpoint_type ep_; - - //-------------------------------------------------------------------------- - - // opcodes for creating the test plans - - // concurrent read and write - struct case_1{}; - - // write a bad frame and shut down - struct case_2{}; - - //-------------------------------------------------------------------------- - - class coro_peer - { - error_code ec_; - boost::asio::io_service ios_; - boost::asio::ip::tcp::acceptor acceptor_; - socket_type sock_; - socket ws_; - opcode op_; - beast::streambuf rb_; - beast::streambuf wb_; - yield_context* yield_; - int state_ = 0; - //unit_test::suite& test_; - - public: - coro_peer(coro_peer&&) = default; - coro_peer(coro_peer const&) = delete; - coro_peer& operator=(coro_peer&&) = delete; - coro_peer& operator=(coro_peer const&) = delete; - - template - coro_peer(bool server, endpoint_type ep, - unit_test::suite& test, Ops const&... ops) - : acceptor_(ios_) - , sock_(ios_) - , ws_(sock_) - //, test_(test) - { - if(server) - { - acceptor_.open(ep.protocol()); - acceptor_.bind(ep); - acceptor_.listen( - boost::asio::socket_base::max_connections); - boost::asio::spawn(ios_, - [=](auto yield) - { - yield_ = &yield; - state_ = 10; - acceptor_.async_accept(sock_, (*yield_)[ec_]); - if(ec_) - return this->fail("accept"); - state_ = 20; - ws_.async_accept((*yield_)[ec_]); - if(ec_) - return this->fail("ws.accept"); - this->invoke(ops...); - state_ = -1; - }); - } - else - { - boost::asio::spawn(ios_, - [=](auto yield) - { - yield_ = &yield; - state_ = 30; - sock_.async_connect(ep, (*yield_)[ec_]); - if(ec_) - return this->fail("connect"); - state_ = 40; - ws_.async_handshake(ep.address().to_string() + - std::to_string(ep.port()), "/", (*yield_)[ec_]); - if(ec_) - return this->fail("handshake"); - this->invoke(ops...); - state_ = -1; - }); - } - } - - ~coro_peer() - { - } - - int - state() const - { - return state_; - } - - void - run_one() - { - ios_.run_one(); - } - - void - step_to(int to = 0) - { - while(state_ != to) - ios_.run_one(); - } - - private: - template - void fail(String const& s) - { - } - - void invoke_1(case_1) - { - ws_.async_read(op_, rb_, - [&](auto ec) - { - if(ec) - return this->fail(ec); - rb_.consume(rb_.size()); - }); - state_ = 100; - ws_.async_write( - boost::asio::null_buffers{}, (*yield_)[ec_]); - if(ec_) - return fail("write"); - } - - void invoke_1(case_2) - { - detail::frame_header fh; - fh.op = opcode::rsv5; // bad opcode - fh.fin = true; - fh.mask = true; - fh.rsv1 = false; - fh.rsv2 = false; - fh.rsv3 = false; - fh.len = 0; - fh.key = 0; - detail::write(wb_, fh); - state_ = 200; - boost::asio::async_write( - ws_.next_layer(), wb_.data(), - (*yield_)[ec_]); - if(ec_) - return fail("write"); - ws_.next_layer().shutdown( - socket_type::shutdown_both, ec_); - if(ec_) - return fail("shutdown"); - } - - inline - void - invoke() - { - } - - template - inline - void - invoke(Op op, Ops const&... ops) - { - invoke_1(op); - invoke(ops...); - } - }; - - void - testInvokable() - { - endpoint_type const ep{ - address_type::from_string( - "127.0.0.1"), 6000}; - coro_peer server(true, ep, *this, case_1{}); - coro_peer client(false, ep, *this, case_2{}); - server.step_to(10); // async_accept - client.step_to(30); // async_connect - server.step_to(20); // async_accept(ws) - client.step_to(40); // async_handshake - server.step_to(100); // case_1 - client.step_to(200); // case_2 - client.step_to(-1); - server.step_to(-1); - } - - //-------------------------------------------------------------------------- - - bool - maybe_fail(error_code const& ec, std::string const& what) - { - return expect(! ec, what + ": " + ec.message()); - } - - void - maybe_throw(error_code ec, std::string what) - { - if(ec) - { - maybe_fail(ec, what); - throw ec; - } - } - - template - static - std::string - buffers_to_string(Buffers const& bs) - { - using boost::asio::buffer_cast; - using boost::asio::buffer_size; - std::string s; - s.reserve(buffer_size(bs)); - for(auto const& b : bs) - s.append(buffer_cast(b), - buffer_size(b)); - for(auto i = s.size(); i-- > 0;) - if(s[i] == '\r') - s.replace(i, 1, "\\r"); - else if(s[i] == '\n') - s.replace(i, 1, "\\n\n"); - return s; - } - - int - makeRequest(endpoint_type ep, std::string const& s) - { - using boost::asio::buffer; - boost::asio::io_service ios; - boost::asio::ip::tcp::socket sock(ios); - sock.connect(ep); - write(sock, append_buffers( - buffer(s), buffer("\r\n"))); - - using namespace http; - response resp; - streambuf sb; - read(sock, sb, resp); - return resp.status; - } - - void - expectStatus(endpoint_type ep, - int status, std::string const& s) - { - expect(makeRequest(ep, s) == status); - } - - void - testHandshake(endpoint_type ep) - { - expectStatus(ep, 400, "GET / HTTP/1.0\r\n"); - } - - void - syncEchoClient(endpoint_type ep) - { - using boost::asio::buffer; - error_code ec; - boost::asio::io_service ios; - wsproto::socket ws(ios); - ws.next_layer().connect(ep, ec); - if(! maybe_fail(ec, "connect")) - return; - ws.handshake(ep.address().to_string(), "/", ec); - if(! maybe_fail(ec, "upgrade")) - return; - std::string s(65535, '*'); - ws.write_frame(true, buffer(s), ec); - if(! maybe_fail(ec, "write")) - return; - boost::asio::streambuf sb; - wsproto::opcode op; - ws.read(op, sb, ec); - if(! maybe_fail(ec, "read")) - return; - if(! ec) - expect(op == wsproto::opcode::text); - expect(buffers_to_string(sb.data()) == s); - sb.consume(sb.size()); - ws.close({}, ec); - if(! maybe_fail(ec, "close")) - return; - while(! ec) - { - ws.read(op, sb, ec); - if(! ec) - sb.consume(sb.size()); - } - if(ec != error::closed) - maybe_fail(ec, "teardown"); - } - - void - run() override - { - //testInvokable(); - - { - endpoint_type ep{ - address_type::from_string("127.0.0.1"), 6000}; - testcase("Echo Server"); - test::sync_echo_peer s(true, ep, *this); - //testHandshake(ep); - syncEchoClient(ep); - } - - { - endpoint_type ep{ - address_type::from_string("127.0.0.1"), 6001}; - testcase("Async Echo Server"); - test::async_echo_peer s(true, ep, *this); - //testHandshake(ep); - syncEchoClient(ep); - } - } -}; - -BEAST_DEFINE_TESTSUITE(ws,asio,beast); - -} // wsproto -} // beast diff --git a/src/beast/beast/wsproto/src/test/sync_echo_peer.h b/src/beast/beast/wsproto/src/test/sync_echo_peer.h deleted file mode 100644 index 1e8e4377c4..0000000000 --- a/src/beast/beast/wsproto/src/test/sync_echo_peer.h +++ /dev/null @@ -1,182 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_SYNC_ECHO_PEER_H_INCLUDED -#define BEAST_WSPROTO_SYNC_ECHO_PEER_H_INCLUDED - -#include -#include -#include -#include -#include -#include -#include - -namespace beast { -namespace wsproto { -namespace test { - -// Synchronous WebSocket echo client/server -// -class sync_echo_peer -{ -public: - static std::size_t constexpr autobahnCycles = 520; - - using error_code = boost::system::error_code; - using endpoint_type = boost::asio::ip::tcp::endpoint; - using address_type = boost::asio::ip::address; - using socket_type = boost::asio::ip::tcp::socket; - -private: - unit_test::suite& suite_; - boost::asio::io_service ios_; - socket_type sock_; - boost::asio::ip::tcp::acceptor acceptor_; - unit_test::thread thread_; - std::size_t n_ = 0; - -public: - sync_echo_peer(bool server, - endpoint_type ep, unit_test::suite& suite) - : suite_(suite) - , sock_(ios_) - , acceptor_(ios_) - { - error_code ec; - acceptor_.open(ep.protocol(), ec); - maybe_throw(ec, "open"); - acceptor_.bind(ep, ec); - maybe_throw(ec, "bind"); - acceptor_.listen( - boost::asio::socket_base::max_connections, ec); - maybe_throw(ec, "listen"); - acceptor_.async_accept(sock_, - std::bind(&sync_echo_peer::on_accept, this, - beast::asio::placeholders::error)); - thread_ = unit_test::thread(suite_, - [&] - { - ios_.run(); - }); - } - - ~sync_echo_peer() - { - error_code ec; - ios_.dispatch( - [&]{ acceptor_.close(ec); }); - thread_.join(); - } - -private: - void - fail(error_code ec, std::string what) - { - suite_.log << - what << ": " << ec.message(); - } - - void - maybe_throw(error_code ec, std::string what) - { - if(ec) - { - fail(ec, what); - throw ec; - } - } - - void - on_accept(error_code ec) - { - if(ec == boost::asio::error::operation_aborted) - return; - maybe_throw(ec, "accept"); - ++n_; - std::thread{ - [ - this, - sock = std::move(sock_), - work = boost::asio::io_service::work{ios_} - ]() mutable - { - do_peer(std::move(sock)); - }}.detach(); - if(n_ < autobahnCycles) - acceptor_.async_accept(sock_, - std::bind(&sync_echo_peer::on_accept, this, - beast::asio::placeholders::error)); - } - - struct identity - { - template - void - operator()(http::message& req) - { - req.headers.replace("User-Agent", "sync_echo_client"); - } - - template - void - operator()(http::message& resp) - { - resp.headers.replace("Server", "sync_echo_server"); - } - }; - - void - do_peer(socket_type&& sock) - { - wsproto::socket ws(std::move(sock)); - ws.set_option(decorate(identity{})); - ws.set_option(read_message_max(64 * 1024 * 1024)); - //ws.set_option(auto_fragment_size(0)); - error_code ec; - ws.accept(ec); - if(ec) - { - fail(ec, "accept"); - return; - } - for(;;) - { - wsproto::opcode op; - beast::streambuf sb; - ws.read(op, sb, ec); - if(ec) - break; - ws.set_option(wsproto::message_type(op)); - ws.write(sb.data(), ec); - if(ec) - break; - } - if(ec && ec != wsproto::error::closed) - { - fail(ec, "read"); - } - } -}; - -} // test -} // wsproto -} // beast - -#endif diff --git a/src/beast/examples/Jamfile b/src/beast/examples/Jamfile index 10edb82b11..b615209cf8 100644 --- a/src/beast/examples/Jamfile +++ b/src/beast/examples/Jamfile @@ -8,17 +8,17 @@ import os ; exe http_crawl : - ../beast/http/src/beast_http_nodejs_parser.cpp + ../src/beast_http_nodejs_parser.cpp http_crawl.cpp urls_large_data.cpp ; exe http_server : - ../beast/http/src/beast_http_nodejs_parser.cpp + ../src/beast_http_nodejs_parser.cpp http_server.cpp ; exe wsproto_echo : - ../beast/http/src/beast_http_nodejs_parser.cpp + ../src/beast_http_nodejs_parser.cpp wsproto_echo.cpp ; diff --git a/src/beast/examples/file_body.h b/src/beast/examples/file_body.h index 34fa46e00a..e46cff9ed7 100644 --- a/src/beast/examples/file_body.h +++ b/src/beast/examples/file_body.h @@ -20,8 +20,8 @@ #ifndef BEAST_EXAMPLE_FILE_BODY_H_INCLUDED #define BEAST_EXAMPLE_FILE_BODY_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/beast/examples/http_async_server.h b/src/beast/examples/http_async_server.h index 8bc6ebf2b2..e3ace8e9d5 100644 --- a/src/beast/examples/http_async_server.h +++ b/src/beast/examples/http_async_server.h @@ -23,7 +23,7 @@ #include "file_body.h" #include "http_stream.h" -#include +#include #include #include #include diff --git a/src/beast/examples/http_server_response.h b/src/beast/examples/http_server_response.h deleted file mode 100644 index 54221aa159..0000000000 --- a/src/beast/examples/http_server_response.h +++ /dev/null @@ -1,31 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_EXAMPLE_SERVER_RESPONSE_H_INCLUDED -#define BEAST_HTTP_EXAMPLE_SERVER_RESPONSE_H_INCLUDED - -namespace beast { -namespace http { -namespace example { - -} // example -} // http -} // beast - -#endif diff --git a/src/beast/examples/http_stream.h b/src/beast/examples/http_stream.h index 9b7a7e1790..d49bbac5a6 100644 --- a/src/beast/examples/http_stream.h +++ b/src/beast/examples/http_stream.h @@ -20,8 +20,8 @@ #ifndef BEAST_HTTP_STREAM_H_INCLUDED #define BEAST_HTTP_STREAM_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/beast/examples/http_stream.ipp b/src/beast/examples/http_stream.ipp index 3432de8f06..fa5fd7ad77 100644 --- a/src/beast/examples/http_stream.ipp +++ b/src/beast/examples/http_stream.ipp @@ -20,12 +20,12 @@ #ifndef BEAST_HTTP_STREAM_IPP_INCLUDED #define BEAST_HTTP_STREAM_IPP_INCLUDED -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include namespace beast { diff --git a/src/beast/examples/http_sync_server.h b/src/beast/examples/http_sync_server.h index 610e1464de..db72729da7 100644 --- a/src/beast/examples/http_sync_server.h +++ b/src/beast/examples/http_sync_server.h @@ -23,7 +23,6 @@ #include "file_body.h" #include "http_stream.h" -#include #include #include #include diff --git a/src/beast/examples/wsproto_async_echo_peer.h b/src/beast/examples/wsproto_async_echo_peer.h index 89e51cd882..469e841f4a 100644 --- a/src/beast/examples/wsproto_async_echo_peer.h +++ b/src/beast/examples/wsproto_async_echo_peer.h @@ -20,9 +20,9 @@ #ifndef BEAST_WSPROTO_ASYNC_ECHO_PEER_H_INCLUDED #define BEAST_WSPROTO_ASYNC_ECHO_PEER_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include #include @@ -30,7 +30,7 @@ #include namespace beast { -namespace wsproto { +namespace websocket { // Asynchronous WebSocket echo client/server // @@ -94,8 +94,8 @@ private: { int state = 0; boost::optional ep; - wsproto::socket ws; - wsproto::opcode op; + websocket::stream ws; + websocket::opcode op; beast::streambuf sb; int id; @@ -197,13 +197,13 @@ private: // got message case 2: - if(ec == wsproto::error::closed) + if(ec == websocket::error::closed) return; if(ec) return fail(ec, "async_read"); // write message d.state = 1; - d.ws.set_option(wsproto::message_type(d.op)); + d.ws.set_option(websocket::message_type(d.op)); d.ws.async_write(d.sb.data(), std::move(*this)); return; @@ -224,7 +224,7 @@ private: void fail(error_code ec, std::string what) { - if(ec != wsproto::error::closed) + if(ec != websocket::error::closed) std::cerr << "#" << d_->id << " " << what << ": " << ec.message() << std::endl; } @@ -261,7 +261,7 @@ private: } }; -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/examples/wsproto_echo.cpp b/src/beast/examples/wsproto_echo.cpp index 2aa9da0cce..ba85637744 100644 --- a/src/beast/examples/wsproto_echo.cpp +++ b/src/beast/examples/wsproto_echo.cpp @@ -19,35 +19,18 @@ #include "wsproto_async_echo_peer.h" #include "wsproto_sync_echo_peer.h" -#include -#include -#include +#include "sig_wait.h" int main() { using endpoint_type = boost::asio::ip::tcp::endpoint; using address_type = boost::asio::ip::address; - beast::wsproto::async_echo_peer s1(true, endpoint_type{ + beast::websocket::async_echo_peer s1(true, endpoint_type{ address_type::from_string("127.0.0.1"), 6000 }, 4); - beast::wsproto::sync_echo_peer s2(true, endpoint_type{ + beast::websocket::sync_echo_peer s2(true, endpoint_type{ address_type::from_string("127.0.0.1"), 6001 }); - boost::asio::io_service ios; - boost::asio::signal_set signals( - ios, SIGINT, SIGTERM); - std::mutex m; - bool stop = false; - std::condition_variable cv; - signals.async_wait( - [&](boost::system::error_code const& ec, - int signal_number) - { - std::lock_guard lock(m); - stop = true; - cv.notify_one(); - }); - std::unique_lock lock(m); - cv.wait(lock, [&]{ return stop; }); + sig_wait(); } diff --git a/src/beast/examples/wsproto_sync_echo_peer.h b/src/beast/examples/wsproto_sync_echo_peer.h index 37aa3414e6..991a2d8cb6 100644 --- a/src/beast/examples/wsproto_sync_echo_peer.h +++ b/src/beast/examples/wsproto_sync_echo_peer.h @@ -20,8 +20,8 @@ #ifndef BEAST_WSPROTO_SYNC_ECHO_PEER_H_INCLUDED #define BEAST_WSPROTO_SYNC_ECHO_PEER_H_INCLUDED -#include -#include +#include +#include #include #include #include @@ -29,7 +29,7 @@ #include namespace beast { -namespace wsproto { +namespace websocket { // Synchronous WebSocket echo client/server // @@ -144,7 +144,7 @@ private: void do_peer(int id, socket_type&& sock) { - wsproto::socket ws(std::move(sock)); + websocket::stream ws(std::move(sock)); ws.set_option(decorate(identity{})); ws.set_option(read_message_max(64 * 1024 * 1024)); error_code ec; @@ -156,24 +156,24 @@ private: } for(;;) { - wsproto::opcode op; + websocket::opcode op; beast::streambuf sb; ws.read(op, sb, ec); if(ec) break; - ws.set_option(wsproto::message_type(op)); + ws.set_option(websocket::message_type(op)); ws.write(sb.data(), ec); if(ec) break; } - if(ec && ec != wsproto::error::closed) + if(ec && ec != websocket::error::closed) { fail(id, ec, "read"); } } }; -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/asio/async_completion.h b/src/beast/include/beast/async_completion.hpp similarity index 65% rename from src/beast/beast/asio/async_completion.h rename to src/beast/include/beast/async_completion.hpp index da9493ff1f..d4be5428c4 100644 --- a/src/beast/beast/asio/async_completion.h +++ b/src/beast/include/beast/async_completion.hpp @@ -1,26 +1,14 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_ASYNC_COMPLETION_HPP +#define BEAST_ASYNC_COMPLETION_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_ASYNC_COMPLETION_H_INLUDED -#define BEAST_ASIO_ASYNC_COMPLETION_H_INLUDED - -#include +#include #include #include #include diff --git a/src/beast/beast/asio/basic_streambuf.h b/src/beast/include/beast/basic_streambuf.hpp similarity index 86% rename from src/beast/beast/asio/basic_streambuf.h rename to src/beast/include/beast/basic_streambuf.hpp index e87999d1e7..9a65ce08d2 100644 --- a/src/beast/beast/asio/basic_streambuf.h +++ b/src/beast/include/beast/basic_streambuf.hpp @@ -1,26 +1,14 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_BASIC_STREAMBUF_HPP +#define BEAST_BASIC_STREAMBUF_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_BASIC_STREAMBUF_H_INCLUDED -#define BEAST_ASIO_BASIC_STREAMBUF_H_INCLUDED - -#include +#include #include #include #include @@ -42,7 +30,7 @@ namespace beast { template class basic_streambuf #if ! GENERATING_DOCS - : private empty_base_optimization< + : private detail::empty_base_optimization< typename std::allocator_traits:: template rebind_alloc> #endif @@ -345,6 +333,6 @@ to_string(basic_streambuf const& streambuf); } // beast -#include +#include #endif diff --git a/src/beast/beast/asio/bind_handler.h b/src/beast/include/beast/bind_handler.hpp similarity index 75% rename from src/beast/beast/asio/bind_handler.h rename to src/beast/include/beast/bind_handler.hpp index afa964a907..6cc6225f79 100644 --- a/src/beast/beast/asio/bind_handler.h +++ b/src/beast/include/beast/bind_handler.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_BIND_HANDLER_H_INCLUDED -#define BEAST_ASIO_BIND_HANDLER_H_INCLUDED +#ifndef BEAST_BIND_HANDLER_HPP +#define BEAST_BIND_HANDLER_HPP #include #include @@ -31,7 +19,7 @@ namespace beast { namespace detail { -/** Nullary handler that calls Handler with bound arguments. +/* Nullary handler that calls Handler with bound arguments. The bound handler provides the same io_service execution guarantees as the original handler. diff --git a/src/beast/beast/asio/append_buffers.h b/src/beast/include/beast/buffer_cat.hpp similarity index 80% rename from src/beast/beast/asio/append_buffers.h rename to src/beast/include/beast/buffer_cat.hpp index 297ca41396..40a556fdab 100644 --- a/src/beast/beast/asio/append_buffers.h +++ b/src/beast/include/beast/buffer_cat.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_APPEND_BUFFERS_H_INLUDED -#define BEAST_ASIO_APPEND_BUFFERS_H_INLUDED +#ifndef BEAST_BUFFER_CAT_HPP +#define BEAST_BUFFER_CAT_HPP #include #include @@ -33,7 +21,7 @@ namespace beast { namespace detail { template -class append_buffers_helper +class buffer_cat_helper { std::tuple bs_; @@ -42,13 +30,13 @@ public: class const_iterator; - append_buffers_helper(append_buffers_helper&&) = default; - append_buffers_helper(append_buffers_helper const&) = default; - append_buffers_helper& operator=(append_buffers_helper&&) = default; - append_buffers_helper& operator=(append_buffers_helper const&) = default; + buffer_cat_helper(buffer_cat_helper&&) = default; + buffer_cat_helper(buffer_cat_helper const&) = default; + buffer_cat_helper& operator=(buffer_cat_helper&&) = default; + buffer_cat_helper& operator=(buffer_cat_helper const&) = default; explicit - append_buffers_helper(Bs const&... bs) + buffer_cat_helper(Bs const&... bs) : bs_(bs...) { } @@ -77,7 +65,7 @@ max_sizeof() } template -class append_buffers_helper< +class buffer_cat_helper< ValueType, Bs...>::const_iterator { std::size_t n_; @@ -85,7 +73,7 @@ class append_buffers_helper< std::array()> buf_; - friend class append_buffers_helper; + friend class buffer_cat_helper; template using C = std::integral_constant; @@ -349,14 +337,14 @@ private: //------------------------------------------------------------------------------ template -append_buffers_helper:: +buffer_cat_helper:: const_iterator::~const_iterator() { destroy(C<0>{}); } template -append_buffers_helper:: +buffer_cat_helper:: const_iterator::const_iterator() : n_(sizeof...(Bs)) , bs_(nullptr) @@ -364,7 +352,7 @@ const_iterator::const_iterator() } template -append_buffers_helper:: +buffer_cat_helper:: const_iterator::const_iterator( std::tuple const& bs, bool at_end) : bs_(&bs) @@ -376,7 +364,7 @@ const_iterator::const_iterator( } template -append_buffers_helper:: +buffer_cat_helper:: const_iterator::const_iterator(const_iterator&& other) : n_(other.n_) , bs_(other.bs_) @@ -385,7 +373,7 @@ const_iterator::const_iterator(const_iterator&& other) } template -append_buffers_helper:: +buffer_cat_helper:: const_iterator::const_iterator(const_iterator const& other) : n_(other.n_) , bs_(other.bs_) @@ -395,7 +383,7 @@ const_iterator::const_iterator(const_iterator const& other) template auto -append_buffers_helper:: +buffer_cat_helper:: const_iterator::operator=(const_iterator&& other) -> const_iterator& { @@ -410,7 +398,7 @@ const_iterator::operator=(const_iterator&& other) -> template auto -append_buffers_helper:: +buffer_cat_helper:: const_iterator::operator=(const_iterator const& other) -> const_iterator& { @@ -425,7 +413,7 @@ const_iterator& template bool -append_buffers_helper:: +buffer_cat_helper:: const_iterator::operator==(const_iterator const& other) const { if(bs_ != other.bs_) @@ -437,7 +425,7 @@ const_iterator::operator==(const_iterator const& other) const template auto -append_buffers_helper:: +buffer_cat_helper:: const_iterator::operator*() const -> reference { @@ -446,7 +434,7 @@ const_iterator::operator*() const -> template auto -append_buffers_helper:: +buffer_cat_helper:: const_iterator::operator++() -> const_iterator& { @@ -456,7 +444,7 @@ const_iterator::operator++() -> template auto -append_buffers_helper:: +buffer_cat_helper:: const_iterator::operator--() -> const_iterator& { @@ -466,7 +454,7 @@ const_iterator::operator--() -> template auto -append_buffers_helper::begin() const -> +buffer_cat_helper::begin() const -> const_iterator { return const_iterator(bs_, false); @@ -474,7 +462,7 @@ append_buffers_helper::begin() const -> template auto -append_buffers_helper::end() const -> +buffer_cat_helper::end() const -> const_iterator { return const_iterator(bs_, true); @@ -500,14 +488,14 @@ append_buffers_helper::end() const -> #if GENERATING_DOCS template implementation_defined -append_buffers(BufferSequence const&... buffers) +buffer_cat(BufferSequence const&... buffers) #else template auto -append_buffers(B1 const& b1, B2 const& b2, Bn const&... bn) +buffer_cat(B1 const& b1, B2 const& b2, Bn const&... bn) #endif { - return detail::append_buffers_helper< + return detail::buffer_cat_helper< boost::asio::const_buffer, B1, B2, Bn...>(b1, b2, bn...); } diff --git a/src/beast/beast/asio/buffers_adapter.h b/src/beast/include/beast/buffers_adapter.hpp similarity index 92% rename from src/beast/beast/asio/buffers_adapter.h rename to src/beast/include/beast/buffers_adapter.hpp index a2212a7463..85856b140a 100644 --- a/src/beast/beast/asio/buffers_adapter.h +++ b/src/beast/include/beast/buffers_adapter.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_BUFFERS_ADAPTER_H_INLUDED -#define BEAST_ASIO_BUFFERS_ADAPTER_H_INLUDED +#ifndef BEAST_BUFFERS_ADAPTER_HPP +#define BEAST_BUFFERS_ADAPTER_HPP #include #include diff --git a/src/beast/include/beast/buffers_debug.hpp b/src/beast/include/beast/buffers_debug.hpp new file mode 100644 index 0000000000..b25349f9d4 --- /dev/null +++ b/src/beast/include/beast/buffers_debug.hpp @@ -0,0 +1,39 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_BUFFERS_DEBUG_HPP +#define BEAST_BUFFERS_DEBUG_HPP + +#include +#include + +namespace beast { +namespace debug { + +template +std::string +buffers_to_string(Buffers const& bs) +{ + using boost::asio::buffer_cast; + using boost::asio::buffer_size; + std::string s; + s.reserve(buffer_size(bs)); + for(auto const& b : bs) + s.append(buffer_cast(b), + buffer_size(b)); + for(auto i = s.size(); i-- > 0;) + if(s[i] == '\r') + s.replace(i, 1, "\\r"); + else if(s[i] == '\n') + s.replace(i, 1, "\\n\n"); + return s; +} + +} // debug +} // beast + +#endif diff --git a/src/beast/beast/asio/consuming_buffers.h b/src/beast/include/beast/consuming_buffers.hpp similarity index 85% rename from src/beast/beast/asio/consuming_buffers.h rename to src/beast/include/beast/consuming_buffers.hpp index f20ad7fa7f..57d34f0ee3 100644 --- a/src/beast/beast/asio/consuming_buffers.h +++ b/src/beast/include/beast/consuming_buffers.hpp @@ -1,26 +1,14 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_CONSUMING_BUFFERS_HPP +#define BEAST_CONSUMING_BUFFERS_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_CONSUMING_BUFFERS_H_INLUDED -#define BEAST_ASIO_CONSUMING_BUFFERS_H_INLUDED - -#include +#include #include #include #include diff --git a/src/beast/beast/crypto/base64.h b/src/beast/include/beast/detail/base64.hpp similarity index 75% rename from src/beast/beast/crypto/base64.h rename to src/beast/include/beast/detail/base64.hpp index 4f2ecbba1d..0256aa7d0b 100644 --- a/src/beast/beast/crypto/base64.h +++ b/src/beast/include/beast/detail/base64.hpp @@ -1,29 +1,18 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_CRYPTO_BASE64_H_INCLUDED -#define BEAST_CRYPTO_BASE64_H_INCLUDED +#ifndef BEAST_DETAIL_BASE64_HPP +#define BEAST_DETAIL_BASE64_HPP #include #include namespace beast { +namespace detail { /* Portions from http://www.adp-gmbh.ch/cpp/common/base64.html @@ -150,7 +139,8 @@ base64_decode(std::string const& data) c4[i++] = data[in_]; in_++; if(i == 4) { for(i = 0; i < 4; i++) - c4[i] = base64_alphabet().find(c4[i]); + c4[i] = static_cast( + base64_alphabet().find(c4[i])); c3[0] = (c4[0] << 2) + ((c4[1] & 0x30) >> 4); c3[1] = ((c4[1] & 0xf) << 4) + ((c4[2] & 0x3c) >> 2); @@ -168,7 +158,8 @@ base64_decode(std::string const& data) c4[j] = 0; for(j = 0; j < 4; j++) - c4[j] = base64_alphabet().find(c4[j]); + c4[j] = static_cast( + base64_alphabet().find(c4[j])); c3[0] = (c4[0] << 2) + ((c4[1] & 0x30) >> 4); c3[1] = ((c4[1] & 0xf) << 4) + ((c4[2] & 0x3c) >> 2); @@ -181,6 +172,7 @@ base64_decode(std::string const& data) return ret; } -} +} // detail +} // beast #endif diff --git a/src/beast/beast/ci_char_traits.h b/src/beast/include/beast/detail/ci_char_traits.hpp similarity index 56% rename from src/beast/beast/ci_char_traits.h rename to src/beast/include/beast/detail/ci_char_traits.hpp index 9d958a8ebe..0e4d6377e2 100644 --- a/src/beast/beast/ci_char_traits.h +++ b/src/beast/include/beast/detail/ci_char_traits.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UTILITY_CI_CHAR_TRAITS_H_INCLUDED -#define BEAST_UTILITY_CI_CHAR_TRAITS_H_INCLUDED +#ifndef BEAST_DETAIL_CI_CHAR_TRAITS_HPP +#define BEAST_DETAIL_CI_CHAR_TRAITS_HPP #include #include @@ -29,6 +17,7 @@ #include namespace beast { +namespace detail { /** Case-insensitive function object for performing less than comparisons. */ struct ci_less @@ -51,8 +40,6 @@ struct ci_less } }; -namespace detail { - inline bool ci_equal(std::pair lhs, @@ -82,19 +69,16 @@ view(std::string const& s) return {s.data(), s.size()}; } -} - /** Returns `true` if strings are case-insensitive equal. */ template inline bool ci_equal(String1 const& lhs, String2 const& rhs) { - using detail::view; - using detail::ci_equal; return ci_equal(view(lhs), view(rhs)); } -} +} // detail +} // beast #endif diff --git a/src/beast/beast/unit_test/const_container.h b/src/beast/include/beast/detail/const_container.hpp similarity index 55% rename from src/beast/beast/unit_test/const_container.h rename to src/beast/include/beast/detail/const_container.hpp index 2bf093c738..72f2c32bee 100644 --- a/src/beast/beast/unit_test/const_container.h +++ b/src/beast/include/beast/detail/const_container.hpp @@ -1,26 +1,15 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_CONST_CONTAINER_H_INCLUDED -#define BEAST_UNIT_TEST_CONST_CONTAINER_H_INCLUDED +#ifndef BEAST_DETAIL_CONST_CONTAINER_HPP +#define BEAST_DETAIL_CONST_CONTAINER_HPP namespace beast { +namespace detail { /** Adapter to constrain a container interface. The interface allows for limited read only operations. Derived classes @@ -94,6 +83,7 @@ public: /** @} */ }; +} // detail } // beast #endif diff --git a/src/beast/include/beast/detail/empty_base_optimization.hpp b/src/beast/include/beast/detail/empty_base_optimization.hpp new file mode 100644 index 0000000000..1be8ccde4b --- /dev/null +++ b/src/beast/include/beast/detail/empty_base_optimization.hpp @@ -0,0 +1,94 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_DETAIL_EMPTY_BASE_OPTIMIZATION_HPP +#define BEAST_DETAIL_EMPTY_BASE_OPTIMIZATION_HPP + +#include +#include + +namespace beast { +namespace detail { + +template +struct empty_base_optimization_decide + : std::integral_constant ::value +#ifdef __clang__ + && !__is_final(T) +#endif + > +{ +}; + +template < + class T, + int UniqueID = 0, + bool ShouldDeriveFrom = + empty_base_optimization_decide::value +> +class empty_base_optimization : private T +{ +public: + empty_base_optimization() = default; + + empty_base_optimization(T const& t) + : T (t) + {} + + empty_base_optimization(T&& t) + : T (std::move (t)) + {} + + T& member() noexcept + { + return *this; + } + + T const& member() const noexcept + { + return *this; + } +}; + +//------------------------------------------------------------------------------ + +template < + class T, + int UniqueID +> +class empty_base_optimization +{ +public: + empty_base_optimization() = default; + + empty_base_optimization(T const& t) + : m_t (t) + {} + + empty_base_optimization(T&& t) + : m_t (std::move (t)) + {} + + T& member() noexcept + { + return m_t; + } + + T const& member() const noexcept + { + return m_t; + } + +private: + T m_t; +}; + +} // detail +} // beast + +#endif diff --git a/src/beast/beast/is_call_possible.h b/src/beast/include/beast/detail/is_call_possible.hpp similarity index 57% rename from src/beast/beast/is_call_possible.h rename to src/beast/include/beast/detail/is_call_possible.hpp index 5c18bc3b1f..c14dbd3482 100644 --- a/src/beast/beast/is_call_possible.h +++ b/src/beast/include/beast/detail/is_call_possible.hpp @@ -1,29 +1,16 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_IS_CALL_POSSIBLE_H_INCLUDED -#define BEAST_IS_CALL_POSSIBLE_H_INCLUDED +#ifndef BEAST_DETAIL_IS_CALL_POSSIBLE_HPP +#define BEAST_DETAIL_IS_CALL_POSSIBLE_HPP #include namespace beast { - namespace detail { template @@ -38,8 +25,6 @@ template std::false_type is_call_possible_test(C&& c, long, A&& ...a); -} // detail - /** Metafunction returns `true` if F callable as R(A...) Example: is_call_possible @@ -53,7 +38,7 @@ struct is_call_possible template struct is_call_possible - : decltype(detail::is_call_possible_test( + : decltype(is_call_possible_test( std::declval(), 1, std::declval()...)) { }; @@ -96,8 +81,10 @@ static_assert(is_call_possible< static_assert(! is_call_possible< is_call_possible_udt3 const, int(int)>::value, ""); -} -} +} // test + +} // detail +} // beast #endif diff --git a/src/beast/beast/crypto/detail/sha_context.h b/src/beast/include/beast/detail/sha1.hpp similarity index 86% rename from src/beast/beast/crypto/detail/sha_context.h rename to src/beast/include/beast/detail/sha1.hpp index 482df01d82..c34b1bb8bc 100644 --- a/src/beast/beast/crypto/detail/sha_context.h +++ b/src/beast/include/beast/detail/sha1.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_CRYPTO_SHA_CONTEXT_H_INCLUDED -#define BEAST_CRYPTO_SHA_CONTEXT_H_INCLUDED +#ifndef BEAST_DETAIL_SHA1_HPP +#define BEAST_DETAIL_SHA1_HPP #include #include @@ -228,7 +216,7 @@ transform( } // sha1 -struct sha_context +struct sha1_context { static unsigned int const block_size = sha1::BLOCK_BYTES; static unsigned int const digest_size = 20; @@ -241,7 +229,7 @@ struct sha_context template void -init(sha_context& ctx) noexcept +init(sha1_context& ctx) noexcept { ctx.buflen = 0; ctx.digest[0] = 0x67452301; @@ -254,7 +242,7 @@ init(sha_context& ctx) noexcept template void -update(sha_context& ctx, +update(sha1_context& ctx, void const* message, std::size_t size) noexcept { auto p = reinterpret_cast< @@ -279,7 +267,7 @@ update(sha_context& ctx, template void -finish(sha_context& ctx, void* digest) noexcept +finish(sha1_context& ctx, void* digest) noexcept { using sha1::BLOCK_INTS; using sha1::BLOCK_BYTES; diff --git a/src/beast/include/beast/detail/stream/abstract_ostream.hpp b/src/beast/include/beast/detail/stream/abstract_ostream.hpp new file mode 100644 index 0000000000..43a3c22373 --- /dev/null +++ b/src/beast/include/beast/detail/stream/abstract_ostream.hpp @@ -0,0 +1,22 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_DETAIL_STREAM_ABSTRACT_OSTREAM_HPP +#define BEAST_DETAIL_STREAM_ABSTRACT_OSTREAM_HPP + +#include + +namespace beast { +namespace detail { + +/** An abstract ostream for `char`. */ +using abstract_ostream = basic_abstract_ostream ; + +} // detail +} // beast + +#endif diff --git a/src/beast/beast/streams/basic_abstract_ostream.h b/src/beast/include/beast/detail/stream/basic_abstract_ostream.hpp similarity index 55% rename from src/beast/beast/streams/basic_abstract_ostream.h rename to src/beast/include/beast/detail/stream/basic_abstract_ostream.hpp index 82341b7880..098886a2a8 100644 --- a/src/beast/beast/streams/basic_abstract_ostream.h +++ b/src/beast/include/beast/detail/stream/basic_abstract_ostream.hpp @@ -1,32 +1,20 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_STREAMS_BASIC_ABSTRACT_OSTREAM_H_INCLUDED -#define BEAST_STREAMS_BASIC_ABSTRACT_OSTREAM_H_INCLUDED - -#include +#ifndef BEAST_DETAIL_STREAM_BASIC_ABSTRACT_OSTREAM_HPP +#define BEAST_DETAIL_STREAM_BASIC_ABSTRACT_OSTREAM_HPP +#include #include #include #include namespace beast { +namespace detail { /** Abstraction for an output stream similar to std::basic_ostream. */ template < @@ -93,6 +81,7 @@ public: } }; -} +} // detail +} // beast #endif diff --git a/src/beast/beast/streams/basic_scoped_ostream.h b/src/beast/include/beast/detail/stream/basic_scoped_ostream.hpp similarity index 69% rename from src/beast/beast/streams/basic_scoped_ostream.h rename to src/beast/include/beast/detail/stream/basic_scoped_ostream.hpp index e645334ac5..fcd34d6b61 100644 --- a/src/beast/beast/streams/basic_scoped_ostream.h +++ b/src/beast/include/beast/detail/stream/basic_scoped_ostream.hpp @@ -1,26 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_STREAMS_BASIC_SCOPED_OSTREAM_H_INCLUDED -#define BEAST_STREAMS_BASIC_SCOPED_OSTREAM_H_INCLUDED - -#include +#ifndef BEAST_DETAIL_STREAM_BASIC_SCOPED_OSTREAM_HPP +#define BEAST_DETAIL_STREAM_BASIC_SCOPED_OSTREAM_HPP #include #include @@ -38,6 +24,7 @@ #endif namespace beast { +namespace detail { template < class CharT, @@ -145,6 +132,7 @@ public: } }; -} +} // detail +} // beast #endif diff --git a/src/beast/include/beast/detail/stream/basic_std_ostream.hpp b/src/beast/include/beast/detail/stream/basic_std_ostream.hpp new file mode 100644 index 0000000000..9173421214 --- /dev/null +++ b/src/beast/include/beast/detail/stream/basic_std_ostream.hpp @@ -0,0 +1,62 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_DETAIL_STREAM_BASIC_STD_OSTREAM_H_INCLUDED +#define BEAST_DETAIL_STREAM_BASIC_STD_OSTREAM_H_INCLUDED + +#include +#include + +namespace beast { +namespace detail { + +/** Wraps an existing std::basic_ostream as an abstract_ostream. */ +template < + class CharT, + class Traits = std::char_traits +> +class basic_std_ostream + : public basic_abstract_ostream +{ +private: + using typename basic_abstract_ostream ::string_type; + + std::reference_wrapper m_stream; + +public: + explicit basic_std_ostream ( + std::basic_ostream & stream) + : m_stream (stream) + { + } + + void + write (string_type const& s) override + { + m_stream.get() << s << std::endl; + } +}; + +using std_ostream = basic_std_ostream ; + +//------------------------------------------------------------------------------ + +/** Returns a basic_std_ostream using template argument deduction. */ +template < + class CharT, + class Traits = std::char_traits +> +basic_std_ostream +make_std_ostream (std::basic_ostream & stream) +{ + return basic_std_ostream (stream); +} + +} // detail +} // beast + +#endif diff --git a/src/beast/include/beast/detail/stream/debug_ostream.hpp b/src/beast/include/beast/detail/stream/debug_ostream.hpp new file mode 100644 index 0000000000..1f3bc4653e --- /dev/null +++ b/src/beast/include/beast/detail/stream/debug_ostream.hpp @@ -0,0 +1,80 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_DETAIL_STREAM_DEBUG_OSTREAM_HPP +#define BEAST_DETAIL_STREAM_DEBUG_OSTREAM_HPP + +#include +#include + +#ifdef _MSC_VER +# ifndef WIN32_LEAN_AND_MEAN // VC_EXTRALEAN +# define WIN32_LEAN_AND_MEAN +#include +# undef WIN32_LEAN_AND_MEAN +# else +#include +# endif +# ifdef min +# undef min +# endif +# ifdef max +# undef max +# endif +#endif + +namespace beast { +namespace detail { + +#ifdef _MSC_VER +/** A basic_abstract_ostream that redirects output to an attached debugger. */ +class debug_ostream + : public abstract_ostream +{ +private: + bool m_debugger; + +public: + debug_ostream() + : m_debugger (IsDebuggerPresent() != FALSE) + { + // Note that the check for an attached debugger is made only + // during construction time, for efficiency. A stream created before + // the debugger is attached will not have output redirected. + } + + void + write (string_type const& s) override + { + if (m_debugger) + { + OutputDebugStringA ((s + "\n").c_str()); + return; + } + + std::cout << s << std::endl; + } +}; + +#else +class debug_ostream + : public abstract_ostream +{ +public: + void + write (string_type const& s) override + { + std::cout << s << std::endl; + } +}; + +#endif + +} // detail +} // beast + +#endif diff --git a/src/beast/beast/unit_test/temp_dir.h b/src/beast/include/beast/detail/temp_dir.hpp similarity index 51% rename from src/beast/beast/unit_test/temp_dir.h rename to src/beast/include/beast/detail/temp_dir.hpp index 030dcfcbe6..54a0d905a0 100644 --- a/src/beast/beast/unit_test/temp_dir.h +++ b/src/beast/include/beast/detail/temp_dir.hpp @@ -1,29 +1,18 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNITTEST_TEMP_DIR_H_INCLUDED -#define BEAST_UNITTEST_TEMP_DIR_H_INCLUDED +#ifndef BEAST_DETAIL_TEMP_DIR_H_INCLUDED +#define BEAST_DETAIL_TEMP_DIR_H_INCLUDED #include #include namespace beast { +namespace detail { /** RAII temporary directory. @@ -78,6 +67,7 @@ public: } }; +} // detail } // beast #endif diff --git a/src/beast/include/beast/detail/unit_test.h b/src/beast/include/beast/detail/unit_test.h new file mode 100644 index 0000000000..a53379e0ba --- /dev/null +++ b/src/beast/include/beast/detail/unit_test.h @@ -0,0 +1,23 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_DETAIL_UNIT_TEST_H_INCLUDED +#define BEAST_DETAIL_UNIT_TEST_H_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/src/beast/include/beast/detail/unit_test/amount.hpp b/src/beast/include/beast/detail/unit_test/amount.hpp new file mode 100644 index 0000000000..c07b4cad0e --- /dev/null +++ b/src/beast/include/beast/detail/unit_test/amount.hpp @@ -0,0 +1,59 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_DETAIL_UNIT_TEST_AMOUNT_HPP +#define BEAST_DETAIL_UNIT_TEST_AMOUNT_HPP + +#include +#include +#include + +namespace beast { +namespace detail { + +inline +namespace unit_test { + +/** Utility for producing nicely composed output of amounts with units. */ +class amount +{ +private: + std::size_t n_; + std::string const& what_; + +public: + amount (amount const&) = default; + amount& operator= (amount const&) = delete; + + template + amount (std::size_t n, std::string const& what); + + friend + std::ostream& + operator<< (std::ostream& s, amount const& t); +}; + +template +amount::amount (std::size_t n, std::string const& what) + : n_ (n) + , what_ (what) +{ +} + +inline +std::ostream& +operator<< (std::ostream& s, amount const& t) +{ + s << t.n_ << " " << t.what_ << ((t.n_ != 1) ? "s" : ""); + return s; +} + +} // unit_test +} // detail +} // beast + +#endif diff --git a/src/beast/beast/unit_test/define_print.cpp b/src/beast/include/beast/detail/unit_test/define_print.cpp similarity index 52% rename from src/beast/beast/unit_test/define_print.cpp rename to src/beast/include/beast/detail/unit_test/define_print.cpp index 27e2c2d7a7..6540d4dcac 100644 --- a/src/beast/beast/unit_test/define_print.cpp +++ b/src/beast/include/beast/detail/unit_test/define_print.cpp @@ -1,30 +1,21 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include +#include +#include +#include #include // Include this .cpp in your project to gain access to the printing suite namespace beast { +namespace detail { + +inline namespace unit_test { namespace detail { @@ -93,6 +84,7 @@ print_test::print (suite_list &c) BEAST_DEFINE_TESTSUITE_MANUAL(print,unit_test,beast); -} -} -} +} // detail +} // unit_test +} // detail +} // beast diff --git a/src/beast/include/beast/detail/unit_test/global_suites.hpp b/src/beast/include/beast/detail/unit_test/global_suites.hpp new file mode 100644 index 0000000000..c7a7d8a376 --- /dev/null +++ b/src/beast/include/beast/detail/unit_test/global_suites.hpp @@ -0,0 +1,60 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_DETAIL_UNIT_TEST_GLOBAL_SUITES_HPP +#define BEAST_DETAIL_UNIT_TEST_GLOBAL_SUITES_HPP + +#include + +namespace beast { +namespace detail { + +inline +namespace unit_test { + +namespace detail { + +template +suite_list& +global_suites() +{ + static suite_list s; + return s; +} + +template +struct insert_suite +{ + template + insert_suite (char const* name, char const* module, + char const* library, bool manual); +}; + +template +template +insert_suite::insert_suite (char const* name, + char const* module, char const* library, bool manual) +{ + global_suites().insert ( + name, module, library, manual); +} + +} // detail + +/** Holds suites registered during static initialization. */ +inline +suite_list const& +global_suites() +{ + return detail::global_suites(); +} + +} // unit_test +} // detail +} // beast + +#endif diff --git a/src/beast/beast/unit_test/match.h b/src/beast/include/beast/detail/unit_test/match.hpp similarity index 73% rename from src/beast/beast/unit_test/match.h rename to src/beast/include/beast/detail/unit_test/match.hpp index cc9b2b0140..664bae8a1f 100644 --- a/src/beast/beast/unit_test/match.h +++ b/src/beast/include/beast/detail/unit_test/match.hpp @@ -1,28 +1,20 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_DETAIL_UNIT_TEST_MATCH_HPP +#define BEAST_DETAIL_UNIT_TEST_MATCH_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_MATCH_H_INCLUDED -#define BEAST_UNIT_TEST_MATCH_H_INCLUDED - -#include +#include +#include namespace beast { +namespace detail { + +inline namespace unit_test { // Predicate for implementing matches @@ -179,6 +171,7 @@ match_library (std::string const& name) } } // unit_test +} // detail } // beast #endif diff --git a/src/beast/include/beast/detail/unit_test/print.hpp b/src/beast/include/beast/detail/unit_test/print.hpp new file mode 100644 index 0000000000..04957db594 --- /dev/null +++ b/src/beast/include/beast/detail/unit_test/print.hpp @@ -0,0 +1,71 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_DETAIL_UNIT_TEST_PRINT_H_INCLUDED +#define BEAST_DETAIL_UNIT_TEST_PRINT_H_INCLUDED + +#include +#include +#include +#include + +#include +#include + +namespace beast { +namespace detail { + +inline +namespace unit_test { + +/** Write test results to the specified output stream. */ +/** @{ */ +template +void +print (results const& r, beast::detail::abstract_ostream& stream) +{ + for (auto const& s : r) + { + for (auto const& c : s) + { + stream << + s.name() << + (c.name().empty() ? "" : ("." + c.name())); + + std::size_t i (1); + for (auto const& t : c.tests) + { + if (! t.pass) + stream << + "#" << i << + " failed: " << t.reason; + ++i; + } + } + } + + stream << + amount (r.size(), "suite") << ", " << + amount (r.cases(), "case") << ", " << + amount (r.total(), "test") << " total, " << + amount (r.failed(), "failure") + ; +} + +template +void +print (results const& r, std::ostream& stream = std::cout) +{ + auto s (make_std_ostream (stream)); + print (r, s); +} + +} // unit_test +} // detail +} // beast + +#endif diff --git a/src/beast/beast/unit_test/recorder.h b/src/beast/include/beast/detail/unit_test/recorder.hpp similarity index 52% rename from src/beast/beast/unit_test/recorder.h rename to src/beast/include/beast/detail/unit_test/recorder.hpp index b066e0cffc..8c711cf8c1 100644 --- a/src/beast/beast/unit_test/recorder.h +++ b/src/beast/include/beast/detail/unit_test/recorder.hpp @@ -1,29 +1,20 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_DETAIL_UNIT_TEST_RECORDER_HPP +#define BEAST_DETAIL_UNIT_TEST_RECORDER_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_RECORDER_H_INCLUDED -#define BEAST_UNIT_TEST_RECORDER_H_INCLUDED - -#include -#include +#include +#include namespace beast { +namespace detail { + +inline namespace unit_test { /** A test runner that stores the results. */ @@ -99,6 +90,7 @@ private: }; } // unit_test +} // detail } // beast #endif diff --git a/src/beast/beast/unit_test/reporter.h b/src/beast/include/beast/detail/unit_test/reporter.hpp similarity index 80% rename from src/beast/beast/unit_test/reporter.h rename to src/beast/include/beast/detail/unit_test/reporter.hpp index e9952058e8..93a0f9606b 100644 --- a/src/beast/beast/unit_test/reporter.h +++ b/src/beast/include/beast/detail/unit_test/reporter.hpp @@ -1,29 +1,17 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_DETAIL_UNIT_TEST_REPORTER_HPP +#define BEAST_DETAIL_UNIT_TEST_REPORTER_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_REPORTER_H_INCLUDED -#define BEAST_UNIT_TEST_REPORTER_H_INCLUDED - -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -35,6 +23,9 @@ #include namespace beast { +namespace detail { + +inline namespace unit_test { namespace detail { @@ -96,7 +87,7 @@ private: }; boost::optional std_ostream_; - std::reference_wrapper stream_; + std::reference_wrapper stream_; results results_; suite_results suite_results_; case_results case_results_; @@ -111,7 +102,7 @@ public: reporter (std::ostream& stream = std::cout); explicit - reporter (abstract_ostream& stream); + reporter (beast::detail::abstract_ostream& stream); private: static @@ -238,7 +229,7 @@ reporter<_>::~reporter() template reporter<_>::reporter ( - abstract_ostream& stream) + beast::detail::abstract_ostream& stream) : stream_ (stream) { } @@ -327,6 +318,7 @@ reporter<_>::on_log ( using reporter = detail::reporter<>; } // unit_test +} // detail } // beast #endif diff --git a/src/beast/beast/unit_test/results.h b/src/beast/include/beast/detail/unit_test/results.hpp similarity index 79% rename from src/beast/beast/unit_test/results.h rename to src/beast/include/beast/detail/unit_test/results.hpp index 125b897020..75231fa806 100644 --- a/src/beast/beast/unit_test/results.h +++ b/src/beast/include/beast/detail/unit_test/results.hpp @@ -1,31 +1,22 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_DETAIL_UNIT_TEST_RESULTS_HPP +#define BEAST_DETAIL_UNIT_TEST_RESULTS_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_RESULTS_H_INCLUDED -#define BEAST_UNIT_TEST_RESULTS_H_INCLUDED - -#include +#include #include #include namespace beast { +namespace detail { + +inline namespace unit_test { /** Holds a set of test condition outcomes in a testcase. */ @@ -249,6 +240,7 @@ public: }; } // unit_test +} // detail } // beast #endif diff --git a/src/beast/beast/unit_test/runner.h b/src/beast/include/beast/detail/unit_test/runner.hpp similarity index 83% rename from src/beast/beast/unit_test/runner.h rename to src/beast/include/beast/detail/unit_test/runner.hpp index 164770f628..6f46774557 100644 --- a/src/beast/beast/unit_test/runner.h +++ b/src/beast/include/beast/detail/unit_test/runner.hpp @@ -1,32 +1,23 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_DETAIL_UNIT_TEST_RUNNER_H_INCLUDED +#define BEAST_DETAIL_UNIT_TEST_RUNNER_H_INCLUDED - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_RUNNER_H_INCLUDED -#define BEAST_UNIT_TEST_RUNNER_H_INCLUDED - -#include -#include +#include +#include #include #include #include namespace beast { +namespace detail { + +inline namespace unit_test { /** Unit test runner interface. @@ -37,7 +28,7 @@ class runner { private: // Reroutes log output to the runner - class stream_t : public abstract_ostream + class stream_t : public beast::detail::abstract_ostream { private: runner& owner_; @@ -341,6 +332,7 @@ runner::log (std::string const& s) } } // unit_test +} // detail } // beast #endif diff --git a/src/beast/beast/unit_test/suite.h b/src/beast/include/beast/detail/unit_test/suite.hpp similarity index 90% rename from src/beast/beast/unit_test/suite.h rename to src/beast/include/beast/detail/unit_test/suite.hpp index f3e0aa585c..3732224ed3 100644 --- a/src/beast/beast/unit_test/suite.h +++ b/src/beast/include/beast/detail/unit_test/suite.hpp @@ -1,30 +1,21 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_DETAIL_UNIT_TEST_SUITE_HPP +#define BEAST_DETAIL_UNIT_TEST_SUITE_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_SUITE_H_INCLUDED -#define BEAST_UNIT_TEST_SUITE_H_INCLUDED - -#include +#include #include #include namespace beast { +namespace detail { + +inline namespace unit_test { class thread; @@ -546,6 +537,7 @@ suite::run (runner& r) } } // unit_test +} // detail } // beast //------------------------------------------------------------------------------ @@ -553,7 +545,7 @@ suite::run (runner& r) // detail: // This inserts the suite with the given manual flag #define BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,manual) \ - static beast::unit_test::detail::insert_suite \ + static beast::detail::unit_test::detail::insert_suite \ Library ## Module ## Class ## _test_instance ( \ #Class, #Module, #Library, manual); @@ -601,7 +593,7 @@ suite::run (runner& r) #define BEAST_DEFINE_TESTSUITE(Class,Module,Library) #else -#include +#include #define BEAST_DEFINE_TESTSUITE(Class,Module,Library) \ BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,false) #define BEAST_DEFINE_TESTSUITE_MANUAL(Class,Module,Library) \ diff --git a/src/beast/beast/unit_test/suite_info.h b/src/beast/include/beast/detail/unit_test/suite_info.hpp similarity index 64% rename from src/beast/beast/unit_test/suite_info.h rename to src/beast/include/beast/detail/unit_test/suite_info.hpp index 94ba5cc8c1..2176bb829f 100644 --- a/src/beast/beast/unit_test/suite_info.h +++ b/src/beast/include/beast/detail/unit_test/suite_info.hpp @@ -1,30 +1,21 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_SUITE_INFO_H_INCLUDED -#define BEAST_UNIT_TEST_SUITE_INFO_H_INCLUDED +#ifndef BEAST_DETAIL_UNIT_TEST_SUITE_INFO_HPP +#define BEAST_DETAIL_UNIT_TEST_SUITE_INFO_HPP #include #include #include namespace beast { +namespace detail { + +inline namespace unit_test { class runner; @@ -122,6 +113,7 @@ make_suite_info (std::string const& name, std::string const& module, } } // unit_test +} // detail } // beast #endif diff --git a/src/beast/beast/unit_test/suite_list.h b/src/beast/include/beast/detail/unit_test/suite_list.hpp similarity index 51% rename from src/beast/beast/unit_test/suite_list.h rename to src/beast/include/beast/detail/unit_test/suite_list.hpp index b552d4e36c..1393d406ad 100644 --- a/src/beast/beast/unit_test/suite_list.h +++ b/src/beast/include/beast/detail/unit_test/suite_list.hpp @@ -1,33 +1,24 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_DETAIL_UNIT_TEST_SUITE_LIST_HPP +#define BEAST_DETAIL_UNIT_TEST_SUITE_LIST_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_SUITE_LIST_H_INCLUDED -#define BEAST_UNIT_TEST_SUITE_LIST_H_INCLUDED - -#include -#include +#include +#include #include #include #include #include namespace beast { +namespace detail { + +inline namespace unit_test { /** A container of test suites. */ @@ -77,6 +68,7 @@ suite_list::insert (char const* name, char const* module, char const* library, } } // unit_test +} // detail } // beast #endif diff --git a/src/beast/beast/unit_test/thread.h b/src/beast/include/beast/detail/unit_test/thread.hpp similarity index 63% rename from src/beast/beast/unit_test/thread.h rename to src/beast/include/beast/detail/unit_test/thread.hpp index 90e6fb3d2b..a684abd3b6 100644 --- a/src/beast/beast/unit_test/thread.h +++ b/src/beast/include/beast/detail/unit_test/thread.hpp @@ -1,31 +1,22 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_DETAIL_UNIT_TEST_THREAD_HPP +#define BEAST_DETAIL_UNIT_TEST_THREAD_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_UNIT_TEST_THREAD_H_INCLUDED -#define BEAST_UNIT_TEST_THREAD_H_INCLUDED - -#include +#include #include #include #include namespace beast { +namespace detail { + +inline namespace unit_test { /** Replacement for std::thread that handles exceptions in unit tests. */ @@ -131,6 +122,7 @@ private: }; } // unit_test +} // detail } // beast #endif diff --git a/src/beast/beast/asio/handler_alloc.h b/src/beast/include/beast/handler_alloc.hpp similarity index 70% rename from src/beast/beast/asio/handler_alloc.h rename to src/beast/include/beast/handler_alloc.hpp index d76f62d993..afde93e9df 100644 --- a/src/beast/beast/asio/handler_alloc.h +++ b/src/beast/include/beast/handler_alloc.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_HANDLER_ALLOC_H_INCLUDED -#define BEAST_ASIO_HANDLER_ALLOC_H_INCLUDED +#ifndef BEAST_HANDLER_ALLOC_HPP +#define BEAST_HANDLER_ALLOC_HPP #include #include diff --git a/src/beast/include/beast/http.hpp b/src/beast/include/beast/http.hpp new file mode 100644 index 0000000000..591c32bb05 --- /dev/null +++ b/src/beast/include/beast/http.hpp @@ -0,0 +1,29 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_HTTP_HPP_INCLUDED +#define BEAST_HTTP_HPP_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif diff --git a/src/beast/beast/http/basic_headers.h b/src/beast/include/beast/http/basic_headers.hpp similarity index 86% rename from src/beast/beast/http/basic_headers.h rename to src/beast/include/beast/http/basic_headers.hpp index b10390e8eb..cf1f775306 100644 --- a/src/beast/beast/http/basic_headers.h +++ b/src/beast/include/beast/http/basic_headers.hpp @@ -1,29 +1,17 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_BASIC_HEADERS_HPP +#define BEAST_HTTP_BASIC_HEADERS_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_BASIC_HEADERS_H_INCLUDED -#define BEAST_HTTP_BASIC_HEADERS_H_INCLUDED - -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -32,7 +20,7 @@ #include #include #include -#include // +#include #include namespace beast { @@ -92,7 +80,7 @@ protected: } }; - struct less : private ci_less + struct less : private beast::detail::ci_less { template bool @@ -111,7 +99,7 @@ protected: bool operator()(element const& lhs, element const& rhs) const { - return beast::ci_less::operator()( + return ci_less::operator()( lhs.data.first, rhs.data.first); } }; @@ -257,7 +245,7 @@ public: template class basic_headers #if ! GENERATING_DOCS - : private empty_base_optimization< + : private beast::detail::empty_base_optimization< typename std::allocator_traits:: template rebind_alloc< detail::basic_headers_base::element>> diff --git a/src/beast/beast/http/basic_parser.h b/src/beast/include/beast/http/basic_parser.hpp similarity index 89% rename from src/beast/beast/http/basic_parser.h rename to src/beast/include/beast/http/basic_parser.hpp index 85301a5beb..494083ce26 100644 --- a/src/beast/beast/http/basic_parser.h +++ b/src/beast/include/beast/http/basic_parser.hpp @@ -1,33 +1,21 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_BASIC_PARSER_HPP +#define BEAST_HTTP_BASIC_PARSER_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_BASIC_PARSER_H_INCLUDED -#define BEAST_HTTP_BASIC_PARSER_H_INCLUDED - -#include -#include -#include +#include +#include +#include #include #include #include #include -#include // +#include namespace beast { namespace http { @@ -265,7 +253,7 @@ private: }; template using has_on_start = - std::bool_constant::value>; + std::integral_constant::value>; void call_on_start(std::true_type) @@ -295,7 +283,7 @@ private: }; template using has_on_field = - std::bool_constant::value>; + std::integral_constant::value>; void call_on_field(std::string const& field, @@ -325,7 +313,7 @@ private: }; template using has_on_headers_complete = - std::bool_constant::value>; + std::integral_constant::value>; void call_on_headers_complete(error_code& ec, std::true_type) @@ -356,7 +344,7 @@ private: }; template using has_on_request = - std::bool_constant::value>; + std::integral_constant::value>; void call_on_request(method_t method, std::string url, @@ -396,7 +384,7 @@ private: }; template using has_on_response = - std::bool_constant::value>; + std::integral_constant::value>; bool call_on_response(int status, std::string text, @@ -431,7 +419,7 @@ private: }; template using has_on_body = - std::bool_constant::value>; + std::integral_constant::value>; void call_on_body(void const* data, std::size_t bytes, @@ -460,7 +448,7 @@ private: }; template using has_on_complete = - std::bool_constant::value>; + std::integral_constant::value>; void call_on_complete(std::true_type) diff --git a/src/beast/beast/http/chunk_encode.h b/src/beast/include/beast/http/chunk_encode.hpp similarity index 85% rename from src/beast/beast/http/chunk_encode.h rename to src/beast/include/beast/http/chunk_encode.hpp index 608dad32d2..15ae2a427a 100644 --- a/src/beast/beast/http/chunk_encode.h +++ b/src/beast/include/beast/http/chunk_encode.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_CHUNK_ENCODE_H_INCLUDED -#define BEAST_HTTP_CHUNK_ENCODE_H_INCLUDED +#ifndef BEAST_HTTP_CHUNK_ENCODE_HPP +#define BEAST_HTTP_CHUNK_ENCODE_HPP #include #include diff --git a/src/beast/beast/http/detail/error.h b/src/beast/include/beast/http/detail/error.hpp similarity index 50% rename from src/beast/beast/http/detail/error.h rename to src/beast/include/beast/http/detail/error.hpp index 39918f910d..a1543d9884 100644 --- a/src/beast/beast/http/detail/error.h +++ b/src/beast/include/beast/http/detail/error.hpp @@ -1,26 +1,14 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_DETAIL_ERROR_HPP +#define BEAST_HTTP_DETAIL_ERROR_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_DETAIL_ERROR_H_INCLUDED -#define BEAST_HTTP_DETAIL_ERROR_H_INCLUDED - -#include +#include #include namespace beast { diff --git a/src/beast/beast/http/detail/write_preparation.h b/src/beast/include/beast/http/detail/write_preparation.hpp similarity index 67% rename from src/beast/beast/http/detail/write_preparation.h rename to src/beast/include/beast/http/detail/write_preparation.hpp index f7bfd2916a..5456eb2ffb 100644 --- a/src/beast/beast/http/detail/write_preparation.h +++ b/src/beast/include/beast/http/detail/write_preparation.hpp @@ -1,26 +1,14 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Copyright 2013, Vinnie Falco - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_DETAIL_WRITE_PREPARATION_HPP +#define BEAST_HTTP_DETAIL_WRITE_PREPARATION_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_WRITE_PREPARATION_H_INCLUDED -#define BEAST_HTTP_WRITE_PREPARATION_H_INCLUDED - -#include +#include namespace beast { namespace http { diff --git a/src/beast/beast/http/detail/writes.h b/src/beast/include/beast/http/detail/writes.hpp similarity index 52% rename from src/beast/beast/http/detail/writes.h rename to src/beast/include/beast/http/detail/writes.hpp index efeff68cd0..d887a95c02 100644 --- a/src/beast/beast/http/detail/writes.h +++ b/src/beast/include/beast/http/detail/writes.hpp @@ -1,26 +1,14 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_DETAIL_WRITES_HPP +#define BEAST_HTTP_DETAIL_WRITES_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_WRITES_H_INCLUDED -#define BEAST_HTTP_WRITES_H_INCLUDED - -#include +#include #include #include #include diff --git a/src/beast/include/beast/http/empty_body.hpp b/src/beast/include/beast/http/empty_body.hpp new file mode 100644 index 0000000000..d1d076fe48 --- /dev/null +++ b/src/beast/include/beast/http/empty_body.hpp @@ -0,0 +1,75 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_HTTP_EMPTY_BODY_HPP +#define BEAST_HTTP_EMPTY_BODY_HPP + +#include +#include +#include +#include +#include +#include + +namespace beast { +namespace http { + +/** An empty content-body. +*/ +struct empty_body +{ + struct value_type + { + }; + + struct reader + { + template + explicit + reader(message&) + { + } + + void + write(void const*, std::size_t, error_code&) + { + } + }; + + struct writer + { + template + explicit + writer(message const& m) + { + } + + void + init(error_code& ec) + { + } + + std::size_t + content_length() const + { + return 0; + } + + template + boost::tribool + operator()(resume_context&&, error_code&, Write&& write) + { + write(boost::asio::null_buffers{}); + return true; + } + }; +}; + +} // http +} // beast + +#endif diff --git a/src/beast/test/temp_buffer.cpp b/src/beast/include/beast/http/error.hpp similarity index 53% rename from src/beast/test/temp_buffer.cpp rename to src/beast/include/beast/http/error.hpp index 536cf776f3..d82d45bd36 100644 --- a/src/beast/test/temp_buffer.cpp +++ b/src/beast/include/beast/http/error.hpp @@ -5,5 +5,17 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -// Test that header file is self-contained. -#include +#ifndef BEAST_HTTP_ERROR_HPP +#define BEAST_HTTP_ERROR_HPP + +#include + +namespace beast { +namespace http { + +using error_code = boost::system::error_code; + +} // http +} // beast + +#endif diff --git a/src/beast/beast/http/fields.h b/src/beast/include/beast/http/fields.hpp similarity index 100% rename from src/beast/beast/http/fields.h rename to src/beast/include/beast/http/fields.hpp diff --git a/src/beast/include/beast/http/headers.hpp b/src/beast/include/beast/http/headers.hpp new file mode 100644 index 0000000000..9b919071d9 --- /dev/null +++ b/src/beast/include/beast/http/headers.hpp @@ -0,0 +1,26 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_HTTP_HEADERS_HPP +#define BEAST_HTTP_HEADERS_HPP + +#include +#include + +namespace beast { +namespace http { + +template +using headers = basic_headers; + +using http_headers = + basic_headers>; + +} // http +} // beast + +#endif diff --git a/src/beast/beast/http/impl/basic_headers.ipp b/src/beast/include/beast/http/impl/basic_headers.ipp similarity index 81% rename from src/beast/beast/http/impl/basic_headers.ipp rename to src/beast/include/beast/http/impl/basic_headers.ipp index 0c4ec1e518..45a42322d7 100644 --- a/src/beast/beast/http/impl/basic_headers.ipp +++ b/src/beast/include/beast/http/impl/basic_headers.ipp @@ -1,27 +1,15 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_IMPL_BASIC_HEADERS_IPP +#define BEAST_HTTP_IMPL_BASIC_HEADERS_IPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_BASIC_HEADERS_IPP_INCLUDED -#define BEAST_HTTP_BASIC_HEADERS_IPP_INCLUDED - -#include -#include +#include +#include namespace beast { namespace http { @@ -138,7 +126,7 @@ basic_headers:: template basic_headers:: basic_headers(Allocator const& alloc) - : empty_base_optimization< + : beast::detail::empty_base_optimization< alloc_type>(alloc) { } @@ -146,7 +134,7 @@ basic_headers(Allocator const& alloc) template basic_headers:: basic_headers(basic_headers&& other) - : empty_base_optimization( + : beast::detail::empty_base_optimization( std::move(other.member())) , detail::basic_headers_base( std::move(other.set_), std::move(other.list_)) diff --git a/src/beast/beast/http/impl/basic_parser.ipp b/src/beast/include/beast/http/impl/basic_parser.ipp similarity index 65% rename from src/beast/beast/http/impl/basic_parser.ipp rename to src/beast/include/beast/http/impl/basic_parser.ipp index 9642d21f5a..15b624d849 100644 --- a/src/beast/beast/http/impl/basic_parser.ipp +++ b/src/beast/include/beast/http/impl/basic_parser.ipp @@ -1,29 +1,83 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_IMPL_BASIC_PARSER_IPP +#define BEAST_HTTP_IMPL_BASIC_PARSER_IPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include +#include +#include +#include namespace beast { namespace http { +namespace detail { + +inline +beast::http::method_t +convert_http_method(http_method m) +{ + using namespace beast; + switch (m) + { + case HTTP_DELETE: return http::method_t::http_delete; + case HTTP_GET: return http::method_t::http_get; + case HTTP_HEAD: return http::method_t::http_head; + case HTTP_POST: return http::method_t::http_post; + case HTTP_PUT: return http::method_t::http_put; + + // pathological + case HTTP_CONNECT: return http::method_t::http_connect; + case HTTP_OPTIONS: return http::method_t::http_options; + case HTTP_TRACE: return http::method_t::http_trace; + + // webdav + case HTTP_COPY: return http::method_t::http_copy; + case HTTP_LOCK: return http::method_t::http_lock; + case HTTP_MKCOL: return http::method_t::http_mkcol; + case HTTP_MOVE: return http::method_t::http_move; + case HTTP_PROPFIND: return http::method_t::http_propfind; + case HTTP_PROPPATCH: return http::method_t::http_proppatch; + case HTTP_SEARCH: return http::method_t::http_search; + case HTTP_UNLOCK: return http::method_t::http_unlock; + case HTTP_BIND: return http::method_t::http_bind; + case HTTP_REBIND: return http::method_t::http_rebind; + case HTTP_UNBIND: return http::method_t::http_unbind; + case HTTP_ACL: return http::method_t::http_acl; + + // subversion + case HTTP_REPORT: return http::method_t::http_report; + case HTTP_MKACTIVITY: return http::method_t::http_mkactivity; + case HTTP_CHECKOUT: return http::method_t::http_checkout; + case HTTP_MERGE: return http::method_t::http_merge; + + // upnp + case HTTP_MSEARCH: return http::method_t::http_msearch; + case HTTP_NOTIFY: return http::method_t::http_notify; + case HTTP_SUBSCRIBE: return http::method_t::http_subscribe; + case HTTP_UNSUBSCRIBE: return http::method_t::http_unsubscribe; + + // RFC-5789 + case HTTP_PATCH: return http::method_t::http_patch; + case HTTP_PURGE: return http::method_t::http_purge; + + // CalDav + case HTTP_MKCALENDAR: return http::method_t::http_mkcalendar; + + // RFC-2068, section 19.6.1.2 + case HTTP_LINK: return http::method_t::http_link; + case HTTP_UNLINK: return http::method_t::http_unlink; + }; + + return http::method_t::http_get; +} + +} // detail + template basic_parser:: basic_parser(basic_parser&& other) @@ -207,7 +261,7 @@ basic_parser::cb_headers_complete(http_parser* p) http_should_keep_alive(p) != 0; if(p->type == http_parser_type::HTTP_REQUEST) { - t.call_on_request(convert_http_method( + t.call_on_request(detail::convert_http_method( http_method(p->method)), t.url_, p->http_major, p->http_minor, keep_alive, p->upgrade, has_on_request{}); @@ -258,3 +312,5 @@ basic_parser::cb_chunk_complete(http_parser*) } // http } // beast + +#endif diff --git a/src/beast/beast/http/impl/http-parser/http_parser.h b/src/beast/include/beast/http/impl/http_parser.h similarity index 97% rename from src/beast/beast/http/impl/http-parser/http_parser.h rename to src/beast/include/beast/http/impl/http_parser.h index ffbfd99799..105ae510a8 100644 --- a/src/beast/beast/http/impl/http-parser/http_parser.h +++ b/src/beast/include/beast/http/impl/http_parser.h @@ -18,17 +18,16 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ -#ifndef BEAST_HTTP_HTTP_PARSER_HTTP_PARSER_H_INCLUDED -#define BEAST_HTTP_HTTP_PARSER_HTTP_PARSER_H_INCLUDED - +#ifndef http_parser_h +#define http_parser_h #ifdef __cplusplus extern "C" { #endif /* Also update SONAME in the Makefile whenever you change these. */ #define HTTP_PARSER_VERSION_MAJOR 2 -#define HTTP_PARSER_VERSION_MINOR 6 -#define HTTP_PARSER_VERSION_PATCH 1 +#define HTTP_PARSER_VERSION_MINOR 7 +#define HTTP_PARSER_VERSION_PATCH 0 #include #if defined(_WIN32) && !defined(__MINGW32__) && \ @@ -78,6 +77,11 @@ typedef struct http_parser_settings http_parser_settings; * HEAD request which may contain 'Content-Length' or 'Transfer-Encoding: * chunked' headers that indicate the presence of a body. * + * Returning `2` from on_headers_complete will tell parser that it should not + * expect neither a body nor any futher responses on this connection. This is + * useful for handling responses to a CONNECT request which may not contain + * `Upgrade` or `Connection: upgrade` headers. + * * http_data_cb does not return data chunks. It will be called arbitrarily * many times for each string. E.G. you might get 10 callbacks for "on_url" * each providing just a few characters more data. diff --git a/src/beast/beast/http/impl/message.ipp b/src/beast/include/beast/http/impl/message.ipp similarity index 85% rename from src/beast/beast/http/impl/message.ipp rename to src/beast/include/beast/http/impl/message.ipp index ccb72bef8f..f9dcb36711 100644 --- a/src/beast/beast/http/impl/message.ipp +++ b/src/beast/include/beast/http/impl/message.ipp @@ -1,30 +1,18 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_IMPL_MESSAGE_IPP +#define BEAST_HTTP_IMPL_MESSAGE_IPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_MESSAGE_IPP_INCLUDED -#define BEAST_HTTP_MESSAGE_IPP_INCLUDED - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/beast/beast/http/impl/read.ipp b/src/beast/include/beast/http/impl/read.ipp similarity index 84% rename from src/beast/beast/http/impl/read.ipp rename to src/beast/include/beast/http/impl/read.ipp index bc45cda6f0..0022f184df 100644 --- a/src/beast/beast/http/impl/read.ipp +++ b/src/beast/include/beast/http/impl/read.ipp @@ -1,29 +1,17 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_IMPL_READ_IPP_HPP +#define BEAST_HTTP_IMPL_READ_IPP_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_READ_IPP_H_INCLUDED -#define BEAST_HTTP_READ_IPP_H_INCLUDED - -#include -#include -#include -#include +#include +#include +#include +#include #include namespace beast { diff --git a/src/beast/beast/http/impl/write.ipp b/src/beast/include/beast/http/impl/write.ipp similarity index 84% rename from src/beast/beast/http/impl/write.ipp rename to src/beast/include/beast/http/impl/write.ipp index 5a06575abc..30852e2ef7 100644 --- a/src/beast/beast/http/impl/write.ipp +++ b/src/beast/include/beast/http/impl/write.ipp @@ -1,41 +1,29 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Copyright 2013, Vinnie Falco - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_IMPL_WRITE_IPP +#define BEAST_HTTP_IMPL_WRITE_IPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_WRITE_IPP_INCLUDED -#define BEAST_HTTP_WRITE_IPP_INCLUDED - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include // +#include namespace beast { namespace http { @@ -174,12 +162,12 @@ operator()(error_code ec, std::size_t, bool again) // write headers and body if(d.wp.chunked) boost::asio::async_write(d.s, - append_buffers(d.wp.sb.data(), + buffer_cat(d.wp.sb.data(), chunk_encode(buffers)), std::move(*this)); else boost::asio::async_write(d.s, - append_buffers(d.wp.sb.data(), + buffer_cat(d.wp.sb.data(), buffers), std::move(*this)); }); if(ec) @@ -304,10 +292,10 @@ write(SyncWriteStream& stream, { // write headers and body if(wp.chunked) - boost::asio::write(stream, append_buffers( + boost::asio::write(stream, buffer_cat( wp.sb.data(), chunk_encode(buffers)), ec); else - boost::asio::write(stream, append_buffers( + boost::asio::write(stream, buffer_cat( wp.sb.data(), buffers), ec); }); if(ec) diff --git a/src/beast/include/beast/http/message.hpp b/src/beast/include/beast/http/message.hpp new file mode 100644 index 0000000000..e1756a395b --- /dev/null +++ b/src/beast/include/beast/http/message.hpp @@ -0,0 +1,170 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_HTTP_MESSAGE_HPP +#define BEAST_HTTP_MESSAGE_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace beast { +namespace http { + +namespace detail { + +struct request_fields +{ + http::method_t method; + std::string url; +}; + +struct response_fields +{ + int status; + std::string reason; +}; + +} // detail + +struct request_params +{ + http::method_t method; + std::string url; + int version; +}; + +struct response_params +{ + int status; + std::string reason; + int version; +}; + +/** A HTTP message. + + A message can be a request or response, depending on the `isRequest` + template argument value. Requests and responses have different types, + so functions may be overloaded on them if desired. + + The `Body` template argument type determines the model used + to read or write the content body of the message. + + @tparam isRequest `true` if this is a request. + + @tparam Body A type meeting the requirements of Body. + + @tparam Headers A type meeting the requirements of Headers. +*/ +template +struct message + : std::conditional_t +{ + /** The trait type characterizing the body. + + The body member will be of type body_type::value_type. + */ + using body_type = Body; + using headers_type = Headers; + + using is_request = + std::integral_constant; + + int version; // 10 or 11 + headers_type headers; + typename Body::value_type body; + + message(); + message(message&&) = default; + message(message const&) = default; + message& operator=(message&&) = default; + message& operator=(message const&) = default; + + /** Construct a HTTP request. + */ + explicit + message(request_params params); + + /** Construct a HTTP response. + */ + explicit + message(response_params params); + + /// Serialize the request or response line to a Streambuf. + template + void + write_firstline(Streambuf& streambuf) const + { + write_firstline(streambuf, + std::integral_constant{}); + } + + /// Diagnostics only + template + friend + std::ostream& + operator<<(std::ostream& os, + message const& m); + +private: + template + void + write_firstline(Streambuf& streambuf, + std::true_type) const; + + template + void + write_firstline(Streambuf& streambuf, + std::false_type) const; +}; + +#if ! GENERATING_DOCS + +/// A typical HTTP request +template>> +using request = message; + +/// A typical HTTP response +template>> +using response = message; + +#endif + +// For diagnostic output only +template +std::ostream& +operator<<(std::ostream& os, + message const& m); + +/// Write a FieldSequence to a Streambuf. +template +void +write_fields(Streambuf& streambuf, FieldSequence const& fields); + +/// Returns `true` if a message indicates a keep alive +template +bool +is_keep_alive(message const& msg); + +/// Returns `true` if a message indicates a HTTP Upgrade request or response +template +bool +is_upgrade(message const& msg); + +} // http +} // beast + +#include + +#endif diff --git a/src/beast/beast/http/method.h b/src/beast/include/beast/http/method.hpp similarity index 79% rename from src/beast/beast/http/method.h rename to src/beast/include/beast/http/method.hpp index bc58af68af..0c1acf045e 100644 --- a/src/beast/beast/http/method.h +++ b/src/beast/include/beast/http/method.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_METHOD_H_INCLUDED -#define BEAST_HTTP_METHOD_H_INCLUDED +#ifndef BEAST_HTTP_METHOD_HPP +#define BEAST_HTTP_METHOD_HPP #include #include diff --git a/src/beast/include/beast/http/parser.hpp b/src/beast/include/beast/http/parser.hpp new file mode 100644 index 0000000000..fd4f4eaab9 --- /dev/null +++ b/src/beast/include/beast/http/parser.hpp @@ -0,0 +1,155 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_HTTP_PARSER_HPP +#define BEAST_HTTP_PARSER_HPP + +#include +#include +#include +#include +#include +#include +#include + +namespace beast { +namespace http { + +/** A HTTP parser. + + The parser may only be used once. +*/ +template +class parser + : public basic_parser> +{ + using message_type = + message; + + message_type m_; + typename message_type::body_type::reader r_; + bool started_ = false; + +public: + parser(parser&&) = default; + + parser() + : http::basic_parser(isRequest) + , r_(m_) + { + } + + /// Returns `true` if at least one byte has been processed + bool + started() + { + return started_; + } + + message_type + release() + { + return std::move(m_); + } + +private: + friend class http::basic_parser; + + void + on_start() + { + started_ = true; + } + + void + on_field(std::string const& field, std::string const& value) + { + m_.headers.insert(field, value); + } + + void + on_headers_complete(error_code&) + { + // vFALCO TODO Decode the Content-Length and + // Transfer-Encoding, see if we can reserve the buffer. + // + // r_.reserve(content_length) + } + + bool + on_request(http::method_t method, std::string const& url, + int major, int minor, bool keep_alive, bool upgrade, + std::true_type) + { + m_.method = method; + m_.url = url; + m_.version = major * 10 + minor; + return true; + } + + bool + on_request(http::method_t, std::string const&, + int, int, bool, bool, + std::false_type) + { + return true; + } + + bool + on_request(http::method_t method, std::string const& url, + int major, int minor, bool keep_alive, bool upgrade) + { + return on_request(method, url, + major, minor, keep_alive, upgrade, + typename message_type::is_request{}); + } + + bool + on_response(int status, std::string const& reason, + int major, int minor, bool keep_alive, bool upgrade, + std::true_type) + { + m_.status = status; + m_.reason = reason; + m_.version = major * 10 + minor; + // VFALCO TODO return expect_body_ + return true; + } + + bool + on_response(int, std::string const&, int, int, bool, bool, + std::false_type) + { + return true; + } + + bool + on_response(int status, std::string const& reason, + int major, int minor, bool keep_alive, bool upgrade) + { + return on_response( + status, reason, major, minor, keep_alive, upgrade, + std::integral_constant{}); + } + + void + on_body(void const* data, + std::size_t size, error_code& ec) + { + r_.write(data, size, ec); + } + + void + on_complete() + { + } +}; + +} // http +} // beast + +#endif diff --git a/src/beast/beast/http/read.h b/src/beast/include/beast/http/read.hpp similarity index 70% rename from src/beast/beast/http/read.h rename to src/beast/include/beast/http/read.hpp index 6707831675..9532cdee08 100644 --- a/src/beast/beast/http/read.h +++ b/src/beast/include/beast/http/read.hpp @@ -1,28 +1,16 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_READ_HPP +#define BEAST_HTTP_READ_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_READ_H_INCLUDED -#define BEAST_HTTP_READ_H_INCLUDED - -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/beast/beast/http/reason.h b/src/beast/include/beast/http/reason.hpp similarity index 62% rename from src/beast/beast/http/reason.h rename to src/beast/include/beast/http/reason.hpp index 7d97809125..ab3b51b741 100644 --- a/src/beast/beast/http/reason.h +++ b/src/beast/include/beast/http/reason.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_REASON_H_INCLUDED -#define BEAST_HTTP_REASON_H_INCLUDED +#ifndef BEAST_HTTP_REASON_HPP +#define BEAST_HTTP_REASON_HPP namespace beast { namespace http { diff --git a/src/beast/include/beast/http/resume_context.hpp b/src/beast/include/beast/http/resume_context.hpp new file mode 100644 index 0000000000..67c8d513a5 --- /dev/null +++ b/src/beast/include/beast/http/resume_context.hpp @@ -0,0 +1,34 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_HTTP_RESUME_CONTEXT_HPP +#define BEAST_HTTP_RESUME_CONTEXT_HPP + +#include + +namespace beast { +namespace http { + +/** A functor that resumes a write operation. + + An rvalue reference to an object of this type is provided by the + write implementation to the `writer` associated with the body of + a message being sent. + + If it is desired that the `writer` suspend the write operation (for + example, to wait until data is ready), it can take ownership of + the resume context using a move. Then, it returns `boost::indeterminate` + to indicate that the write operation should suspend. Later, the calling + code invokes the resume function and the write operation continues + from where it left off. +*/ +using resume_context = std::function; + +} // http +} // beast + +#endif diff --git a/src/beast/beast/http/rfc2616.h b/src/beast/include/beast/http/rfc2616.hpp similarity index 89% rename from src/beast/beast/http/rfc2616.h rename to src/beast/include/beast/http/rfc2616.hpp index 053c3109ef..ea43016c76 100644 --- a/src/beast/beast/http/rfc2616.h +++ b/src/beast/include/beast/http/rfc2616.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_RFC2616_H_INCLUDED -#define BEAST_HTTP_RFC2616_H_INCLUDED +#ifndef BEAST_HTTP_RFC2616_HPP +#define BEAST_HTTP_RFC2616_HPP #include #include diff --git a/src/beast/beast/http/streambuf_body.h b/src/beast/include/beast/http/streambuf_body.hpp similarity index 55% rename from src/beast/beast/http/streambuf_body.h rename to src/beast/include/beast/http/streambuf_body.hpp index e89a48a1d7..7b2fe581e9 100644 --- a/src/beast/beast/http/streambuf_body.h +++ b/src/beast/include/beast/http/streambuf_body.hpp @@ -1,29 +1,17 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_STREAMBUF_BODY_HPP +#define BEAST_HTTP_STREAMBUF_BODY_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_STREAMBUF_BODY_H_INCLUDED -#define BEAST_HTTP_STREAMBUF_BODY_H_INCLUDED - -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/beast/beast/http/string_body.h b/src/beast/include/beast/http/string_body.hpp similarity index 50% rename from src/beast/beast/http/string_body.h rename to src/beast/include/beast/http/string_body.hpp index c00326ab7d..19f9822636 100644 --- a/src/beast/beast/http/string_body.h +++ b/src/beast/include/beast/http/string_body.hpp @@ -1,30 +1,18 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_STRING_BODY_HPP +#define BEAST_HTTP_STRING_BODY_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_STRING_BODY_H_INCLUDED -#define BEAST_HTTP_STRING_BODY_H_INCLUDED - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/src/beast/include/beast/http/type_check.hpp b/src/beast/include/beast/http/type_check.hpp new file mode 100644 index 0000000000..a5192bd445 --- /dev/null +++ b/src/beast/include/beast/http/type_check.hpp @@ -0,0 +1,72 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_HTTP_TYPE_CHECK_HPP +#define BEAST_HTTP_TYPE_CHECK_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast { +namespace http { + +#if GENERATING_DOCS +namespace detail { +#else +namespace concept { +#endif + +struct Reader +{ + template + Reader(message&) noexcept; + void write(void const*, std::size_t, error_code&) noexcept; +}; + +} // concept + +/// Evaluates to std::true_type if `T` models Body +template +struct is_Body : std::true_type +{ +}; + +/// Evalulates to std::true_type if Body has a reader +template +struct is_ReadableBody : std::true_type +{ +}; + +/// Evalulates to std::true_type if Body has a writer +template +struct is_WritableBody : std::true_type +{ +}; + +/// Evaluates to std::true_type if `T` models HTTPMessage +template +struct is_HTTPMessage : std::false_type +{ +}; + +/// Evaluates to std::true_type if `HTTPMessage` is a request +template +struct is_HTTPRequest : std::true_type +{ +}; + +} // http +} // beast + +#endif diff --git a/src/beast/beast/http/write.h b/src/beast/include/beast/http/write.hpp similarity index 63% rename from src/beast/beast/http/write.h rename to src/beast/include/beast/http/write.hpp index bafa2ec655..9544687b2c 100644 --- a/src/beast/beast/http/write.h +++ b/src/beast/include/beast/http/write.hpp @@ -1,27 +1,15 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_HTTP_WRITE_HPP +#define BEAST_HTTP_WRITE_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_WRITE_H_INCLUDED -#define BEAST_HTTP_WRITE_H_INCLUDED - -#include -#include +#include +#include #include #include diff --git a/src/beast/beast/asio/impl/basic_streambuf.ipp b/src/beast/include/beast/impl/basic_streambuf.ipp similarity index 94% rename from src/beast/beast/asio/impl/basic_streambuf.ipp rename to src/beast/include/beast/impl/basic_streambuf.ipp index afec27bf7e..46ec6ab288 100644 --- a/src/beast/beast/asio/impl/basic_streambuf.ipp +++ b/src/beast/include/beast/impl/basic_streambuf.ipp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_BASIC_STREAMBUF_IPP_INCLUDED -#define BEAST_ASIO_BASIC_STREAMBUF_IPP_INCLUDED +#ifndef BEAST_IMPL_BASIC_STREAMBUF_IPP +#define BEAST_IMPL_BASIC_STREAMBUF_IPP #include #include @@ -358,7 +346,7 @@ basic_streambuf::~basic_streambuf() template basic_streambuf:: basic_streambuf(basic_streambuf&& other) - : empty_base_optimization( + : detail::empty_base_optimization( std::move(other.member())) , alloc_size_(other.alloc_size_) , in_size_(other.in_size_) @@ -476,7 +464,7 @@ basic_streambuf::operator=( template basic_streambuf::basic_streambuf( std::size_t alloc_size, Allocator const& alloc) - : empty_base_optimization(alloc) + : detail::empty_base_optimization(alloc) , out_(list_.end()) , alloc_size_(alloc_size) { diff --git a/src/beast/beast/asio/impl/streambuf_readstream.ipp b/src/beast/include/beast/impl/streambuf_readstream.ipp similarity index 83% rename from src/beast/beast/asio/impl/streambuf_readstream.ipp rename to src/beast/include/beast/impl/streambuf_readstream.ipp index fd1e8d9147..9c52df4112 100644 --- a/src/beast/beast/asio/impl/streambuf_readstream.ipp +++ b/src/beast/include/beast/impl/streambuf_readstream.ipp @@ -1,29 +1,17 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_IMPL_STREAMBUF_READSTREAM_IPP +#define BEAST_IMPL_STREAMBUF_READSTREAM_IPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_STREAMBUF_READSTREAM_IPP_INLUDED -#define BEAST_ASIO_STREAMBUF_READSTREAM_IPP_INLUDED - -#include -#include -#include -#include +#include +#include +#include +#include namespace beast { diff --git a/src/beast/include/beast/placeholders.hpp b/src/beast/include/beast/placeholders.hpp new file mode 100644 index 0000000000..2ba1a7af37 --- /dev/null +++ b/src/beast/include/beast/placeholders.hpp @@ -0,0 +1,29 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_PLACEHOLDERS_HPP +#define BEAST_PLACEHOLDERS_HPP + +#include + +namespace beast { +namespace asio { + +namespace placeholders { +// asio placeholders that work with std::bind +namespace { +static auto const error (std::placeholders::_1); +static auto const bytes_transferred (std::placeholders::_2); +static auto const iterator (std::placeholders::_2); +static auto const signal_number (std::placeholders::_2); +} +} + +} +} + +#endif diff --git a/src/beast/beast/asio/prepare_buffers.h b/src/beast/include/beast/prepare_buffers.hpp similarity index 87% rename from src/beast/beast/asio/prepare_buffers.h rename to src/beast/include/beast/prepare_buffers.hpp index 724e56b26e..e2009bc003 100644 --- a/src/beast/beast/asio/prepare_buffers.h +++ b/src/beast/include/beast/prepare_buffers.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_PREPARE_BUFFERS_H_INLUDED -#define BEAST_ASIO_PREPARE_BUFFERS_H_INLUDED +#ifndef BEAST_PREPARE_BUFFERS_HPP +#define BEAST_PREPARE_BUFFERS_HPP #include #include diff --git a/src/beast/beast/asio/static_streambuf.h b/src/beast/include/beast/static_streambuf.hpp similarity index 89% rename from src/beast/beast/asio/static_streambuf.h rename to src/beast/include/beast/static_streambuf.hpp index 349998d39e..65d6df9569 100644 --- a/src/beast/beast/asio/static_streambuf.h +++ b/src/beast/include/beast/static_streambuf.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_STATIC_STREAMBUF_H_INLUDED -#define BEAST_ASIO_STATIC_STREAMBUF_H_INLUDED +#ifndef BEAST_STATIC_STREAMBUF_HPP +#define BEAST_STATIC_STREAMBUF_HPP #include #include diff --git a/src/beast/test/asio.cpp b/src/beast/include/beast/streambuf.hpp similarity index 55% rename from src/beast/test/asio.cpp rename to src/beast/include/beast/streambuf.hpp index 880a574428..04ab4b3e0a 100644 --- a/src/beast/test/asio.cpp +++ b/src/beast/include/beast/streambuf.hpp @@ -5,5 +5,15 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -// Test that header file is self-contained. -#include +#ifndef BEAST_STREAMBUF_HPP +#define BEAST_STREAMBUF_HPP + +#include + +namespace beast { + +using streambuf = basic_streambuf>; + +} // beast + +#endif diff --git a/src/beast/beast/asio/streambuf_readstream.h b/src/beast/include/beast/streambuf_readstream.hpp similarity index 84% rename from src/beast/beast/asio/streambuf_readstream.h rename to src/beast/include/beast/streambuf_readstream.hpp index 78b6db7815..8b5bb77057 100644 --- a/src/beast/beast/asio/streambuf_readstream.h +++ b/src/beast/include/beast/streambuf_readstream.hpp @@ -1,26 +1,14 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_STREAMBUF_READSTREAM_HPP +#define BEAST_STREAMBUF_READSTREAM_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_STREAMBUF_READSTREAM_H_INLUDED -#define BEAST_ASIO_STREAMBUF_READSTREAM_H_INLUDED - -#include +#include #include #include #include @@ -254,6 +242,6 @@ public: } // beast -#include +#include #endif diff --git a/src/beast/beast/asio/type_check.h b/src/beast/include/beast/type_check.hpp similarity index 81% rename from src/beast/beast/asio/type_check.h rename to src/beast/include/beast/type_check.hpp index 00d0276171..16dfa8c843 100644 --- a/src/beast/beast/asio/type_check.h +++ b/src/beast/include/beast/type_check.hpp @@ -1,31 +1,19 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_TYPE_CHECK_HPP +#define BEAST_TYPE_CHECK_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_ASIO_TYPE_CHECK_H_INCLUDED -#define BEAST_ASIO_TYPE_CHECK_H_INCLUDED - -#include +#include #include #include #include #include -#include +#include #include namespace beast { @@ -297,22 +285,53 @@ struct is_Stream }; /// Determine if `T` meets the requirements of `Streambuf`. -template -struct is_Streambuf : std::false_type {}; -template -struct is_Streambuf().prepare(1))>::value>, - std::integral_constant().data())>::value>, - decltype(std::declval().commit(1), std::true_type{}), - decltype(std::declval().consume(1), std::true_type{}), - std::is_same().size()), std::size_t> ->>:std::true_type{}; +template +class is_Streambuf +{ + template().prepare(1))>::value>> + static R check1(int); + template + static std::false_type check1(...); + using type1 = decltype(check1(0)); + + template().data())>::value>> + static R check2(int); + template + static std::false_type check2(...); + using type2 = decltype(check2(0)); + + template().commit(1), std::true_type{})> + static R check3(int); + template + static std::false_type check3(...); + using type3 = decltype(check3(0)); + + template().consume(1), std::true_type{})> + static R check4(int); + template + static std::false_type check4(...); + using type4 = decltype(check4(0)); + + template().size()), std::size_t>> + static R check5(int); + template + static std::false_type check5(...); + using type5 = decltype(check5(0)); + +public: + /// `true` if `T` meets the requirements. + static bool const value = + type1::value && type2::value && + type3::value && type4::value && + type5::value; +}; #if ! GENERATING_DOCS @@ -320,7 +339,7 @@ struct is_Streambuf using is_Handler = std::integral_constant>::value && - is_call_possible::value>; + detail::is_call_possible::value>; #endif diff --git a/src/beast/beast/http/error.h b/src/beast/include/beast/websocket.hpp similarity index 78% rename from src/beast/beast/http/error.h rename to src/beast/include/beast/websocket.hpp index 3a101c551b..2baebdfc14 100644 --- a/src/beast/beast/http/error.h +++ b/src/beast/include/beast/websocket.hpp @@ -17,17 +17,14 @@ */ //============================================================================== -#ifndef BEAST_HTTP_ERROR_H_INCLUDED -#define BEAST_HTTP_ERROR_H_INCLUDED +#ifndef BEAST_WEBSOCKET_HPP +#define BEAST_WEBSOCKET_HPP -#include - -namespace beast { -namespace http { - -using error_code = boost::system::error_code; - -} // http -} // beast +#include +#include +#include +#include +#include +#include #endif diff --git a/src/beast/beast/wsproto/detail/debug.h b/src/beast/include/beast/websocket/detail/debug.hpp similarity index 99% rename from src/beast/beast/wsproto/detail/debug.h rename to src/beast/include/beast/websocket/detail/debug.hpp index a3696c9ff2..91de367bdd 100644 --- a/src/beast/beast/wsproto/detail/debug.h +++ b/src/beast/include/beast/websocket/detail/debug.hpp @@ -27,7 +27,7 @@ #include namespace beast { -namespace wsproto { +namespace websocket { namespace detail { template diff --git a/src/beast/beast/wsproto/detail/decorator.h b/src/beast/include/beast/websocket/detail/decorator.hpp similarity index 51% rename from src/beast/beast/wsproto/detail/decorator.h rename to src/beast/include/beast/websocket/detail/decorator.hpp index 7078849cfd..c0492477bb 100644 --- a/src/beast/beast/wsproto/detail/decorator.h +++ b/src/beast/include/beast/websocket/detail/decorator.hpp @@ -1,32 +1,20 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_DETAIL_DECORATOR_HPP +#define BEAST_WEBSOCKET_DETAIL_DECORATOR_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_DECORATOR_H_INCLUDED -#define BEAST_WSPROTO_DECORATOR_H_INCLUDED - -#include -#include -#include +#include +#include +#include #include namespace beast { -namespace wsproto { +namespace websocket { namespace detail { using request_type = http::request; @@ -106,7 +94,7 @@ using decorator_type = std::unique_ptr; } // detail -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/detail/error.h b/src/beast/include/beast/websocket/detail/error.hpp similarity index 61% rename from src/beast/beast/wsproto/detail/error.h rename to src/beast/include/beast/websocket/detail/error.hpp index f19e1bc03e..0495a9ae87 100644 --- a/src/beast/beast/wsproto/detail/error.h +++ b/src/beast/include/beast/websocket/detail/error.hpp @@ -1,31 +1,19 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_DETAIL_ERROR_HPP +#define BEAST_WEBSOCKET_DETAIL_ERROR_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_DETAIL_ERROR_H_INCLUDED -#define BEAST_WSPROTO_DETAIL_ERROR_H_INCLUDED - -#include +#include namespace boost { namespace system { template<> -struct is_error_code_enum +struct is_error_code_enum { static bool const value = true; }; @@ -33,7 +21,7 @@ struct is_error_code_enum } // boost namespace beast { -namespace wsproto { +namespace websocket { namespace detail { class error_category : public boost::system::error_category @@ -98,7 +86,7 @@ get_error_category() } } // detail -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/detail/frame.h b/src/beast/include/beast/websocket/detail/frame.hpp similarity index 84% rename from src/beast/beast/wsproto/detail/frame.h rename to src/beast/include/beast/websocket/detail/frame.hpp index cd9db07805..3ec1bfc635 100644 --- a/src/beast/beast/wsproto/detail/frame.h +++ b/src/beast/include/beast/websocket/detail/frame.hpp @@ -1,37 +1,25 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_DETAIL_FRAME_HPP +#define BEAST_WEBSOCKET_DETAIL_FRAME_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_FRAME_H_INCLUDED -#define BEAST_WSPROTO_FRAME_H_INCLUDED - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include #include namespace beast { -namespace wsproto { +namespace websocket { namespace detail { // Contents of a WebSocket frame header @@ -369,7 +357,7 @@ read(close_reason& cr, } } // detail -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/include/beast/websocket/detail/hybi13.hpp b/src/beast/include/beast/websocket/detail/hybi13.hpp new file mode 100644 index 0000000000..831469c80d --- /dev/null +++ b/src/beast/include/beast/websocket/detail/hybi13.hpp @@ -0,0 +1,57 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_WEBSOCKET_DETAIL_HYBI13_HPP +#define BEAST_WEBSOCKET_DETAIL_HYBI13_HPP + +#include +#include +#include +#include +#include +#include + +namespace beast { +namespace websocket { +namespace detail { + +template +std::string +make_sec_ws_key(Gen& g) +{ + union U + { + std::array a4; + std::array a16; + }; + U u; + for(int i = 0; i < 4; ++i) + u.a4[i] = g(); + return beast::detail::base64_encode(u.a16.data(), u.a16.size()); +} + +template +std::string +make_sec_ws_accept(boost::string_ref const& key) +{ + std::string s(key.data(), key.size()); + s += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; + beast::detail::sha1_context ctx; + beast::detail::init(ctx); + beast::detail::update(ctx, s.data(), s.size()); + std::array digest; + beast::detail::finish(ctx, digest.data()); + return beast::detail::base64_encode( + digest.data(), digest.size()); +} + +} // detail +} // websocket +} // beast + +#endif diff --git a/src/beast/beast/wsproto/detail/invokable.h b/src/beast/include/beast/websocket/detail/invokable.hpp similarity index 69% rename from src/beast/beast/wsproto/detail/invokable.h rename to src/beast/include/beast/websocket/detail/invokable.hpp index 140246893d..37053fc8fa 100644 --- a/src/beast/beast/wsproto/detail/invokable.h +++ b/src/beast/include/beast/websocket/detail/invokable.hpp @@ -1,24 +1,12 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_INVOKABLE_H_INCLUDED -#define BEAST_WSPROTO_INVOKABLE_H_INCLUDED +#ifndef BEAST_WEBSOCKET_DETAIL_INVOKABLE_HPP +#define BEAST_WEBSOCKET_DETAIL_INVOKABLE_HPP #include #include @@ -27,7 +15,7 @@ #include namespace beast { -namespace wsproto { +namespace websocket { namespace detail { // "Parks" a composed operation, to invoke later @@ -162,7 +150,7 @@ invokable::emplace(F&& f) } } // detail -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/detail/mask.h b/src/beast/include/beast/websocket/detail/mask.hpp similarity index 98% rename from src/beast/beast/wsproto/detail/mask.h rename to src/beast/include/beast/websocket/detail/mask.hpp index 220268665d..f5ebaddd71 100644 --- a/src/beast/beast/wsproto/detail/mask.h +++ b/src/beast/include/beast/websocket/detail/mask.hpp @@ -17,8 +17,8 @@ */ //============================================================================== -#ifndef BEAST_WSPROTO_DETAIL_MASKGEN_H_INCLUDED -#define BEAST_WSPROTO_DETAIL_MASKGEN_H_INCLUDED +#ifndef BEAST_WEBSOCKETDETAIL_MASKGEN_HPP +#define BEAST_WEBSOCKETDETAIL_MASKGEN_HPP #include #include @@ -28,7 +28,7 @@ #include namespace beast { -namespace wsproto { +namespace websocket { namespace detail { // Pseudo-random source of mask keys @@ -383,7 +383,7 @@ mask_inplace( } } // detail -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/detail/socket_base.h b/src/beast/include/beast/websocket/detail/stream_base.hpp similarity index 60% rename from src/beast/beast/wsproto/detail/socket_base.h rename to src/beast/include/beast/websocket/detail/stream_base.hpp index 11abd8b5fc..42eab6890c 100644 --- a/src/beast/beast/wsproto/detail/socket_base.h +++ b/src/beast/include/beast/websocket/detail/stream_base.hpp @@ -1,36 +1,24 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_DETAIL_STREAM_BASE_HPP +#define BEAST_WEBSOCKET_DETAIL_STREAM_BASE_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_SOCKET_BASE_H_INCLUDED -#define BEAST_WSPROTO_SOCKET_BASE_H_INCLUDED - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -39,7 +27,7 @@ #include namespace beast { -namespace wsproto { +namespace websocket { namespace detail { template @@ -73,7 +61,7 @@ clamp(UInt x, std::size_t limit) //------------------------------------------------------------------------------ -struct socket_base +struct stream_base { protected: struct op {}; @@ -108,16 +96,16 @@ protected: invokable wr_op_; // invoked after read completes close_reason cr_; // set from received close frame - socket_base() + stream_base() : d_(std::make_unique< decorator>()) { } - socket_base(socket_base&&) = default; - socket_base(socket_base const&) = delete; - socket_base& operator=(socket_base&&) = default; - socket_base& operator=(socket_base const&) = delete; + stream_base(stream_base&&) = default; + stream_base(stream_base const&) = delete; + stream_base& operator=(stream_base&&) = default; + stream_base& operator=(stream_base const&) = delete; template void @@ -135,7 +123,7 @@ protected: }; } // detail -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/detail/utf8_checker.h b/src/beast/include/beast/websocket/detail/utf8_checker.hpp similarity index 80% rename from src/beast/beast/wsproto/detail/utf8_checker.h rename to src/beast/include/beast/websocket/detail/utf8_checker.hpp index 7d35134c42..e9a673bbef 100644 --- a/src/beast/beast/wsproto/detail/utf8_checker.h +++ b/src/beast/include/beast/websocket/detail/utf8_checker.hpp @@ -1,31 +1,19 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_UTF8_CHECKER_H_INCLUDED -#define BEAST_WSPROTO_UTF8_CHECKER_H_INCLUDED +#ifndef BEAST_WEBSOCKET_DETAIL_UTF8_CHECKER_HPP +#define BEAST_WEBSOCKET_DETAIL_UTF8_CHECKER_HPP #include #include #include // DEPRECATED namespace beast { -namespace wsproto { +namespace websocket { namespace detail { // Code adapted from @@ -178,7 +166,7 @@ check_utf8(char const* p, std::size_t n) } } // detail -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/include/beast/websocket/error.hpp b/src/beast/include/beast/websocket/error.hpp new file mode 100644 index 0000000000..0283483f67 --- /dev/null +++ b/src/beast/include/beast/websocket/error.hpp @@ -0,0 +1,60 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_WEBSOCKET_ERROR_HPP +#define BEAST_WEBSOCKET_ERROR_HPP + +#include + +namespace beast { +namespace websocket { + +using error_code = boost::system::error_code; + +/// Error values +enum class error +{ + /// Both sides performed a WebSocket close + closed = 1, + + /// WebSocket connection failed, protocol violation + failed, + + /// Upgrade request failed, connection is closed + handshake_failed, + + /// Upgrade request failed, but connection is still open + keep_alive, + + /// HTTP response is malformed + response_malformed, + + /// HTTP response failed the upgrade + response_failed, + + /// Upgrade request denied for invalid fields. + response_denied, + + /// Upgrade request is malformed + request_malformed, + + /// Upgrade request fields incorrect + request_invalid, + + /// Upgrade request denied + request_denied +}; + +error_code +make_error_code(error e); + +} // websocket +} // beast + +#include + +#endif diff --git a/src/beast/beast/wsproto/impl/accept_op.ipp b/src/beast/include/beast/websocket/impl/accept_op.ipp similarity index 63% rename from src/beast/beast/wsproto/impl/accept_op.ipp rename to src/beast/include/beast/websocket/impl/accept_op.ipp index c82e24cd1a..ff8b03d1d9 100644 --- a/src/beast/beast/wsproto/impl/accept_op.ipp +++ b/src/beast/include/beast/websocket/impl/accept_op.ipp @@ -1,56 +1,44 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_IMPL_ACCEPT_OP_HPP +#define BEAST_WEBSOCKET_IMPL_ACCEPT_OP_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_ACCEPT_OP_H_INCLUDED -#define BEAST_WSPROTO_ACCEPT_OP_H_INCLUDED - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include namespace beast { -namespace wsproto { +namespace websocket { // read and respond to an upgrade request // -template +template template -class socket::accept_op +class stream::accept_op { using alloc_type = handler_alloc; struct data { - socket& ws; + stream& ws; http::request req; Handler h; bool cont; int state = 0; template - data(DeducedHandler&& h_, socket& ws_, + data(DeducedHandler&& h_, stream& ws_, Buffers const& buffers) : ws(ws_) , h(std::forward(h_)) @@ -73,7 +61,7 @@ public: template accept_op(DeducedHandler&& h, - socket& ws, Args&&... args) + stream& ws, Args&&... args) : d_(std::allocate_shared(alloc_type{h}, std::forward(h), ws, std::forward(args)...)) @@ -120,10 +108,10 @@ public: } }; -template +template template void -socket::accept_op:: +stream::accept_op:: operator()(error_code const& ec, std::size_t bytes_transferred, bool again) { @@ -152,7 +140,7 @@ operator()(error_code const& ec, d.h(ec); } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/impl/close_op.ipp b/src/beast/include/beast/websocket/impl/close_op.ipp similarity index 71% rename from src/beast/beast/wsproto/impl/close_op.ipp rename to src/beast/include/beast/websocket/impl/close_op.ipp index f17e050ead..1b558686a6 100644 --- a/src/beast/beast/wsproto/impl/close_op.ipp +++ b/src/beast/include/beast/websocket/impl/close_op.ipp @@ -1,37 +1,25 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_IMPL_CLOSE_OP_HPP +#define BEAST_WEBSOCKET_IMPL_CLOSE_OP_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_CLOSE_OP_H_INCLUDED -#define BEAST_WSPROTO_CLOSE_OP_H_INCLUDED - -#include -#include +#include +#include #include namespace beast { -namespace wsproto { +namespace websocket { // send the close message and wait for the response // -template +template template -class socket::close_op +class stream::close_op { using alloc_type = handler_alloc; @@ -42,7 +30,7 @@ class socket::close_op struct data : op { - socket& ws; + stream& ws; close_reason cr; Handler h; fb_type fb; @@ -51,7 +39,7 @@ class socket::close_op int state = 0; template - data(DeducedHandler&& h_, socket& ws_, + data(DeducedHandler&& h_, stream& ws_, close_reason const& cr_) : ws(ws_) , cr(cr_) @@ -72,7 +60,7 @@ public: template close_op(DeducedHandler&& h, - socket& ws, Args&&... args) + stream& ws, Args&&... args) : d_(std::allocate_shared(alloc_type{h}, std::forward(h), ws, std::forward(args)...)) @@ -127,10 +115,10 @@ public: } }; -template +template template void -socket::close_op::operator()( +stream::close_op::operator()( error_code ec, std::size_t bytes_transferred, bool again) { auto& d = *d_; @@ -192,7 +180,7 @@ socket::close_op::operator()( d.ws.rd_op_.maybe_invoke(); } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/include/beast/websocket/impl/error.ipp b/src/beast/include/beast/websocket/impl/error.ipp new file mode 100644 index 0000000000..b4c2910228 --- /dev/null +++ b/src/beast/include/beast/websocket/impl/error.ipp @@ -0,0 +1,27 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef BEAST_WEBSOCKET_IMPL_ERROR_IPP_HPP +#define BEAST_WEBSOCKET_IMPL_ERROR_IPP_HPP + +#include + +namespace beast { +namespace websocket { + +inline +error_code +make_error_code(error e) +{ + return error_code( + static_cast(e), detail::get_error_category()); +} + +} // websocket +} // beast + +#endif diff --git a/src/beast/beast/wsproto/impl/handshake_op.ipp b/src/beast/include/beast/websocket/impl/handshake_op.ipp similarity index 66% rename from src/beast/beast/wsproto/impl/handshake_op.ipp rename to src/beast/include/beast/websocket/impl/handshake_op.ipp index 2f6538fb76..a3cd9e552a 100644 --- a/src/beast/beast/wsproto/impl/handshake_op.ipp +++ b/src/beast/include/beast/websocket/impl/handshake_op.ipp @@ -1,48 +1,36 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_IMPL_HANDSHAKE_OP_HPP +#define BEAST_WEBSOCKET_IMPL_HANDSHAKE_OP_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_HANDSHAKE_OP_H_INCLUDED -#define BEAST_WSPROTO_HANDSHAKE_OP_H_INCLUDED - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include namespace beast { -namespace wsproto { +namespace websocket { // send the upgrade request and process the response // -template +template template -class socket::handshake_op +class stream::handshake_op { using alloc_type = handler_alloc; struct data { - socket& ws; + stream& ws; Handler h; std::string key; http::request req; @@ -51,7 +39,7 @@ class socket::handshake_op int state = 0; template - data(DeducedHandler&& h_, socket& ws_, + data(DeducedHandler&& h_, stream& ws_, boost::string_ref const& host, boost::string_ref const& resource) : ws(ws_) @@ -71,7 +59,7 @@ public: template handshake_op(DeducedHandler&& h, - socket& ws, Args&&... args) + stream& ws, Args&&... args) : d_(std::allocate_shared(alloc_type{h}, std::forward(h), ws, std::forward(args)...)) @@ -118,10 +106,10 @@ public: } }; -template +template template void -socket::handshake_op< +stream::handshake_op< Handler>::operator()(error_code ec, std::size_t bytes_transferred, bool again) { @@ -164,7 +152,7 @@ socket::handshake_op< d.h(ec); } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/impl/read_frame_op.ipp b/src/beast/include/beast/websocket/impl/read_frame_op.ipp similarity index 89% rename from src/beast/beast/wsproto/impl/read_frame_op.ipp rename to src/beast/include/beast/websocket/impl/read_frame_op.ipp index 9c3d1f017c..e29feda006 100644 --- a/src/beast/beast/wsproto/impl/read_frame_op.ipp +++ b/src/beast/include/beast/websocket/impl/read_frame_op.ipp @@ -1,41 +1,29 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_IMPL_READ_FRAME_OP_HPP +#define BEAST_WEBSOCKET_IMPL_READ_FRAME_OP_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_READ_FRAME_OP_H_INCLUDED -#define BEAST_WSPROTO_READ_FRAME_OP_H_INCLUDED - -#include -#include -#include -#include +#include +#include +#include +#include #include #include namespace beast { -namespace wsproto { +namespace websocket { // Reads a single message frame, // processes any received control frames. // -template +template template -class socket::read_frame_op +class stream::read_frame_op { using alloc_type = handler_alloc; @@ -51,7 +39,7 @@ class socket::read_frame_op struct data : op { - socket& ws; + stream& ws; frame_info& fi; Streambuf& sb; smb_type smb; @@ -62,7 +50,7 @@ class socket::read_frame_op int state = 0; template - data(DeducedHandler&& h_, socket& ws_, + data(DeducedHandler&& h_, stream& ws_, frame_info& fi_, Streambuf& sb_) : ws(ws_) , fi(fi_) @@ -82,7 +70,7 @@ public: template read_frame_op(DeducedHandler&& h, - socket& ws, Args&&... args) + stream& ws, Args&&... args) : d_(std::allocate_shared(alloc_type{h}, std::forward(h), ws, std::forward(args)...)) @@ -136,10 +124,10 @@ public: } }; -template +template template void -socket::read_frame_op:: +stream::read_frame_op:: operator()(error_code ec,std::size_t bytes_transferred, bool again) { auto& d = *d_; @@ -513,7 +501,7 @@ operator()(error_code ec,std::size_t bytes_transferred, bool again) d.ws.wr_op_.maybe_invoke(); } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/impl/read_op.ipp b/src/beast/include/beast/websocket/impl/read_op.ipp similarity index 62% rename from src/beast/beast/wsproto/impl/read_op.ipp rename to src/beast/include/beast/websocket/impl/read_op.ipp index 895a91514b..b42c401b0b 100644 --- a/src/beast/beast/wsproto/impl/read_op.ipp +++ b/src/beast/include/beast/websocket/impl/read_op.ipp @@ -1,43 +1,31 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_IMPL_READ_OP_HPP +#define BEAST_WEBSOCKET_IMPL_READ_OP_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_READ_OP_H_INCLUDED -#define BEAST_WSPROTO_READ_OP_H_INCLUDED - -#include +#include #include namespace beast { -namespace wsproto { +namespace websocket { // read an entire message // -template +template template -class socket::read_op +class stream::read_op { using alloc_type = handler_alloc; struct data { - socket& ws; + stream& ws; opcode& op; Streambuf& sb; Handler h; @@ -47,7 +35,7 @@ class socket::read_op template data(DeducedHandler&& h_, - socket& ws_, opcode& op_, + stream& ws_, opcode& op_, Streambuf& sb_) : ws(ws_) , op(op_) @@ -67,7 +55,7 @@ public: template read_op(DeducedHandler&& h, - socket& ws, Args&&... args) + stream& ws, Args&&... args) : d_(std::allocate_shared(alloc_type{h}, std::forward(h), ws, std::forward(args)...)) @@ -109,10 +97,10 @@ public: } }; -template +template template void -socket::read_op:: +stream::read_op:: operator()(error_code const& ec, bool again) { auto& d = *d_; @@ -138,7 +126,7 @@ operator()(error_code const& ec, bool again) d.h(ec); } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/impl/response_op.ipp b/src/beast/include/beast/websocket/impl/response_op.ipp similarity index 62% rename from src/beast/beast/wsproto/impl/response_op.ipp rename to src/beast/include/beast/websocket/impl/response_op.ipp index ff7e6f7f7f..9351c2b27e 100644 --- a/src/beast/beast/wsproto/impl/response_op.ipp +++ b/src/beast/include/beast/websocket/impl/response_op.ipp @@ -1,44 +1,32 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_IMPL_RESPONSE_OP_HPP +#define BEAST_WEBSOCKET_IMPL_RESPONSE_OP_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_RESPONSE_OP_H_INCLUDED -#define BEAST_WSPROTO_RESPONSE_OP_H_INCLUDED - -#include -#include -#include +#include +#include +#include #include namespace beast { -namespace wsproto { +namespace websocket { // Respond to an upgrade HTTP request -template +template template -class socket::response_op +class stream::response_op { using alloc_type = handler_alloc; struct data { - socket& ws; + stream& ws; http::response resp; Handler h; error_code final_ec; @@ -47,7 +35,7 @@ class socket::response_op template - data(DeducedHandler&& h_, socket& ws_, + data(DeducedHandler&& h_, stream& ws_, http::message const& req, bool cont_) : ws(ws_) @@ -68,7 +56,7 @@ public: template response_op(DeducedHandler&& h, - socket& ws, Args&&... args) + stream& ws, Args&&... args) : d_(std::allocate_shared(alloc_type{h}, std::forward(h), ws, std::forward(args)...)) @@ -110,10 +98,10 @@ public: } }; -template +template template void -socket::response_op:: +stream::response_op:: operator()(error_code ec, bool again) { auto& d = *d_; @@ -141,7 +129,7 @@ operator()(error_code ec, bool again) d.h(ec); } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/impl/socket.ipp b/src/beast/include/beast/websocket/impl/socket.ipp similarity index 84% rename from src/beast/beast/wsproto/impl/socket.ipp rename to src/beast/include/beast/websocket/impl/socket.ipp index 50607f9a85..6d437540d2 100644 --- a/src/beast/beast/wsproto/impl/socket.ipp +++ b/src/beast/include/beast/websocket/impl/socket.ipp @@ -1,46 +1,34 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_IMPL_SOCKET_IPP +#define BEAST_WEBSOCKET_IMPL_SOCKET_IPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_IMPL_SOCKET_IPP_INCLUDED -#define BEAST_WSPROTO_IMPL_SOCKET_IPP_INCLUDED - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -48,13 +36,13 @@ #include namespace beast { -namespace wsproto { +namespace websocket { namespace detail { template void -socket_base::prepare_fh(close_code& code) +stream_base::prepare_fh(close_code& code) { // continuation without an active message if(! rd_cont_ && rd_fh_.op == opcode::cont) @@ -100,7 +88,7 @@ socket_base::prepare_fh(close_code& code) template void -socket_base::write_close( +stream_base::write_close( Streambuf& sb, close_reason const& cr) { using namespace boost::endian; @@ -146,7 +134,7 @@ socket_base::write_close( template void -socket_base::write_ping(Streambuf& sb, +stream_base::write_ping(Streambuf& sb, opcode op, ping_payload_type const& data) { frame_header fh; @@ -177,9 +165,9 @@ socket_base::write_ping(Streambuf& sb, //------------------------------------------------------------------------------ -template +template template -socket::socket(Args&&... args) +stream::stream(Args&&... args) : next_layer_(std::forward(args)...) , stream_(next_layer_) { @@ -187,26 +175,26 @@ socket::socket(Args&&... args) "Stream requirements not met"); } -template +template void -socket::accept(error_code& ec) +stream::accept(error_code& ec) { accept(boost::asio::null_buffers{}, ec); } -template +template template auto -socket::async_accept(AcceptHandler&& handler) +stream::async_accept(AcceptHandler&& handler) { return async_accept(boost::asio::null_buffers{}, std::forward(handler)); } -template +template template void -socket::accept( +stream::accept( ConstBufferSequence const& buffers) { static_assert(is_ConstBufferSequence< @@ -217,10 +205,10 @@ socket::accept( detail::maybe_throw(ec, "accept"); } -template +template template void -socket::accept( +stream::accept( ConstBufferSequence const& buffers, error_code& ec) { static_assert(beast::is_ConstBufferSequence< @@ -238,10 +226,10 @@ socket::accept( accept(m, ec); } -template +template template auto -socket::async_accept( +stream::async_accept( ConstBufferSequence const& bs, AcceptHandler&& handler) { static_assert(beast::is_ConstBufferSequence< @@ -255,10 +243,10 @@ socket::async_accept( return completion.result.get(); } -template +template template void -socket::accept( +stream::accept( http::message const& request) { error_code ec; @@ -266,10 +254,10 @@ socket::accept( detail::maybe_throw(ec, "accept"); } -template +template template void -socket::accept( +stream::accept( http::message const& req, error_code& ec) { @@ -285,10 +273,10 @@ socket::accept( role_ = role_type::server; } -template +template template auto -socket::async_accept( +stream::async_accept( http::message const& req, AcceptHandler&& handler) { @@ -302,9 +290,9 @@ socket::async_accept( return completion.result.get(); } -template +template void -socket::handshake(boost::string_ref const& host, +stream::handshake(boost::string_ref const& host, boost::string_ref const& resource, error_code& ec) { std::string key; @@ -319,10 +307,10 @@ socket::handshake(boost::string_ref const& host, do_response(resp, key, ec); } -template +template template auto -socket::async_handshake(boost::string_ref const& host, +stream::async_handshake(boost::string_ref const& host, boost::string_ref const& resource, HandshakeHandler&& handler) { beast::async_completion< @@ -333,9 +321,9 @@ socket::async_handshake(boost::string_ref const& host, return completion.result.get(); } -template +template void -socket::close( +stream::close( close_reason const& cr, error_code& ec) { assert(! wr_close_); @@ -346,10 +334,10 @@ socket::close( error_ = ec != 0; } -template +template template auto -socket::async_close( +stream::async_close( close_reason const& cr, CloseHandler&& handler) { beast::async_completion< @@ -360,10 +348,10 @@ socket::async_close( return completion.result.get(); } -template +template template void -socket:: +stream:: read(opcode& op, Streambuf& streambuf, error_code& ec) { frame_info fi; @@ -378,10 +366,10 @@ read(opcode& op, Streambuf& streambuf, error_code& ec) } } -template +template template auto -socket:: +stream:: async_read(opcode& op, Streambuf& streambuf, ReadHandler&& handler) { @@ -395,10 +383,10 @@ async_read(opcode& op, return completion.result.get(); } -template +template template void -socket::read_frame(frame_info& fi, +stream::read_frame(frame_info& fi, Streambuf& streambuf, error_code& ec) { close_code code{}; @@ -531,10 +519,10 @@ socket::read_frame(frame_info& fi, error_ = ec != 0; } -template +template template auto -socket::async_read_frame(frame_info& fi, +stream::async_read_frame(frame_info& fi, Streambuf& streambuf, ReadHandler&& handler) { static_assert(beast::is_Streambuf::value, @@ -546,10 +534,10 @@ socket::async_read_frame(frame_info& fi, return completion.result.get(); } -template +template template void -socket::write( +stream::write( ConstBufferSequence const& bs, error_code& ec) { static_assert(beast::is_ConstBufferSequence< @@ -573,10 +561,10 @@ socket::write( } } -template +template template auto -socket::async_write( +stream::async_write( ConstBufferSequence const& bs, WriteHandler&& handler) { static_assert(beast::is_ConstBufferSequence< @@ -589,10 +577,10 @@ socket::async_write( return completion.result.get(); } -template +template template void -socket::write_frame(bool fin, +stream::write_frame(bool fin, ConstBufferSequence const& bs, error_code& ec) { static_assert(beast::is_ConstBufferSequence< @@ -617,7 +605,7 @@ socket::write_frame(bool fin, { // send header and payload boost::asio::write(stream_, - append_buffers(fh_buf.data(), bs), ec); + buffer_cat(fh_buf.data(), bs), ec); error_ = ec != 0; return; } @@ -640,7 +628,7 @@ socket::write_frame(bool fin, detail::mask_inplace(mb, key); // send header and payload boost::asio::write(stream_, - append_buffers(fh_buf.data(), mb), ec); + buffer_cat(fh_buf.data(), mb), ec); if(ec) { error_ = ec != 0; @@ -666,10 +654,10 @@ socket::write_frame(bool fin, } } -template +template template auto -socket::async_write_frame(bool fin, +stream::async_write_frame(bool fin, ConstBufferSequence const& bs, WriteHandler&& handler) { static_assert(beast::is_ConstBufferSequence< @@ -686,9 +674,9 @@ socket::async_write_frame(bool fin, //------------------------------------------------------------------------------ -template +template http::request -socket::build_request(boost::string_ref const& host, +stream::build_request(boost::string_ref const& host, boost::string_ref const& resource, std::string& key) { http::request req; @@ -705,10 +693,10 @@ socket::build_request(boost::string_ref const& host, return req; } -template +template template http::response -socket::build_response( +stream::build_response( http::message const& req) { auto err = @@ -757,10 +745,10 @@ socket::build_response( return resp; } -template +template template void -socket::do_response( +stream::do_response( http::message const& resp, boost::string_ref const& key, error_code& ec) { @@ -781,9 +769,9 @@ socket::do_response( role_ = role_type::client; } -template +template void -socket::do_read_fh( +stream::do_read_fh( detail::frame_streambuf& fb, close_code& code, error_code& ec) { @@ -809,7 +797,7 @@ socket::do_read_fh( prepare_fh(code); } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/impl/ssl.ipp b/src/beast/include/beast/websocket/impl/ssl.ipp similarity index 72% rename from src/beast/beast/wsproto/impl/ssl.ipp rename to src/beast/include/beast/websocket/impl/ssl.ipp index ec465db639..4e9440a8a3 100644 --- a/src/beast/beast/wsproto/impl/ssl.ipp +++ b/src/beast/include/beast/websocket/impl/ssl.ipp @@ -1,30 +1,18 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_IMPL_SSL_IPP_INCLUDED +#define BEAST_WEBSOCKET_IMPL_SSL_IPP_INCLUDED - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_SSL_IPP_INCLUDED -#define BEAST_WSPROTO_SSL_IPP_INCLUDED - -#include -#include +#include +#include namespace beast { -namespace wsproto { +namespace websocket { namespace detail { @@ -164,7 +152,7 @@ async_teardown( handler), stream}; } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/impl/teardown.ipp b/src/beast/include/beast/websocket/impl/teardown.ipp similarity index 72% rename from src/beast/beast/wsproto/impl/teardown.ipp rename to src/beast/include/beast/websocket/impl/teardown.ipp index 92e50fd0f4..e11992a6a7 100644 --- a/src/beast/beast/wsproto/impl/teardown.ipp +++ b/src/beast/include/beast/websocket/impl/teardown.ipp @@ -1,31 +1,19 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_IMPL_TEARDOWN_IPP +#define BEAST_WEBSOCKET_IMPL_TEARDOWN_IPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_TEARDOWN_IPP_INCLUDED -#define BEAST_WSPROTO_TEARDOWN_IPP_INCLUDED - -#include -#include +#include +#include #include namespace beast { -namespace wsproto { +namespace websocket { namespace detail { @@ -177,7 +165,7 @@ async_teardown( TeardownHandler>(handler), socket}; } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/impl/write_frame_op.ipp b/src/beast/include/beast/websocket/impl/write_frame_op.ipp similarity index 78% rename from src/beast/beast/wsproto/impl/write_frame_op.ipp rename to src/beast/include/beast/websocket/impl/write_frame_op.ipp index a374157094..3d0f72a188 100644 --- a/src/beast/beast/wsproto/impl/write_frame_op.ipp +++ b/src/beast/include/beast/websocket/impl/write_frame_op.ipp @@ -1,50 +1,38 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_IMPL_WRITE_FRAME_OP_HPP +#define BEAST_WEBSOCKET_IMPL_WRITE_FRAME_OP_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_WRITE_FRAME_OP_H_INCLUDED -#define BEAST_WSPROTO_WRITE_FRAME_OP_H_INCLUDED - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include namespace beast { -namespace wsproto { +namespace websocket { // write a frame // -template +template template -class socket::write_frame_op +class stream::write_frame_op { using alloc_type = handler_alloc; struct data : op { - socket& ws; + stream& ws; consuming_buffers cb; Handler h; detail::frame_header fh; @@ -57,7 +45,7 @@ class socket::write_frame_op int state = 0; template - data(DeducedHandler&& h_, socket& ws_, + data(DeducedHandler&& h_, stream& ws_, bool fin, Buffers const& bs) : ws(ws_) , cb(bs) @@ -106,7 +94,7 @@ public: template write_frame_op(DeducedHandler&& h, - socket& ws, Args&&... args) + stream& ws, Args&&... args) : d_(std::make_shared( std::forward(h), ws, std::forward(args)...)) @@ -155,10 +143,10 @@ public: } }; -template +template template void -socket:: +stream:: write_frame_op:: operator()( error_code ec, std::size_t bytes_transferred, bool again) @@ -214,7 +202,7 @@ operator()( assert(! d.ws.wr_block_); d.ws.wr_block_ = &d; boost::asio::async_write(d.ws.stream_, - append_buffers(d.fh_buf.data(), d.cb), + buffer_cat(d.fh_buf.data(), d.cb), std::move(*this)); return; } @@ -230,7 +218,7 @@ operator()( assert(! d.ws.wr_block_); d.ws.wr_block_ = &d; boost::asio::async_write(d.ws.stream_, - append_buffers(d.fh_buf.data(), + buffer_cat(d.fh_buf.data(), mb), std::move(*this)); return; } @@ -271,7 +259,7 @@ operator()( d.ws.rd_op_.maybe_invoke(); } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/impl/write_op.ipp b/src/beast/include/beast/websocket/impl/write_op.ipp similarity index 61% rename from src/beast/beast/wsproto/impl/write_op.ipp rename to src/beast/include/beast/websocket/impl/write_op.ipp index 24e48dd4d0..50fa14d43c 100644 --- a/src/beast/beast/wsproto/impl/write_op.ipp +++ b/src/beast/include/beast/websocket/impl/write_op.ipp @@ -1,49 +1,36 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_IMPL_WRITE_OP_HPP +#define BEAST_WEBSOCKET_IMPL_WRITE_OP_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_WRITE_OP_H_INCLUDED -#define BEAST_WSPROTO_WRITE_OP_H_INCLUDED - -#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include namespace beast { -namespace wsproto { +namespace websocket { // write a message // -template +template template -class socket::write_op +class stream::write_op { using alloc_type = handler_alloc; struct data : op { - socket& ws; + stream& ws; consuming_buffers cb; Handler h; std::size_t remain; @@ -52,7 +39,7 @@ class socket::write_op template data(DeducedHandler&& h_, - socket& ws_, Buffers const& bs) + stream& ws_, Buffers const& bs) : ws(ws_) , cb(bs) , h(std::forward(h_)) @@ -72,7 +59,7 @@ public: template explicit write_op(DeducedHandler&& h, - socket& ws, Args&&... args) + stream& ws, Args&&... args) : d_(std::allocate_shared(alloc_type{h}, std::forward(h), ws, std::forward(args)...)) @@ -113,10 +100,10 @@ public: } }; -template +template template void -socket:: +stream:: write_op:: operator()(error_code ec, bool again) { @@ -144,7 +131,7 @@ operator()(error_code ec, bool again) d.h(ec); } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/option.h b/src/beast/include/beast/websocket/option.hpp similarity index 84% rename from src/beast/beast/wsproto/option.h rename to src/beast/include/beast/websocket/option.hpp index f2fbb7b1fb..3f872f6507 100644 --- a/src/beast/beast/wsproto/option.h +++ b/src/beast/include/beast/websocket/option.hpp @@ -1,33 +1,21 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_OPTION_HPP +#define BEAST_WEBSOCKET_OPTION_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_OPTION_H_INCLUDED -#define BEAST_WSPROTO_OPTION_H_INCLUDED - -#include +#include #include #include #include #include namespace beast { -namespace wsproto { +namespace websocket { /** Automatic fragmentation size option. @@ -47,7 +35,7 @@ namespace wsproto { Setting the automatic fragmentation size option: @code ... - wsproto::socket stream(ios); + websocket::stream stream(ios); stream.set_option(auto_fragment_size{8192}); @endcode */ @@ -299,7 +287,7 @@ struct write_buffer_size }; #endif -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/rfc6455.h b/src/beast/include/beast/websocket/rfc6455.hpp similarity index 69% rename from src/beast/beast/wsproto/rfc6455.h rename to src/beast/include/beast/websocket/rfc6455.hpp index 84700f426a..3290b369fc 100644 --- a/src/beast/beast/wsproto/rfc6455.h +++ b/src/beast/include/beast/websocket/rfc6455.hpp @@ -1,32 +1,20 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_RFC6455_HPP +#define BEAST_WEBSOCKET_RFC6455_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_RFC6455_H_INCLUDED -#define BEAST_WSPROTO_RFC6455_H_INCLUDED - -#include +#include #include #include #include namespace beast { -namespace wsproto { +namespace websocket { /** WebSocket frame header opcodes. */ enum class opcode : std::uint8_t @@ -157,7 +145,7 @@ enum class role_type #endif -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/ssl.h b/src/beast/include/beast/websocket/ssl.hpp similarity index 61% rename from src/beast/beast/wsproto/ssl.h rename to src/beast/include/beast/websocket/ssl.hpp index e99faec6b5..8d7606b330 100644 --- a/src/beast/beast/wsproto/ssl.h +++ b/src/beast/include/beast/websocket/ssl.hpp @@ -1,32 +1,20 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_SSL_HPP +#define BEAST_WEBSOCKET_SSL_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_SSL_H_INCLUDED -#define BEAST_WSPROTO_SSL_H_INCLUDED - -#include +#include #include #include #include namespace beast { -namespace wsproto { +namespace websocket { /** Tear down a `boost::asio::ssl::stream`. @@ -78,9 +66,9 @@ async_teardown( boost::asio::ssl::stream& stream, TeardownHandler&& handler); -} // wsproto +} // websocket } // beast -#include +#include #endif diff --git a/src/beast/beast/wsproto/static_string.h b/src/beast/include/beast/websocket/static_string.hpp similarity index 98% rename from src/beast/beast/wsproto/static_string.h rename to src/beast/include/beast/websocket/static_string.hpp index 45eb085897..6cddcdc5cb 100644 --- a/src/beast/beast/wsproto/static_string.h +++ b/src/beast/include/beast/websocket/static_string.hpp @@ -17,8 +17,8 @@ */ //============================================================================== -#ifndef BEAST_WSPROTO_STATIC_STRING_H_INCLUDED -#define BEAST_WSPROTO_STATIC_STRING_H_INCLUDED +#ifndef BEAST_WEBSOCKET_STATIC_STRING_HPP +#define BEAST_WEBSOCKET_STATIC_STRING_HPP #include #include @@ -28,7 +28,7 @@ #include namespace beast { -namespace wsproto { +namespace websocket { /** A string with a fixed-size storage area. @@ -331,7 +331,7 @@ assign(CharT const* s) std::copy(s, s+n, s_.begin()); } -} // wsproto +} // websocket } // beast #endif diff --git a/src/beast/beast/wsproto/socket.h b/src/beast/include/beast/websocket/stream.hpp similarity index 90% rename from src/beast/beast/wsproto/socket.h rename to src/beast/include/beast/websocket/stream.hpp index d6f83ea7fd..537242aa8a 100644 --- a/src/beast/beast/wsproto/socket.h +++ b/src/beast/include/beast/websocket/stream.hpp @@ -1,30 +1,18 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. +#ifndef BEAST_WEBSOCKET_STREAM_HPP +#define BEAST_WEBSOCKET_STREAM_HPP - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_WSPROTO_SOCKET_H_INCLUDED -#define BEAST_WSPROTO_SOCKET_H_INCLUDED - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -32,7 +20,7 @@ #include namespace beast { -namespace wsproto { +namespace websocket { /** Information about a WebSocket frame. @@ -52,7 +40,7 @@ struct frame_info /** Provides message-oriented functionality using WebSocket. - The socket class template provides asynchronous and blocking + The stream class template provides asynchronous and blocking message-oriented functionality necessary for clients and servers to utilize the WebSocket protocol. @@ -64,37 +52,40 @@ struct frame_info @par Example - To use the WebSocket socket template with an + To use the WebSocket stream template with an ip::tcp::socket, you would write: @code - wsproto::socket ws(io_service); + websocket::stream ws(io_service); @endcode Alternatively, you can write: @code ip::tcp::socket sock(io_service); - wsproto::socket ws(sock); + websocket::stream ws(sock); @endcode - @note A socket object must not be destroyed while there are + @tparam NextLayer An object meeting the requirements of ReadStream, + WriteStream, AsyncReadStream, and AsyncWriteStream. + + @note A stream object must not be destroyed while there are pending asynchronous operations associated with it. @par Concepts AsyncReadStream, AsyncWriteStream, Decorator, Streambuf, SyncReadStream, SyncWriteStream. */ -template -class socket : public detail::socket_base +template +class stream : public detail::stream_base { friend class ws_test; - Stream next_layer_; - streambuf_readstream stream_; + NextLayer next_layer_; + streambuf_readstream stream_; public: /// The type of the next layer. using next_layer_type = - std::remove_reference_t; + std::remove_reference_t; /// The type of the lowest layer. using lowest_layer_type = @@ -113,42 +104,42 @@ public: typename protocol_type::resolver; /// Move constructor. - socket(socket&&) = default; + stream(stream&&) = default; /** Move assignment. Undefined behavior if operations are active or pending. */ - socket& operator=(socket&&) = default; + stream& operator=(stream&&) = default; - /** Construct a websocket. + /** Construct a WebSocket stream. - This constructor creates a websocket and initialises the - underlying stream object. + This constructor creates a websocket stream and initialises + the next layer object. - @throws Any exceptions thrown by the Stream constructor. + @throws Any exceptions thrown by the NextLayer constructor. @param args The arguments to be passed to initialise the - underlying stream object. The arguments are forwarded - to the stream's constructor. + next layer object. The arguments are forwarded to the next + layer's constructor. */ template explicit - socket(Args&&... args); + stream(Args&&... args); /** Destructor. A stream object must not be destroyed while there are pending asynchronous operations associated with it. */ - ~socket() = default; + ~stream() = default; - /** Set options on the socket. + /** Set options on the stream. The application must ensure that calls to set options are performed within the same implicit or explicit strand. - @param args One or more socket options to set. + @param args One or more stream options to set. */ #if GENERATING_DOCS template @@ -212,13 +203,13 @@ public: stream_.reserve(o.value); } - /** Get the io_service associated with the socket. + /** Get the io_service associated with the stream. This function may be used to obtain the io_service object - that the socket uses to dispatch handlers for asynchronous + that the stream uses to dispatch handlers for asynchronous operations. - @return A reference to the io_service object that the socket + @return A reference to the io_service object that the stream will use to dispatch handlers. Ownership is not transferred to the caller. */ @@ -300,7 +291,7 @@ public: Upgrade request and send the HTTP response. If the contents of the request are valid, the HTTP response - indicates a successful upgrade and the socket is then ready + indicates a successful upgrade and the stream is then ready to send and receive WebSocket protocol frames and messages. If the WebSocket HTTP Upgrade request cannot be satisfied, @@ -310,7 +301,7 @@ public: The call blocks until one of the following conditions is true: - @li An error occurs on the socket. + @li An error occurs on the stream. @li The entire HTTP response has been sent. @@ -330,7 +321,7 @@ public: Upgrade request and send the HTTP response. If the contents of the request are valid, the HTTP response - indicates a successful upgrade and the socket is then ready + indicates a successful upgrade and the stream is then ready to send and receive WebSocket protocol frames and messages. If the WebSocket HTTP Upgrade request cannot be satisfied, @@ -339,7 +330,7 @@ public: The call blocks until one of the following conditions is true: - @li An error occurs on the socket. + @li An error occurs on the stream. @li The entire HTTP response has been sent. @@ -355,7 +346,7 @@ public: always returns immediately. If the contents of the request are valid, the HTTP response - indicates a successful upgrade and the socket is then ready + indicates a successful upgrade and the stream is then ready to send and receive WebSocket protocol frames and messages. If the WebSocket HTTP Upgrade request cannot be satisfied, @@ -383,7 +374,7 @@ public: Upgrade request and send the HTTP response. If the contents of the request are valid, the HTTP response - indicates a successful upgrade and the socket is then ready + indicates a successful upgrade and the stream is then ready to send and receive WebSocket protocol frames and messages. If the WebSocket HTTP Upgrade request cannot be satisfied, @@ -392,13 +383,13 @@ public: The call blocks until one of the following conditions is true: - @li An error occurs on the socket. + @li An error occurs on the stream. @li The entire HTTP response has been sent. @param buffers Caller provide data that has already been - received on the socket. This may be used for implementations - allowing multiple protocols on the same socket. The + received on the stream. This may be used for implementations + allowing multiple protocols on the same stream. The buffered data will first be applied to the handshake, and then to received WebSocket frames. The implementation will copy the caller provided data before the function returns. @@ -415,7 +406,7 @@ public: Upgrade request and send the HTTP response. If the contents of the request are valid, the HTTP response - indicates a successful upgrade and the socket is then ready + indicates a successful upgrade and the stream is then ready to send and receive WebSocket protocol frames and messages. If the WebSocket HTTP Upgrade request cannot be satisfied, @@ -424,13 +415,13 @@ public: The call blocks until one of the following conditions is true: - @li An error occurs on the socket. + @li An error occurs on the stream. @li The entire HTTP response has been sent. @param buffers Caller provide data that has already been - received on the socket. This may be used for implementations - allowing multiple protocols on the same socket. The + received on the stream. This may be used for implementations + allowing multiple protocols on the same stream. The buffered data will first be applied to the handshake, and then to received WebSocket frames. The implementation will copy the caller provided data before the function returns. @@ -448,7 +439,7 @@ public: always returns immediately. If the contents of the request are valid, the HTTP response - indicates a successful upgrade and the socket is then ready + indicates a successful upgrade and the stream is then ready to send and receive WebSocket protocol frames and messages. If the WebSocket HTTP Upgrade request cannot be satisfied, @@ -456,8 +447,8 @@ public: code (typically 400, "Bad Request"). @param buffers Caller provide data that has already been - received on the socket. This may be used for implementations - allowing multiple protocols on the same socket. The + received on the stream. This may be used for implementations + allowing multiple protocols on the same stream. The buffered data will first be applied to the handshake, and then to received WebSocket frames. The implementation will copy the caller provided data before the function returns. @@ -484,7 +475,7 @@ public: to a HTTP WebSocket Upgrade request. If the contents of the request are valid, the HTTP response - indicates a successful upgrade and the socket is then ready + indicates a successful upgrade and the stream is then ready to send and receive WebSocket protocol frames and messages. If the WebSocket HTTP Upgrade request cannot be satisfied, @@ -493,7 +484,7 @@ public: The call blocks until one of the following conditions is true: - @li An error occurs on the socket. + @li An error occurs on the stream. @li The entire HTTP response has been sent. @@ -515,7 +506,7 @@ public: to a HTTP WebSocket Upgrade request. If the contents of the request are valid, the HTTP response - indicates a successful upgrade and the socket is then ready + indicates a successful upgrade and the stream is then ready to send and receive WebSocket protocol frames and messages. If the WebSocket HTTP Upgrade request cannot be satisfied, @@ -524,7 +515,7 @@ public: The call blocks until one of the following conditions is true: - @li An error occurs on the socket. + @li An error occurs on the stream. @li The entire HTTP response has been sent. @@ -546,7 +537,7 @@ public: always returns immediately. If the contents of the request are valid, the HTTP response - indicates a successful upgrade and the socket is then ready + indicates a successful upgrade and the stream is then ready to send and receive WebSocket protocol frames and messages. If the WebSocket HTTP Upgrade request cannot be satisfied, @@ -579,7 +570,7 @@ public: upgrade HTTP request. The call blocks until one of the following conditions is true: - @li An error occurs on the socket + @li An error occurs on the stream @li A complete HTTP response with the result of the upgrade request is received. @@ -594,7 +585,7 @@ public: @par Example @code - wsproto::socket ws(io_service); + websocket::stream ws(io_service); ... try { @@ -621,7 +612,7 @@ public: upgrade HTTP request. The call blocks until one of the following conditions is true: - @li An error occurs on the socket + @li An error occurs on the stream. @li A complete HTTP response with the result of the upgrade request is received. @@ -636,7 +627,7 @@ public: @par Example @code - wsproto::socket ws(io_service); + websocket::stream ws(io_service); ... error_code ec; ws.upgrade(host, resource, ec); @@ -975,7 +966,7 @@ public: @throws boost::system::system_error Thrown on failure. @note This function always sends an entire message. To - send a message in fragments, use `socket::write`. + send a message in fragments, use `write_frame`. */ template void @@ -1010,7 +1001,7 @@ public: until the completion handler is called. @note This function always sends an entire message. To - send a message in fragments, use `socket::write`. + send a message in fragments, use `write_frame`. */ template void @@ -1182,9 +1173,9 @@ private: close_code& code, error_code& ec); }; -} // wsproto +} // websocket } // beast -#include +#include #endif diff --git a/src/beast/beast/wsproto/teardown.h b/src/beast/include/beast/websocket/teardown.hpp similarity index 93% rename from src/beast/beast/wsproto/teardown.h rename to src/beast/include/beast/websocket/teardown.hpp index f184f9e63f..2bbc6e2437 100644 --- a/src/beast/beast/wsproto/teardown.h +++ b/src/beast/include/beast/websocket/teardown.hpp @@ -17,15 +17,15 @@ */ //============================================================================== -#ifndef BEAST_WSPROTO_TEARDOWN_H_INCLUDED -#define BEAST_WSPROTO_TEARDOWN_H_INCLUDED +#ifndef BEAST_WEBSOCKET_TEARDOWN_HPP +#define BEAST_WEBSOCKET_TEARDOWN_HPP -#include +#include #include #include namespace beast { -namespace wsproto { +namespace websocket { /** Tear down a connection. @@ -122,7 +122,7 @@ async_teardown( boost::asio::ip::tcp::socket& socket, TeardownHandler&& handler); -} // wsproto +} // websocket //------------------------------------------------------------------------------ @@ -136,9 +136,9 @@ namespace wsproto_helpers { template inline void -call_teardown(Socket& socket, wsproto::error_code& ec) +call_teardown(Socket& socket, websocket::error_code& ec) { - using wsproto::teardown; + using websocket::teardown; teardown(socket, ec); } @@ -147,15 +147,15 @@ inline void call_async_teardown(Socket& socket, TeardownHandler&& handler) { - using wsproto::async_teardown; + using websocket::async_teardown; async_teardown(socket, std::forward(handler)); } -} // wsproto_helpers +} // websocket_helpers } // beast -#include +#include #endif diff --git a/src/beast/src/beast_http_nodejs_parser.cpp b/src/beast/src/beast_http_nodejs_parser.cpp new file mode 100644 index 0000000000..cb1dccf905 --- /dev/null +++ b/src/beast/src/beast_http_nodejs_parser.cpp @@ -0,0 +1,17 @@ +// +// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifdef _MSC_VER +# pragma warning (push) +# pragma warning (disable: 4127) // conditional expression is constant +# pragma warning (disable: 4244) // integer conversion, possible loss of data +#endif +#include "http-parser/http_parser.c" +#ifdef _MSC_VER +# pragma warning (pop) +#endif + diff --git a/src/beast/beast/http/impl/http-parser/AUTHORS b/src/beast/src/http-parser/AUTHORS similarity index 100% rename from src/beast/beast/http/impl/http-parser/AUTHORS rename to src/beast/src/http-parser/AUTHORS diff --git a/src/beast/beast/http/impl/http-parser/LICENSE-MIT b/src/beast/src/http-parser/LICENSE-MIT similarity index 100% rename from src/beast/beast/http/impl/http-parser/LICENSE-MIT rename to src/beast/src/http-parser/LICENSE-MIT diff --git a/src/beast/beast/http/impl/http-parser/README.md b/src/beast/src/http-parser/README.md similarity index 100% rename from src/beast/beast/http/impl/http-parser/README.md rename to src/beast/src/http-parser/README.md diff --git a/src/beast/beast/http/impl/http-parser/http_parser.c b/src/beast/src/http-parser/http_parser.c similarity index 99% rename from src/beast/beast/http/impl/http-parser/http_parser.c rename to src/beast/src/http-parser/http_parser.c index d0c77ea73a..278d4b2077 100644 --- a/src/beast/beast/http/impl/http-parser/http_parser.c +++ b/src/beast/src/http-parser/http_parser.c @@ -21,7 +21,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ -#include "http_parser.h" +#include "../../include/beast/http/impl/http_parser.h" #include #include #include @@ -123,7 +123,7 @@ do { \ FOR##_mark = NULL; \ } \ } while (0) - + /* Run the data callback FOR and consume the current byte */ #define CALLBACK_DATA(FOR) \ CALLBACK_DATA_(FOR, p - FOR##_mark, p - data + 1) @@ -440,7 +440,7 @@ enum http_host_state * character or %x80-FF **/ #define IS_HEADER_CHAR(ch) \ - (ch == CR || ch == LF || ch == 9 || (ch > 31 && ch != 127)) + (ch == CR || ch == LF || ch == 9 || ((unsigned char)ch > 31 && ch != 127)) #define start_state (parser->type == HTTP_REQUEST ? s_start_req : s_start_res) @@ -1812,6 +1812,9 @@ reexecute: case 0: break; + case 2: + parser->upgrade = 1; + case 1: parser->flags |= F_SKIPBODY; break; diff --git a/src/beast/test/Jamfile b/src/beast/test/Jamfile index e407b93a0b..6b7870df07 100644 --- a/src/beast/test/Jamfile +++ b/src/beast/test/Jamfile @@ -7,24 +7,27 @@ import os ; -path-constant test_main : ../beast/unit_test/src/main.cpp ; - unit-test all : - append_buffers.cpp - asio.cpp + ../src/beast_http_nodejs_parser.cpp async_completion.cpp + base64.cpp basic_streambuf.cpp basic_headers.cpp bind_handler.cpp + buffer_cat.cpp buffers_adapter.cpp buffers_debug.cpp + chunk_encode.cpp consuming_buffers.cpp + empty_base_optimization.cpp handler_alloc.cpp + message.cpp placeholders.cpp prepare_buffers.cpp + rfc2616.cpp static_streambuf.cpp streambuf.cpp streambuf_readstream.cpp type_check.cpp - $(test_main) + main.cpp ; diff --git a/src/beast/test/async_completion.cpp b/src/beast/test/async_completion.cpp index 1118ab8044..6dd0636fe8 100644 --- a/src/beast/test/async_completion.cpp +++ b/src/beast/test/async_completion.cpp @@ -6,4 +6,4 @@ // // Test that header file is self-contained. -#include +#include diff --git a/src/beast/beast/crypto/tests/beast_base64_test.cpp b/src/beast/test/base64.cpp similarity index 84% rename from src/beast/beast/crypto/tests/beast_base64_test.cpp rename to src/beast/test/base64.cpp index d42a82802d..68d7d02829 100644 --- a/src/beast/beast/crypto/tests/beast_base64_test.cpp +++ b/src/beast/test/base64.cpp @@ -17,20 +17,21 @@ */ //============================================================================== -#include -#include +#include +#include namespace beast { +namespace test { -class base64_test : public unit_test::suite +class base64_test : public detail::unit_test::suite { public: void check (std::string const& in, std::string const& out) { - auto const encoded = base64_encode (in); + auto const encoded = detail::base64_encode (in); expect (encoded == out); - expect (base64_decode (encoded) == in); + expect (detail::base64_decode (encoded) == in); } void @@ -48,4 +49,6 @@ public: BEAST_DEFINE_TESTSUITE(base64,crypto,beast); -} +} // test +} // beast + diff --git a/src/beast/test/basic_headers.cpp b/src/beast/test/basic_headers.cpp index ece03c32af..fc78890e57 100644 --- a/src/beast/test/basic_headers.cpp +++ b/src/beast/test/basic_headers.cpp @@ -6,15 +6,15 @@ // // Test that header file is self-contained. -#include +#include -#include +#include namespace beast { namespace http { namespace test { -class basic_headers_test : public unit_test::suite +class basic_headers_test : public beast::detail::unit_test::suite { public: template diff --git a/src/beast/test/basic_streambuf.cpp b/src/beast/test/basic_streambuf.cpp index afe91596fa..f82d53854e 100644 --- a/src/beast/test/basic_streambuf.cpp +++ b/src/beast/test/basic_streambuf.cpp @@ -6,4 +6,4 @@ // // Test that header file is self-contained. -#include +#include diff --git a/src/beast/test/beast_wsproto_ws_test.cpp b/src/beast/test/beast_wsproto_ws_test.cpp deleted file mode 100644 index 8bddcd57a1..0000000000 --- a/src/beast/test/beast_wsproto_ws_test.cpp +++ /dev/null @@ -1,358 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include -#include -#include -#include - -namespace beast { -namespace wsproto { - -class ws_test : public unit_test::suite -{ -public: - using error_code = boost::system::error_code; - using endpoint_type = boost::asio::ip::tcp::endpoint; - using address_type = boost::asio::ip::address; - using socket_type = boost::asio::ip::tcp::socket; - using yield_context = boost::asio::yield_context; - - endpoint_type ep_; - - //-------------------------------------------------------------------------- - - // opcodes for creating the test plans - - // concurrent read and write - struct case_1{}; - - // write a bad frame and shut down - struct case_2{}; - - //-------------------------------------------------------------------------- - - class coro_peer - { - error_code ec_; - boost::asio::io_service ios_; - boost::asio::ip::tcp::acceptor acceptor_; - socket_type sock_; - socket ws_; - opcode::value op_; - beast::streambuf rb_; - beast::streambuf wb_; - yield_context* yield_; - int state_ = 0; - //unit_test::suite& test_; - - public: - coro_peer(coro_peer&&) = default; - coro_peer(coro_peer const&) = delete; - coro_peer& operator=(coro_peer&&) = delete; - coro_peer& operator=(coro_peer const&) = delete; - - template - coro_peer(bool server, endpoint_type ep, - unit_test::suite& test, Ops const&... ops) - : acceptor_(ios_) - , sock_(ios_) - , ws_(sock_) - //, test_(test) - { - if(server) - { - acceptor_.open(ep.protocol()); - acceptor_.bind(ep); - acceptor_.listen( - boost::asio::socket_base::max_connections); - boost::asio::spawn(ios_, - [=](auto yield) - { - yield_ = &yield; - state_ = 10; - acceptor_.async_accept(sock_, (*yield_)[ec_]); - if(ec_) - return this->fail("accept"); - state_ = 20; - ws_.async_accept((*yield_)[ec_]); - if(ec_) - return this->fail("ws.accept"); - this->invoke(ops...); - state_ = -1; - }); - } - else - { - boost::asio::spawn(ios_, - [=](auto yield) - { - yield_ = &yield; - state_ = 30; - sock_.async_connect(ep, (*yield_)[ec_]); - if(ec_) - return this->fail("connect"); - state_ = 40; - ws_.async_handshake(ep.address().to_string() + - std::to_string(ep.port()), "/", (*yield_)[ec_]); - if(ec_) - return this->fail("handshake"); - this->invoke(ops...); - state_ = -1; - }); - } - } - - ~coro_peer() - { - } - - int - state() const - { - return state_; - } - - void - run_one() - { - ios_.run_one(); - } - - void - step_to(int to = 0) - { - while(state_ != to) - ios_.run_one(); - } - - private: - template - void fail(String const& s) - { - } - - void invoke_1(case_1) - { - async_read(ws_, op_, rb_, - [&](auto ec) - { - if(ec) - return this->fail(ec); - rb_.consume(rb_.size()); - }); - state_ = 100; - async_write(ws_, opcode::text, - boost::asio::null_buffers{}, (*yield_)[ec_]); - if(ec_) - return fail("write"); - } - - void invoke_1(case_2) - { - detail::frame_header fh; - fh.op = opcode::rsv5; // bad opcode - fh.fin = true; - fh.mask = true; - fh.rsv1 = false; - fh.rsv2 = false; - fh.rsv3 = false; - fh.len = 0; - fh.key = 0; - detail::write(wb_, fh); - state_ = 200; - boost::asio::async_write( - ws_.next_layer(), wb_.data(), - (*yield_)[ec_]); - if(ec_) - return fail("write"); - ws_.next_layer().shutdown( - socket_type::shutdown_both, ec_); - if(ec_) - return fail("shutdown"); - } - - inline - void - invoke() - { - } - - template - inline - void - invoke(Op op, Ops const&... ops) - { - invoke_1(op); - invoke(ops...); - } - }; - - void - testInvokable() - { - endpoint_type const ep{ - address_type::from_string( - "127.0.0.1"), 6000}; - coro_peer server(true, ep, *this, case_1{}); - coro_peer client(false, ep, *this, case_2{}); - server.step_to(10); // async_accept - client.step_to(30); // async_connect - server.step_to(20); // async_accept(ws) - client.step_to(40); // async_handshake - server.step_to(100); // case_1 - client.step_to(200); // case_2 - client.step_to(-1); - server.step_to(-1); - } - - //-------------------------------------------------------------------------- - - void - maybe_fail(error_code const& ec, std::string const& what) - { - expect(! ec, what + ": " + ec.message()); - } - - void - maybe_throw(error_code ec, std::string what) - { - if(ec) - { - maybe_fail(ec, what); - throw ec; - } - } - - template - static - std::string - buffers_to_string(Buffers const& bs) - { - using boost::asio::buffer_cast; - using boost::asio::buffer_size; - std::string s; - s.reserve(buffer_size(bs)); - for(auto const& b : bs) - s.append(buffer_cast(b), - buffer_size(b)); - for(auto i = s.size(); i-- > 0;) - if(s[i] == '\r') - s.replace(i, 1, "\\r"); - else if(s[i] == '\n') - s.replace(i, 1, "\\n\n"); - return s; - } - - int - makeRequest(endpoint_type ep, std::string const& s) - { - using boost::asio::buffer; - boost::asio::io_service ios; - boost::asio::ip::tcp::socket sock(ios); - sock.connect(ep); - write(sock, append_buffers( - buffer(s), buffer("\r\n"))); - - using namespace http; - parsed_response m; - streambuf sb; - read(sock, sb, m); - return m.status; - } - - void - expectStatus(endpoint_type ep, - int status, std::string const& s) - { - expect(makeRequest(ep, s) == status); - } - - void - testHandshake(endpoint_type ep) - { - expectStatus(ep, 400, "GET / HTTP/1.0\r\n"); - } - - void - syncEchoClient(endpoint_type ep) - { - using boost::asio::buffer; - error_code ec; - boost::asio::io_service ios; - wsproto::socket ws(ios); - ws.next_layer().connect(ep, ec); - maybe_fail(ec, "connect"); - ws.handshake(ep.address().to_string(), "/", ec); - maybe_fail(ec, "upgrade"); - std::string const s = "Hello, world!"; - ws.write(wsproto::opcode::text, true, buffer(s), ec); - maybe_fail(ec, "write"); - boost::asio::streambuf sb; - wsproto::opcode::value op; - read(ws, op, sb, ec); - maybe_fail(ec, "read"); - if(! ec) - expect(op == wsproto::opcode::text); - expect(buffers_to_string(sb.data()) == s); - sb.consume(sb.size()); - ws.close({}, ec); - maybe_fail(ec, "close"); - while(! ec) - { - read(ws, op, sb, ec); - if(! ec) - sb.consume(sb.size()); - } - if(ec != error::closed) - maybe_fail(ec, "teardown"); - } - - void - run() override - { - //testInvokable(); - -#if 0 - { - endpoint_type ep{ - address_type::from_string("127.0.0.1"), 6000}; - testcase("Echo Server"); - test::sync_echo_peer s(true, ep, *this); - testHandshake(ep); - syncEchoClient(ep); - } -#endif - { - endpoint_type ep{ - address_type::from_string("127.0.0.1"), 6001}; - testcase("Async Echo Server"); - test::async_echo_peer s(true, ep, *this); - //testHandshake(ep); - syncEchoClient(ep); - } - } -}; - -BEAST_DEFINE_TESTSUITE(ws,asio,beast); - -} // wsproto -} // beast diff --git a/src/beast/test/bind_handler.cpp b/src/beast/test/bind_handler.cpp index 540efa5164..4bd49738cc 100644 --- a/src/beast/test/bind_handler.cpp +++ b/src/beast/test/bind_handler.cpp @@ -6,6 +6,32 @@ // // Test that header file is self-contained. -#include +#include -#include +#include +#include + +namespace beast { +namespace test { + +class bind_handler_test : public detail::unit_test::suite +{ +public: + static void foo (int) + { + } + + void run() + { + auto f (bind_handler ( + std::bind (&foo, std::placeholders::_1), + 42)); + f(); + pass(); + } +}; + +BEAST_DEFINE_TESTSUITE(bind_handler,asio,beast); + +} // test +} // beast diff --git a/src/beast/test/append_buffers.cpp b/src/beast/test/buffer_cat.cpp similarity index 81% rename from src/beast/test/append_buffers.cpp rename to src/beast/test/buffer_cat.cpp index 468b8622a3..88cb5004c0 100644 --- a/src/beast/test/append_buffers.cpp +++ b/src/beast/test/buffer_cat.cpp @@ -6,9 +6,9 @@ // // Test that header file is self-contained. -#include +#include -#include +#include #include #include #include @@ -16,14 +16,13 @@ #include namespace beast { -namespace asio { namespace test { -class append_buffers_test : public unit_test::suite +class buffer_cat_test : public detail::unit_test::suite { public: - void testAppendBuffers() + void testBufferCat() { using boost::asio::buffer_size; using boost::asio::const_buffer; @@ -40,7 +39,7 @@ public: std::list b5{ const_buffer{buf+9, 1}}; std::list b6; - auto bs = append_buffers( + auto bs = buffer_cat( b1, b2, b3, b4, b5, b6); expect(buffer_size(bs) == 10); std::vector v; @@ -54,23 +53,22 @@ public: bs3 = std::move(bs2); { boost::asio::streambuf sb1, sb2; - expect(buffer_size(append_buffers( + expect(buffer_size(buffer_cat( sb1.prepare(5), sb2.prepare(7))) == 12); sb1.commit(5); sb2.commit(7); - expect(buffer_size(append_buffers( + expect(buffer_size(buffer_cat( sb1.data(), sb2.data())) == 12); } } void run() override { - testAppendBuffers(); + testBufferCat(); } }; -BEAST_DEFINE_TESTSUITE(append_buffers,asio,beast); +BEAST_DEFINE_TESTSUITE(buffer_cat,asio,beast); } // test -} // asio } // beast diff --git a/src/beast/test/buffers_adapter.cpp b/src/beast/test/buffers_adapter.cpp index d2f3d73cf6..b70c545497 100644 --- a/src/beast/test/buffers_adapter.cpp +++ b/src/beast/test/buffers_adapter.cpp @@ -6,18 +6,17 @@ // // Test that header file is self-contained. -#include +#include -#include +#include #include #include #include namespace beast { -namespace asio { namespace test { -class buffers_adapter_test : public unit_test::suite +class buffers_adapter_test : public detail::unit_test::suite { public: template @@ -120,5 +119,4 @@ public: BEAST_DEFINE_TESTSUITE(buffers_adapter,asio,beast); } // test -} // asio } // beast diff --git a/src/beast/test/buffers_debug.cpp b/src/beast/test/buffers_debug.cpp index 231c49b499..cd420b8617 100644 --- a/src/beast/test/buffers_debug.cpp +++ b/src/beast/test/buffers_debug.cpp @@ -6,4 +6,4 @@ // // Test that header file is self-contained. -#include +#include diff --git a/src/beast/beast/http/src/test/beast_http_chunked_encoder_test.cpp b/src/beast/test/chunk_encode.cpp similarity index 96% rename from src/beast/beast/http/src/test/beast_http_chunked_encoder_test.cpp rename to src/beast/test/chunk_encode.cpp index 9684131e30..31ba7bc1c0 100644 --- a/src/beast/beast/http/src/test/beast_http_chunked_encoder_test.cpp +++ b/src/beast/test/chunk_encode.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include namespace beast { namespace http { namespace test { -class chunk_encode_test : public unit_test::suite +class chunk_encode_test : public beast::detail::unit_test::suite { public: // Convert CR LF to printables for display diff --git a/src/beast/test/consuming_buffers.cpp b/src/beast/test/consuming_buffers.cpp index c38355117b..9b3ce35345 100644 --- a/src/beast/test/consuming_buffers.cpp +++ b/src/beast/test/consuming_buffers.cpp @@ -6,17 +6,16 @@ // // Test that header file is self-contained. -#include +#include -#include +#include #include #include namespace beast { -namespace asio { namespace test { -class consuming_buffers_test : public unit_test::suite +class consuming_buffers_test : public beast::detail::unit_test::suite { public: template @@ -93,5 +92,4 @@ public: BEAST_DEFINE_TESTSUITE(consuming_buffers,asio,beast); } // test -} // asio } // beast diff --git a/src/beast/beast/test/beast_empty_base_optimization_test.cpp b/src/beast/test/empty_base_optimization.cpp similarity index 90% rename from src/beast/beast/test/beast_empty_base_optimization_test.cpp rename to src/beast/test/empty_base_optimization.cpp index c21ca370da..6e885aae3e 100644 --- a/src/beast/beast/test/beast_empty_base_optimization_test.cpp +++ b/src/beast/test/empty_base_optimization.cpp @@ -21,21 +21,22 @@ #include #endif -#include +#include -#include +#include namespace beast { +namespace test { class empty_base_optimization_test - : public unit_test::suite + : public beast::detail::unit_test::suite { public: template class test1 - : private empty_base_optimization + : private detail::empty_base_optimization { - using Base = empty_base_optimization; + using Base = detail::empty_base_optimization; void* m_p; public: explicit test1 (T const& t) @@ -104,4 +105,5 @@ public: BEAST_DEFINE_TESTSUITE(empty_base_optimization,utility,beast); +} // test } // beast diff --git a/src/beast/test/handler_alloc.cpp b/src/beast/test/handler_alloc.cpp index f90587b1dd..f27a1943a1 100644 --- a/src/beast/test/handler_alloc.cpp +++ b/src/beast/test/handler_alloc.cpp @@ -6,4 +6,4 @@ // // Test that header file is self-contained. -#include +#include diff --git a/src/beast/beast/unit_test/src/main.cpp b/src/beast/test/main.cpp similarity index 88% rename from src/beast/beast/unit_test/src/main.cpp rename to src/beast/test/main.cpp index 589012a9bb..22efdfcc4f 100644 --- a/src/beast/beast/unit_test/src/main.cpp +++ b/src/beast/test/main.cpp @@ -17,8 +17,9 @@ */ //============================================================================== -#include -#include +#include +#include +#include #ifdef _MSC_VER # ifndef WIN32_LEAN_AND_MEAN // VC_EXTRALEAN @@ -36,7 +37,7 @@ // alone executables that run unit tests. int main() { - using namespace beast::unit_test; + using namespace beast::detail::unit_test; #ifdef _MSC_VER { @@ -47,7 +48,7 @@ int main() #endif { - beast::debug_ostream s; + beast::detail::debug_ostream s; reporter r (s); bool failed (r.run_each (global_suites())); if (failed) diff --git a/src/beast/beast/http/src/test/beast_http_message_test.cpp b/src/beast/test/message.cpp similarity index 88% rename from src/beast/beast/http/src/test/beast_http_message_test.cpp rename to src/beast/test/message.cpp index 7266f7ef9f..ee6aee614f 100644 --- a/src/beast/beast/http/src/test/beast_http_message_test.cpp +++ b/src/beast/test/message.cpp @@ -17,13 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include +// Test that header file is self-contained. +#include + +#include +#include +#include +#include +#include +#include #include namespace beast { @@ -39,15 +41,15 @@ public: using socket_type = boost::asio::ip::tcp::socket; private: - unit_test::suite& suite_; + beast::detail::unit_test::suite& suite_; boost::asio::io_service ios_; socket_type sock_; boost::asio::ip::tcp::acceptor acceptor_; - unit_test::thread thread_; + beast::detail::unit_test::thread thread_; public: sync_echo_http_server( - endpoint_type ep, unit_test::suite& suite) + endpoint_type ep, beast::detail::unit_test::suite& suite) : suite_(suite) , sock_(ios_) , acceptor_(ios_) @@ -63,7 +65,7 @@ public: acceptor_.async_accept(sock_, std::bind(&sync_echo_http_server::on_accept, this, beast::asio::placeholders::error)); - thread_ = unit_test::thread(suite_, + thread_ = beast::detail::unit_test::thread(suite_, [&] { ios_.run(); @@ -132,7 +134,7 @@ private: } }; -class http_message_test : public unit_test::suite +class message_test : public beast::detail::unit_test::suite { public: using error_code = boost::system::error_code; @@ -174,12 +176,12 @@ public: void run() override { - testAsio(); + //testAsio(); pass(); } }; -BEAST_DEFINE_TESTSUITE_MANUAL(http_message,http,beast); +BEAST_DEFINE_TESTSUITE(message,http,beast); } // test } // http diff --git a/src/beast/test/placeholders.cpp b/src/beast/test/placeholders.cpp index b3df0f30e1..d16718b842 100644 --- a/src/beast/test/placeholders.cpp +++ b/src/beast/test/placeholders.cpp @@ -6,4 +6,4 @@ // // Test that header file is self-contained. -#include +#include diff --git a/src/beast/test/prepare_buffers.cpp b/src/beast/test/prepare_buffers.cpp index 842ec85f0a..8ec75ccf99 100644 --- a/src/beast/test/prepare_buffers.cpp +++ b/src/beast/test/prepare_buffers.cpp @@ -6,18 +6,17 @@ // // Test that header file is self-contained. -#include +#include -#include -#include +#include +#include #include #include namespace beast { -namespace asio { namespace test { -class prepare_buffers_test : public unit_test::suite +class prepare_buffers_test : public beast::detail::unit_test::suite { public: template @@ -83,7 +82,7 @@ public: cb.consume(1); expect(buffer_size(cb) == 0); expect(buffer_copy(cb, pb1) == 0); - + auto pbc = prepare_buffers(2, cb); expect(buffer_size(pbc) == 0); expect(buffer_copy(pbc, cb) == 0); @@ -99,5 +98,4 @@ public: BEAST_DEFINE_TESTSUITE(prepare_buffers,asio,beast); } // test -} // asio } // beast diff --git a/src/beast/beast/http/src/test/beast_http_rfc2616_test.cpp b/src/beast/test/rfc2616.cpp similarity index 96% rename from src/beast/beast/http/src/test/beast_http_rfc2616_test.cpp rename to src/beast/test/rfc2616.cpp index 54c220e5fe..c095bc3fb4 100644 --- a/src/beast/beast/http/src/test/beast_http_rfc2616_test.cpp +++ b/src/beast/test/rfc2616.cpp @@ -17,17 +17,16 @@ */ //============================================================================== -#include -#include +#include +#include #include #include - namespace beast { namespace rfc2616 { namespace test { -class rfc2616_test : public beast::unit_test::suite +class rfc2616_test : public beast::detail::unit_test::suite { public: void diff --git a/src/beast/test/ssl_error.cpp b/src/beast/test/ssl_error.cpp deleted file mode 100644 index d750c5de70..0000000000 --- a/src/beast/test/ssl_error.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include - -namespace beast { - -class ssl_error_test : public unit_test::suite -{ -public: - void run() - { - { - boost::system::error_code ec = - boost::system::error_code (335544539, - boost::asio::error::get_ssl_category ()); - std::string const s = beast::error_message_with_ssl(ec); - expect(s == " (20,0,219) error:140000DB:SSL routines:SSL routines:short read"); - } - } -}; - -BEAST_DEFINE_TESTSUITE(ssl_error,asio,beast); - -} // beast diff --git a/src/beast/test/static_streambuf.cpp b/src/beast/test/static_streambuf.cpp index ce97965d58..22c7bcc2b5 100644 --- a/src/beast/test/static_streambuf.cpp +++ b/src/beast/test/static_streambuf.cpp @@ -6,17 +6,16 @@ // // Test that header file is self-contained. -#include +#include -#include +#include #include #include namespace beast { -namespace asio { namespace test { -class static_streambuf_test : public unit_test::suite +class static_streambuf_test : public beast::detail::unit_test::suite { public: template @@ -109,5 +108,4 @@ public: BEAST_DEFINE_TESTSUITE(static_streambuf,asio,beast); } // test -} // asio -} // beast +} // beastp diff --git a/src/beast/test/streambuf.cpp b/src/beast/test/streambuf.cpp index 248771940c..8f7bc414a6 100644 --- a/src/beast/test/streambuf.cpp +++ b/src/beast/test/streambuf.cpp @@ -6,16 +6,15 @@ // // Test that header file is self-contained. -#include +#include -#include +#include #include #include #include #include namespace beast { -namespace asio { namespace test { struct test_allocator_info @@ -135,7 +134,7 @@ public: } }; -class streambuf_test : public unit_test::suite +class streambuf_test : public beast::detail::unit_test::suite { public: template @@ -287,5 +286,4 @@ public: BEAST_DEFINE_TESTSUITE(streambuf,asio,beast); } // test -} // asio } // beast diff --git a/src/beast/test/streambuf_readstream.cpp b/src/beast/test/streambuf_readstream.cpp index e35f5bfd8a..80d34f6b14 100644 --- a/src/beast/test/streambuf_readstream.cpp +++ b/src/beast/test/streambuf_readstream.cpp @@ -6,4 +6,4 @@ // // Test that header file is self-contained. -#include +#include diff --git a/src/beast/test/type_check.cpp b/src/beast/test/type_check.cpp index f25a3b3627..2bdde9a937 100644 --- a/src/beast/test/type_check.cpp +++ b/src/beast/test/type_check.cpp @@ -6,4 +6,4 @@ // // Test that header file is self-contained. -#include +#include diff --git a/src/ripple/app/ledger/InboundTransactions.h b/src/ripple/app/ledger/InboundTransactions.h index 4838a13d07..a2b669d2e4 100644 --- a/src/ripple/app/ledger/InboundTransactions.h +++ b/src/ripple/app/ledger/InboundTransactions.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index c4aabe64bd..7b2f2898dc 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/app/ledger/LedgerProposal.h b/src/ripple/app/ledger/LedgerProposal.h index 1bfe1334cd..f5cb774304 100644 --- a/src/ripple/app/ledger/LedgerProposal.h +++ b/src/ripple/app/ledger/LedgerProposal.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 72df7f60a9..ae8a9d46f0 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -72,7 +72,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index 3e22f647c3..5a79ac49ce 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -36,11 +36,11 @@ #include #include #include -#include +#include #include -#include +#include #include -#include +#include #include #include #include @@ -194,7 +194,7 @@ static int runUnitTests( std::string const& argument) { using namespace beast::unit_test; - beast::debug_ostream stream; + beast::detail::debug_ostream stream; reporter r (stream); r.arg(argument); bool const failed (r.run_each_if ( diff --git a/src/ripple/app/tests/AccountTxPaging.test.cpp b/src/ripple/app/tests/AccountTxPaging.test.cpp index eb5e24f15e..04fc2037c4 100644 --- a/src/ripple/app/tests/AccountTxPaging.test.cpp +++ b/src/ripple/app/tests/AccountTxPaging.test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/app/tests/AmendmentTable.test.cpp b/src/ripple/app/tests/AmendmentTable.test.cpp index b8888e9ade..f5b4d28e47 100644 --- a/src/ripple/app/tests/AmendmentTable.test.cpp +++ b/src/ripple/app/tests/AmendmentTable.test.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/app/tests/CrossingLimits_test.cpp b/src/ripple/app/tests/CrossingLimits_test.cpp index 8cecfbb9b1..e33f520ad8 100644 --- a/src/ripple/app/tests/CrossingLimits_test.cpp +++ b/src/ripple/app/tests/CrossingLimits_test.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include namespace ripple { namespace test { diff --git a/src/ripple/app/tests/DeliverMin.test.cpp b/src/ripple/app/tests/DeliverMin.test.cpp index 6c585babaf..e37ab6a1d8 100644 --- a/src/ripple/app/tests/DeliverMin.test.cpp +++ b/src/ripple/app/tests/DeliverMin.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace ripple { namespace test { diff --git a/src/ripple/app/tests/HashRouter_test.cpp b/src/ripple/app/tests/HashRouter_test.cpp index 825f25ab1f..9e5e6ca4c6 100644 --- a/src/ripple/app/tests/HashRouter_test.cpp +++ b/src/ripple/app/tests/HashRouter_test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace ripple { namespace test { diff --git a/src/ripple/app/tests/OfferStream.test.cpp b/src/ripple/app/tests/OfferStream.test.cpp index 83afd21632..f7072faa32 100644 --- a/src/ripple/app/tests/OfferStream.test.cpp +++ b/src/ripple/app/tests/OfferStream.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace ripple { diff --git a/src/ripple/app/tests/OversizeMeta_test.cpp b/src/ripple/app/tests/OversizeMeta_test.cpp index 7e47ce3255..54063ec21a 100644 --- a/src/ripple/app/tests/OversizeMeta_test.cpp +++ b/src/ripple/app/tests/OversizeMeta_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include namespace ripple { diff --git a/src/ripple/app/tests/Path_test.cpp b/src/ripple/app/tests/Path_test.cpp index b5e9ca3fdf..cff523126b 100644 --- a/src/ripple/app/tests/Path_test.cpp +++ b/src/ripple/app/tests/Path_test.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/app/tests/Taker.test.cpp b/src/ripple/app/tests/Taker.test.cpp index 84dfebb29f..eb2d440d9c 100644 --- a/src/ripple/app/tests/Taker.test.cpp +++ b/src/ripple/app/tests/Taker.test.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include #include #include diff --git a/src/ripple/basics/BasicConfig.h b/src/ripple/basics/BasicConfig.h index fac8ccff4e..dfc45fe921 100644 --- a/src/ripple/basics/BasicConfig.h +++ b/src/ripple/basics/BasicConfig.h @@ -21,8 +21,8 @@ #define RIPPLE_BASICS_BASICCONFIG_H_INCLUDED #include -#include -#include +#include +#include #include #include #include @@ -40,8 +40,8 @@ using IniFileSections = std::map>; A configuration file contains zero or more sections. */ class Section - : public beast::const_container < - std::map > + : public beast::detail::const_container < + std::map > { private: std::string name_; @@ -165,7 +165,7 @@ public: class BasicConfig { private: - std::map map_; + std::map map_; public: /** Returns `true` if a section with the given name exists. */ diff --git a/src/ripple/basics/KeyCache.h b/src/ripple/basics/KeyCache.h index 13285fb25c..3cb0bb64a5 100644 --- a/src/ripple/basics/KeyCache.h +++ b/src/ripple/basics/KeyCache.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/src/ripple/basics/Log.h b/src/ripple/basics/Log.h index 6a8e8929d9..12701af98e 100644 --- a/src/ripple/basics/Log.h +++ b/src/ripple/basics/Log.h @@ -21,7 +21,7 @@ #define RIPPLE_BASICS_LOG_H_INCLUDED #include -#include +#include #include #include #include @@ -148,7 +148,7 @@ private: std::mutex mutable mutex_; std::map , - beast::ci_less> sinks_; + beast::detail::ci_less> sinks_; beast::severities::Severity thresh_; File file_; bool silent_ = false; diff --git a/src/ripple/basics/TaggedCache.h b/src/ripple/basics/TaggedCache.h index 3d99348a00..2105eb5c04 100644 --- a/src/ripple/basics/TaggedCache.h +++ b/src/ripple/basics/TaggedCache.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/basics/TestSuite.h b/src/ripple/basics/TestSuite.h index cb6819a9d4..eb8ee2e1f0 100644 --- a/src/ripple/basics/TestSuite.h +++ b/src/ripple/basics/TestSuite.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_TESTSUITE_H_INCLUDED #define RIPPLE_BASICS_TESTSUITE_H_INCLUDED -#include +#include #include namespace ripple { diff --git a/src/ripple/basics/UnorderedContainers.h b/src/ripple/basics/UnorderedContainers.h index 6497da4a72..1535cbaef7 100644 --- a/src/ripple/basics/UnorderedContainers.h +++ b/src/ripple/basics/UnorderedContainers.h @@ -21,9 +21,9 @@ #define RIPPLE_BASICS_UNORDEREDCONTAINERS_H_INCLUDED #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/basics/chrono.h b/src/ripple/basics/chrono.h index b8647d0209..198fdce596 100644 --- a/src/ripple/basics/chrono.h +++ b/src/ripple/basics/chrono.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_BASICS_CHRONO_H_INCLUDED #define RIPPLE_BASICS_CHRONO_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/basics/hardened_hash.h b/src/ripple/basics/hardened_hash.h index 01bc9e5435..3ef8bdf20a 100644 --- a/src/ripple/basics/hardened_hash.h +++ b/src/ripple/basics/hardened_hash.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_BASICS_HARDENED_HASH_H_INCLUDED #define RIPPLE_BASICS_HARDENED_HASH_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/ripple/basics/impl/CheckLibraryVersions.cpp b/src/ripple/basics/impl/CheckLibraryVersions.cpp index f436604960..5009ccdfd1 100644 --- a/src/ripple/basics/impl/CheckLibraryVersions.cpp +++ b/src/ripple/basics/impl/CheckLibraryVersions.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/basics/impl/RangeSet.cpp b/src/ripple/basics/impl/RangeSet.cpp index 8471f69771..ffd3bdd85b 100644 --- a/src/ripple/basics/impl/RangeSet.cpp +++ b/src/ripple/basics/impl/RangeSet.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/basics/impl/ResolverAsio.cpp b/src/ripple/basics/impl/ResolverAsio.cpp index 928b65f8f5..71544665e8 100644 --- a/src/ripple/basics/impl/ResolverAsio.cpp +++ b/src/ripple/basics/impl/ResolverAsio.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/basics/impl/StringUtilities.cpp b/src/ripple/basics/impl/StringUtilities.cpp index 95e9ce5e92..df7a20666a 100644 --- a/src/ripple/basics/impl/StringUtilities.cpp +++ b/src/ripple/basics/impl/StringUtilities.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/basics/random.h b/src/ripple/basics/random.h index f663328664..b78b0b868c 100644 --- a/src/ripple/basics/random.h +++ b/src/ripple/basics/random.h @@ -21,8 +21,8 @@ #define RIPPLE_BASICS_RANDOM_H_INCLUDED #include -#include -#include +#include +#include #include #include #include @@ -50,7 +50,7 @@ namespace detail { // Determines if a type can be called like an Engine template using is_engine = - beast::is_call_possible; + beast::detail::is_call_possible; } /** Return the default random engine. diff --git a/src/ripple/basics/tests/CheckLibraryVersions.test.cpp b/src/ripple/basics/tests/CheckLibraryVersions.test.cpp index 87a3bfbab2..84fd4ecdcb 100644 --- a/src/ripple/basics/tests/CheckLibraryVersions.test.cpp +++ b/src/ripple/basics/tests/CheckLibraryVersions.test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace ripple { namespace version { diff --git a/src/ripple/basics/tests/KeyCache.test.cpp b/src/ripple/basics/tests/KeyCache.test.cpp index 35d2099229..7a2149ae64 100644 --- a/src/ripple/basics/tests/KeyCache.test.cpp +++ b/src/ripple/basics/tests/KeyCache.test.cpp @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/basics/tests/RangeSet.test.cpp b/src/ripple/basics/tests/RangeSet.test.cpp index 25c81240d9..f5609ab60a 100644 --- a/src/ripple/basics/tests/RangeSet.test.cpp +++ b/src/ripple/basics/tests/RangeSet.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace ripple { diff --git a/src/ripple/basics/tests/StringUtilities.test.cpp b/src/ripple/basics/tests/StringUtilities.test.cpp index 602400b05a..98ff48b4e9 100644 --- a/src/ripple/basics/tests/StringUtilities.test.cpp +++ b/src/ripple/basics/tests/StringUtilities.test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/basics/tests/TaggedCache.test.cpp b/src/ripple/basics/tests/TaggedCache.test.cpp index d129c8b962..98167d3b79 100644 --- a/src/ripple/basics/tests/TaggedCache.test.cpp +++ b/src/ripple/basics/tests/TaggedCache.test.cpp @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/basics/tests/contract.test.cpp b/src/ripple/basics/tests/contract.test.cpp index 70cf7e209f..8aac1ad142 100644 --- a/src/ripple/basics/tests/contract.test.cpp +++ b/src/ripple/basics/tests/contract.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include namespace ripple { diff --git a/src/ripple/basics/tests/hardened_hash_test.cpp b/src/ripple/basics/tests/hardened_hash_test.cpp index 663dd7dd65..97940b6e79 100644 --- a/src/ripple/basics/tests/hardened_hash_test.cpp +++ b/src/ripple/basics/tests/hardened_hash_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/ripple/basics/tests/mulDiv.test.cpp b/src/ripple/basics/tests/mulDiv.test.cpp index 2658556bd5..109a36a44d 100644 --- a/src/ripple/basics/tests/mulDiv.test.cpp +++ b/src/ripple/basics/tests/mulDiv.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace ripple { namespace test { diff --git a/src/beast/beast/asio/io_latency_probe.h b/src/ripple/beast/asio/io_latency_probe.h similarity index 100% rename from src/beast/beast/asio/io_latency_probe.h rename to src/ripple/beast/asio/io_latency_probe.h diff --git a/src/beast/beast/asio/ssl_bundle.h b/src/ripple/beast/asio/ssl_bundle.h similarity index 100% rename from src/beast/beast/asio/ssl_bundle.h rename to src/ripple/beast/asio/ssl_bundle.h diff --git a/src/beast/beast/asio/ssl_error.h b/src/ripple/beast/asio/ssl_error.h similarity index 100% rename from src/beast/beast/asio/ssl_error.h rename to src/ripple/beast/asio/ssl_error.h diff --git a/src/beast/beast/clock/abstract_clock.h b/src/ripple/beast/clock/abstract_clock.h similarity index 100% rename from src/beast/beast/clock/abstract_clock.h rename to src/ripple/beast/clock/abstract_clock.h diff --git a/src/beast/beast/clock/basic_seconds_clock.h b/src/ripple/beast/clock/basic_seconds_clock.h similarity index 99% rename from src/beast/beast/clock/basic_seconds_clock.h rename to src/ripple/beast/clock/basic_seconds_clock.h index d2ce40db56..2450b8f622 100644 --- a/src/beast/beast/clock/basic_seconds_clock.h +++ b/src/ripple/beast/clock/basic_seconds_clock.h @@ -20,7 +20,7 @@ #ifndef BEAST_CHRONO_BASIC_SECONDS_CLOCK_H_INCLUDED #define BEAST_CHRONO_BASIC_SECONDS_CLOCK_H_INCLUDED -#include +#include #include #include diff --git a/src/beast/beast/clock/chrono_util.h b/src/ripple/beast/clock/chrono_util.h similarity index 100% rename from src/beast/beast/clock/chrono_util.h rename to src/ripple/beast/clock/chrono_util.h diff --git a/src/beast/beast/clock/manual_clock.h b/src/ripple/beast/clock/manual_clock.h similarity index 98% rename from src/beast/beast/clock/manual_clock.h rename to src/ripple/beast/clock/manual_clock.h index 23b5165cd7..96baae4fcd 100644 --- a/src/beast/beast/clock/manual_clock.h +++ b/src/ripple/beast/clock/manual_clock.h @@ -20,7 +20,7 @@ #ifndef BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED #define BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED -#include +#include #include namespace beast { diff --git a/src/beast/beast/clock/tests/beast_abstract_clock_test.cpp b/src/ripple/beast/clock/tests/beast_abstract_clock_test.cpp similarity index 95% rename from src/beast/beast/clock/tests/beast_abstract_clock_test.cpp rename to src/ripple/beast/clock/tests/beast_abstract_clock_test.cpp index 1487f8aa11..3f67cdbc4b 100644 --- a/src/beast/beast/clock/tests/beast_abstract_clock_test.cpp +++ b/src/ripple/beast/clock/tests/beast_abstract_clock_test.cpp @@ -19,9 +19,9 @@ // MODULES: ../impl/chrono_io.cpp -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/beast/beast/clock/tests/beast_basic_seconds_clock_test.cpp b/src/ripple/beast/clock/tests/beast_basic_seconds_clock_test.cpp similarity index 93% rename from src/beast/beast/clock/tests/beast_basic_seconds_clock_test.cpp rename to src/ripple/beast/clock/tests/beast_basic_seconds_clock_test.cpp index 227aba5466..7a439aecd6 100644 --- a/src/beast/beast/clock/tests/beast_basic_seconds_clock_test.cpp +++ b/src/ripple/beast/clock/tests/beast_basic_seconds_clock_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include +#include -#include +#include namespace beast { diff --git a/src/ripple/beast/container/detail/aged_ordered_container.h b/src/ripple/beast/container/detail/aged_ordered_container.h index 3ee9cfb66c..4eb78666a2 100644 --- a/src/ripple/beast/container/detail/aged_ordered_container.h +++ b/src/ripple/beast/container/detail/aged_ordered_container.h @@ -23,8 +23,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -33,7 +33,7 @@ #include #include #include -#include // +#include // #include namespace beast { @@ -445,13 +445,13 @@ public: // A set iterator (IsMap==false) is always const // because the elements of a set are immutable. - using iterator = detail::aged_container_iterator< + using iterator = beast::detail::aged_container_iterator< ! IsMap, typename cont_type::iterator>; - using const_iterator = detail::aged_container_iterator< + using const_iterator = beast::detail::aged_container_iterator< true, typename cont_type::iterator>; - using reverse_iterator = detail::aged_container_iterator< + using reverse_iterator = beast::detail::aged_container_iterator< ! IsMap, typename cont_type::reverse_iterator>; - using const_reverse_iterator = detail::aged_container_iterator< + using const_reverse_iterator = beast::detail::aged_container_iterator< true, typename cont_type::reverse_iterator>; //-------------------------------------------------------------------------- @@ -468,13 +468,13 @@ public: public: // A set iterator (IsMap==false) is always const // because the elements of a set are immutable. - using iterator = detail::aged_container_iterator< + using iterator = beast::detail::aged_container_iterator< ! IsMap, typename list_type::iterator>; - using const_iterator = detail::aged_container_iterator< + using const_iterator = beast::detail::aged_container_iterator< true, typename list_type::iterator>; - using reverse_iterator = detail::aged_container_iterator< + using reverse_iterator = beast::detail::aged_container_iterator< ! IsMap, typename list_type::reverse_iterator>; - using const_reverse_iterator = detail::aged_container_iterator< + using const_reverse_iterator = beast::detail::aged_container_iterator< true, typename list_type::reverse_iterator>; iterator begin () @@ -966,16 +966,16 @@ public: // enable_if prevents erase (reverse_iterator pos) from compiling template ::value>> - detail::aged_container_iterator - erase (detail::aged_container_iterator pos); + beast::detail::aged_container_iterator + erase (beast::detail::aged_container_iterator pos); // enable_if prevents erase (reverse_iterator first, reverse_iterator last) // from compiling template ::value>> - detail::aged_container_iterator - erase (detail::aged_container_iterator first, - detail::aged_container_iterator last); + beast::detail::aged_container_iterator + erase (beast::detail::aged_container_iterator first, + beast::detail::aged_container_iterator last); template auto @@ -991,7 +991,7 @@ public: template ::value>> void - touch (detail::aged_container_iterator pos) + touch (beast::detail::aged_container_iterator pos) { touch (pos, clock().now()); } @@ -1220,7 +1220,7 @@ private: template ::value>> void - touch (detail::aged_container_iterator < + touch (beast::detail::aged_container_iterator < is_const, Iterator, Base> pos, typename clock_type::time_point const& now); @@ -1768,27 +1768,27 @@ emplace_hint (const_iterator hint, Args&&... args) -> template template -detail::aged_container_iterator +beast::detail::aged_container_iterator aged_ordered_container :: -erase (detail::aged_container_iterator pos) +erase (beast::detail::aged_container_iterator pos) { unlink_and_delete_element(&*((pos++).iterator())); - return detail::aged_container_iterator < + return beast::detail::aged_container_iterator < false, Iterator, Base> (pos.iterator()); } template template -detail::aged_container_iterator +beast::detail::aged_container_iterator aged_ordered_container :: -erase (detail::aged_container_iterator first, - detail::aged_container_iterator last) +erase (beast::detail::aged_container_iterator first, + beast::detail::aged_container_iterator last) { for (; first != last;) unlink_and_delete_element(&*((first++).iterator())); - return detail::aged_container_iterator < + return beast::detail::aged_container_iterator < false, Iterator, Base> (first.iterator()); } @@ -1884,7 +1884,7 @@ template void aged_ordered_container :: -touch (detail::aged_container_iterator < +touch (beast::detail::aged_container_iterator < is_const, Iterator, Base> pos, typename clock_type::time_point const& now) { @@ -1923,7 +1923,7 @@ swap_data (aged_ordered_container& other) noexcept template -struct is_aged_container > : std::true_type { @@ -1934,9 +1934,9 @@ struct is_aged_container void swap ( - detail::aged_ordered_container & lhs, - detail::aged_ordered_container & rhs) noexcept { lhs.swap (rhs); diff --git a/src/ripple/beast/container/detail/aged_unordered_container.h b/src/ripple/beast/container/detail/aged_unordered_container.h index afb9a2f5a8..ee4d34bd71 100644 --- a/src/ripple/beast/container/detail/aged_unordered_container.h +++ b/src/ripple/beast/container/detail/aged_unordered_container.h @@ -23,8 +23,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -618,14 +618,14 @@ public: // A set iterator (IsMap==false) is always const // because the elements of a set are immutable. - using iterator= detail::aged_container_iterator ; - using const_iterator = detail::aged_container_iterator ; - using local_iterator = detail::aged_container_iterator ; - using const_local_iterator = detail::aged_container_iterator ; //-------------------------------------------------------------------------- @@ -642,13 +642,13 @@ public: public: // A set iterator (IsMap==false) is always const // because the elements of a set are immutable. - using iterator = detail::aged_container_iterator < + using iterator = beast::detail::aged_container_iterator < ! IsMap, typename list_type::iterator>; - using const_iterator = detail::aged_container_iterator < + using const_iterator = beast::detail::aged_container_iterator < true, typename list_type::iterator>; - using reverse_iterator = detail::aged_container_iterator < + using reverse_iterator = beast::detail::aged_container_iterator < ! IsMap, typename list_type::reverse_iterator>; - using const_reverse_iterator = detail::aged_container_iterator < + using const_reverse_iterator = beast::detail::aged_container_iterator < true, typename list_type::reverse_iterator>; iterator begin () @@ -1143,15 +1143,15 @@ public: } template - detail::aged_container_iterator - erase (detail::aged_container_iterator < + beast::detail::aged_container_iterator + erase (beast::detail::aged_container_iterator < is_const, Iterator, Base> pos); template - detail::aged_container_iterator - erase (detail::aged_container_iterator < + beast::detail::aged_container_iterator + erase (beast::detail::aged_container_iterator < is_const, Iterator, Base> first, - detail::aged_container_iterator < + beast::detail::aged_container_iterator < is_const, Iterator, Base> last); template @@ -1164,7 +1164,7 @@ public: template void - touch (detail::aged_container_iterator < + touch (beast::detail::aged_container_iterator < is_const, Iterator, Base> pos) { touch (pos, clock().now()); @@ -1459,7 +1459,7 @@ private: template void - touch (detail::aged_container_iterator < + touch (beast::detail::aged_container_iterator < is_const, Iterator, Base> pos, typename clock_type::time_point const& now) { @@ -2297,32 +2297,32 @@ emplace_hint (const_iterator /*hint*/, Args&&... args) -> template template -detail::aged_container_iterator +beast::detail::aged_container_iterator aged_unordered_container :: -erase (detail::aged_container_iterator < +erase (beast::detail::aged_container_iterator < is_const, Iterator, Base> pos) { unlink_and_delete_element(&*((pos++).iterator())); - return detail::aged_container_iterator < + return beast::detail::aged_container_iterator < false, Iterator, Base> (pos.iterator()); } template template -detail::aged_container_iterator +beast::detail::aged_container_iterator aged_unordered_container :: -erase (detail::aged_container_iterator < +erase (beast::detail::aged_container_iterator < is_const, Iterator, Base> first, - detail::aged_container_iterator < + beast::detail::aged_container_iterator < is_const, Iterator, Base> last) { for (; first != last;) unlink_and_delete_element(&*((first++).iterator())); - return detail::aged_container_iterator < + return beast::detail::aged_container_iterator < false, Iterator, Base> (first.iterator()); } @@ -2510,7 +2510,7 @@ insert_unchecked (value_type const& value) -> template -struct is_aged_container > : std::true_type { @@ -2521,9 +2521,9 @@ struct is_aged_container void swap ( - detail::aged_unordered_container & lhs, - detail::aged_unordered_container & rhs) noexcept { lhs.swap (rhs); @@ -2533,7 +2533,7 @@ void swap ( template -std::size_t expire (detail::aged_unordered_container < +std::size_t expire (beast::detail::aged_unordered_container < IsMulti, IsMap, Key, T, Clock, Hash, KeyEqual, Allocator>& c, std::chrono::duration const& age) noexcept { diff --git a/src/ripple/beast/container/tests/aged_associative_container.test.cpp b/src/ripple/beast/container/tests/aged_associative_container.test.cpp index 020979192f..79369a459a 100644 --- a/src/ripple/beast/container/tests/aged_associative_container.test.cpp +++ b/src/ripple/beast/container/tests/aged_associative_container.test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/ripple/beast/core/LexicalCast.cpp b/src/ripple/beast/core/LexicalCast.cpp index 64868dd305..30b0f8f31a 100644 --- a/src/ripple/beast/core/LexicalCast.cpp +++ b/src/ripple/beast/core/LexicalCast.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace beast { diff --git a/src/ripple/beast/core/List.h b/src/ripple/beast/core/List.h index 8679f2f560..753de93378 100644 --- a/src/ripple/beast/core/List.h +++ b/src/ripple/beast/core/List.h @@ -73,7 +73,7 @@ class ListIterator : public std::iterator < std::bidirectional_iterator_tag, std::size_t> { public: - using value_type = typename detail::CopyConst < + using value_type = typename beast::detail::CopyConst < N, typename N::value_type>::type; using pointer = value_type*; using reference = value_type&; diff --git a/src/ripple/beast/core/RelativeTime.cpp b/src/ripple/beast/core/RelativeTime.cpp index af2fda4e91..1400c73f33 100644 --- a/src/ripple/beast/core/RelativeTime.cpp +++ b/src/ripple/beast/core/RelativeTime.cpp @@ -257,7 +257,7 @@ static double getStartupTime() { StaticInitializer () { - when = detail::monotonicCurrentTimeInSeconds(); + when = beast::detail::monotonicCurrentTimeInSeconds(); } double when; diff --git a/src/ripple/beast/core/SemanticVersion.cpp b/src/ripple/beast/core/SemanticVersion.cpp index d7e400dc8a..6f9b8c0367 100644 --- a/src/ripple/beast/core/SemanticVersion.cpp +++ b/src/ripple/beast/core/SemanticVersion.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include diff --git a/src/beast/beast/crypto/detail/mac_facade.h b/src/ripple/beast/crypto/detail/mac_facade.h similarity index 96% rename from src/beast/beast/crypto/detail/mac_facade.h rename to src/ripple/beast/crypto/detail/mac_facade.h index 8fb80506ae..a2f6aa5fd8 100644 --- a/src/beast/beast/crypto/detail/mac_facade.h +++ b/src/ripple/beast/crypto/detail/mac_facade.h @@ -20,8 +20,8 @@ #ifndef BEAST_CRYPTO_MAC_FACADE_H_INCLUDED #define BEAST_CRYPTO_MAC_FACADE_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/beast/beast/crypto/detail/ripemd_context.h b/src/ripple/beast/crypto/detail/ripemd_context.h similarity index 100% rename from src/beast/beast/crypto/detail/ripemd_context.h rename to src/ripple/beast/crypto/detail/ripemd_context.h diff --git a/src/beast/beast/crypto/detail/sha2_context.h b/src/ripple/beast/crypto/detail/sha2_context.h similarity index 100% rename from src/beast/beast/crypto/detail/sha2_context.h rename to src/ripple/beast/crypto/detail/sha2_context.h diff --git a/src/beast/beast/crypto/ripemd.h b/src/ripple/beast/crypto/ripemd.h similarity index 92% rename from src/beast/beast/crypto/ripemd.h rename to src/ripple/beast/crypto/ripemd.h index 968ffecced..5db5a2742f 100644 --- a/src/beast/beast/crypto/ripemd.h +++ b/src/ripple/beast/crypto/ripemd.h @@ -20,8 +20,8 @@ #ifndef BEAST_CRYPTO_RIPEMD_H_INCLUDED #define BEAST_CRYPTO_RIPEMD_H_INCLUDED -#include -#include +#include +#include namespace beast { diff --git a/src/beast/beast/crypto/secure_erase.h b/src/ripple/beast/crypto/secure_erase.h similarity index 100% rename from src/beast/beast/crypto/secure_erase.h rename to src/ripple/beast/crypto/secure_erase.h diff --git a/src/beast/beast/crypto/sha2.h b/src/ripple/beast/crypto/sha2.h similarity index 93% rename from src/beast/beast/crypto/sha2.h rename to src/ripple/beast/crypto/sha2.h index 203b5c3cfe..72233ad227 100644 --- a/src/beast/beast/crypto/sha2.h +++ b/src/ripple/beast/crypto/sha2.h @@ -20,8 +20,8 @@ #ifndef BEAST_CRYPTO_SHA2_H_INCLUDED #define BEAST_CRYPTO_SHA2_H_INCLUDED -#include -#include +#include +#include namespace beast { diff --git a/src/beast/beast/cxx17/type_traits.h b/src/ripple/beast/cxx17/type_traits.h similarity index 100% rename from src/beast/beast/cxx17/type_traits.h rename to src/ripple/beast/cxx17/type_traits.h diff --git a/src/beast/beast/http/message.h b/src/ripple/beast/deprecated_http.h similarity index 54% rename from src/beast/beast/http/message.h rename to src/ripple/beast/deprecated_http.h index 6dc09a3b7f..215d66da53 100644 --- a/src/beast/beast/http/message.h +++ b/src/ripple/beast/deprecated_http.h @@ -17,184 +17,145 @@ */ //============================================================================== -#ifndef BEAST_HTTP_MESSAGE_H_INCLUDED -#define BEAST_HTTP_MESSAGE_H_INCLUDED +#ifndef BEAST_DEPRECATED_HTTP_H +#define BEAST_DEPRECATED_HTTP_H -#include -#include -#include -#include -#include -#include -#include - -namespace beast { -namespace http { - -namespace detail { - -struct request_fields -{ - http::method_t method; - std::string url; -}; - -struct response_fields -{ - int status; - std::string reason; -}; - -} // detail - -struct request_params -{ - http::method_t method; - std::string url; - int version; -}; - -struct response_params -{ - int status; - std::string reason; - int version; -}; - -/** A HTTP message. - - A message can be a request or response, depending on the `isRequest` - template argument value. Requests and responses have different types, - so functions may be overloaded on them if desired. - - The `Body` template argument type determines the model used - to read or write the content body of the message. - - @tparam isRequest `true` if this is a request. - - @tparam Body A type meeting the requirements of Body. - - @tparam Headers A type meeting the requirements of Headers. -*/ -template -struct message - : std::conditional_t -{ - /** The trait type characterizing the body. - - The body member will be of type body_type::value_type. - */ - using body_type = Body; - using headers_type = Headers; - - using is_request = - std::integral_constant; - - int version; // 10 or 11 - headers_type headers; - typename Body::value_type body; - - message(); - message(message&&) = default; - message(message const&) = default; - message& operator=(message&&) = default; - message& operator=(message const&) = default; - - /** Construct a HTTP request. - */ - explicit - message(request_params params); - - /** Construct a HTTP response. - */ - explicit - message(response_params params); - - /// Serialize the request or response line to a Streambuf. - template - void - write_firstline(Streambuf& streambuf) const - { - write_firstline(streambuf, - std::integral_constant{}); - } - - /// Diagnostics only - template - friend - std::ostream& - operator<<(std::ostream& os, - message const& m); - -private: - template - void - write_firstline(Streambuf& streambuf, - std::true_type) const; - - template - void - write_firstline(Streambuf& streambuf, - std::false_type) const; -}; - -#if ! GENERATING_DOCS - -/// A typical HTTP request -template>> -using request = message; - -/// A typical HTTP response -template>> -using response = message; - -#endif - -// For diagnostic output only -template -std::ostream& -operator<<(std::ostream& os, - message const& m); - -/// Write a FieldSequence to a Streambuf. -template -void -write_fields(Streambuf& streambuf, FieldSequence const& fields); - -/// Returns `true` if a message indicates a keep alive -template -bool -is_keep_alive(message const& msg); - -/// Returns `true` if a message indicates a HTTP Upgrade request or response -template -bool -is_upgrade(message const& msg); - -} // http -} // beast - -#include - -//------------------------------------------------------------------------------ - -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include +#include +#include #include -#include #include +#include #include namespace beast { namespace deprecated_http { +/** Container for the HTTP content-body. */ +class body +{ +private: + using buffer_type = boost::asio::streambuf; + + // Hack: use unique_ptr because streambuf cant be moved + std::unique_ptr buf_; + +public: + using const_buffers_type = buffer_type::const_buffers_type; + + body(); + body (body&& other); + body& operator= (body&& other); + + body (body const&) = delete; + body& operator= (body const&) = delete; + + template + void + clear(); + + void + write (void const* data, std::size_t bytes); + + template + void + write (ConstBufferSequence const& buffers); + + std::size_t + size() const; + + const_buffers_type + data() const; +}; + +template +std::string +to_string (body const& b) +{ + std::string s; + auto const& data (b.data()); + auto const n (boost::asio::buffer_size (data)); + s.resize (n); + boost::asio::buffer_copy ( + boost::asio::buffer (&s[0], n), data); + return s; +} + +//------------------------------------------------------------------------------ + +inline +body::body() + : buf_ (std::make_unique ()) +{ +} + +inline +body::body (body&& other) + : buf_ (std::move(other.buf_)) +{ + other.clear(); +} + +inline +body& +body::operator= (body&& other) +{ + buf_ = std::move(other.buf_); + other.clear(); + return *this; +} + +template +void +body::clear() +{ + buf_ = std::make_unique (); +} + +inline +void +body::write (void const* data, std::size_t bytes) +{ + buf_->commit (boost::asio::buffer_copy (buf_->prepare (bytes), + boost::asio::const_buffers_1 (data, bytes))); +} + +template +void +body::write (ConstBufferSequence const& buffers) +{ + for (auto const& buffer : buffers) + write (boost::asio::buffer_cast (buffer), + boost::asio::buffer_size (buffer)); +} + +inline +std::size_t +body::size() const +{ + return buf_->size(); +} + +inline +auto +body::data() const + -> const_buffers_type +{ + return buf_->data(); +} + +//------------------------------------------------------------------------------ + inline std::pair http_1_0() @@ -403,6 +364,101 @@ write (Streambuf& stream, message const& m) http::detail::write (stream, "\r\n"); } +//------------------------------------------------------------------------------ + +class parser + : public beast::http::basic_parser +{ +// friend class basic_parser; + + message& m_; + std::function write_body_; + +public: + parser(parser&&) = default; + parser(parser const&) = delete; + parser& operator=(parser&&) = delete; + parser& operator=(parser const&) = delete; + + /** Construct a parser for HTTP request or response. + The headers plus request or status line are stored in message. + The content-body, if any, is passed as a series of calls to + the write_body function. Transfer encodings are applied before + any data is passed to the write_body function. + */ + parser(std::function write_body, + message& m, bool request) + : basic_parser(request) + , m_(m) + , write_body_(std::move(write_body)) + { + m_.request(request); + } + + parser(message& m, body& b, bool request) + : basic_parser(request) + , m_(m) + { + write_body_ = [&b](void const* data, std::size_t size) + { + b.write(data, size); + }; + m_.request(request); + } + +//private: + void + on_start() + { + } + + void + on_headers_complete(error_code&) + { + } + + bool + on_request(http::method_t method, std::string const& url, + int major, int minor, bool keep_alive, bool upgrade) + { + m_.method(method); + m_.url(url); + m_.version(major, minor); + m_.keep_alive(keep_alive); + m_.upgrade(upgrade); + return true; + } + + bool + on_response(int status, std::string const& text, + int major, int minor, bool keep_alive, bool upgrade) + { + m_.status(status); + m_.reason(text); + m_.version(major, minor); + m_.keep_alive(keep_alive); + m_.upgrade(upgrade); + return true; + } + + void + on_field(std::string const& field, std::string const& value) + { + m_.headers.insert(field, value); + } + + void + on_body(void const* data, std::size_t bytes, error_code&) + { + write_body_(data, bytes); + } + + void + on_complete() + { + } +}; + } // deprecated_http } // beast diff --git a/src/beast/beast/hash/endian.h b/src/ripple/beast/hash/endian.h similarity index 100% rename from src/beast/beast/hash/endian.h rename to src/ripple/beast/hash/endian.h diff --git a/src/beast/beast/hash/fnv1a.h b/src/ripple/beast/hash/fnv1a.h similarity index 100% rename from src/beast/beast/hash/fnv1a.h rename to src/ripple/beast/hash/fnv1a.h diff --git a/src/beast/beast/hash/hash_append.h b/src/ripple/beast/hash/hash_append.h similarity index 99% rename from src/beast/beast/hash/hash_append.h rename to src/ripple/beast/hash/hash_append.h index 861c11ab12..9f73a90493 100644 --- a/src/beast/beast/hash/hash_append.h +++ b/src/ripple/beast/hash/hash_append.h @@ -21,8 +21,8 @@ #ifndef BEAST_HASH_HASH_APPEND_H_INCLUDED #define BEAST_HASH_HASH_APPEND_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/beast/beast/hash/impl/hash_speed_test.cpp b/src/ripple/beast/hash/impl/hash_speed_test.cpp similarity index 100% rename from src/beast/beast/hash/impl/hash_speed_test.cpp rename to src/ripple/beast/hash/impl/hash_speed_test.cpp diff --git a/src/beast/beast/hash/impl/siphash.cpp b/src/ripple/beast/hash/impl/siphash.cpp similarity index 99% rename from src/beast/beast/hash/impl/siphash.cpp rename to src/ripple/beast/hash/impl/siphash.cpp index 22125f53e0..546ad7c1c8 100644 --- a/src/beast/beast/hash/impl/siphash.cpp +++ b/src/ripple/beast/hash/impl/siphash.cpp @@ -24,7 +24,7 @@ // //------------------------------------------------------------------------------ -#include +#include #include #include #include diff --git a/src/beast/beast/hash/impl/spookyv2.cpp b/src/ripple/beast/hash/impl/spookyv2.cpp similarity index 99% rename from src/beast/beast/hash/impl/spookyv2.cpp rename to src/ripple/beast/hash/impl/spookyv2.cpp index 85f65d3eec..e546f5d180 100644 --- a/src/beast/beast/hash/impl/spookyv2.cpp +++ b/src/ripple/beast/hash/impl/spookyv2.cpp @@ -10,7 +10,7 @@ // August 5 2012: SpookyV2: d = should be d += in short hash, and remove extra mix from long hash #include -#include +#include #ifdef _MSC_VER #pragma warning (push) diff --git a/src/beast/beast/hash/impl/spookyv2.h b/src/ripple/beast/hash/impl/spookyv2.h similarity index 100% rename from src/beast/beast/hash/impl/spookyv2.h rename to src/ripple/beast/hash/impl/spookyv2.h diff --git a/src/beast/beast/hash/impl/xxhash.c b/src/ripple/beast/hash/impl/xxhash.c similarity index 99% rename from src/beast/beast/hash/impl/xxhash.c rename to src/ripple/beast/hash/impl/xxhash.c index 7d5f6f2244..5b7f5960fd 100644 --- a/src/beast/beast/hash/impl/xxhash.c +++ b/src/ripple/beast/hash/impl/xxhash.c @@ -31,7 +31,7 @@ You can contact the author at : - public discussion board : https://groups.google.com/forum/#!forum/lz4c */ -#include +#include //************************************** // Tuning parameters diff --git a/src/beast/beast/hash/impl/xxhash.h b/src/ripple/beast/hash/impl/xxhash.h similarity index 100% rename from src/beast/beast/hash/impl/xxhash.h rename to src/ripple/beast/hash/impl/xxhash.h diff --git a/src/beast/beast/hash/meta.h b/src/ripple/beast/hash/meta.h similarity index 100% rename from src/beast/beast/hash/meta.h rename to src/ripple/beast/hash/meta.h diff --git a/src/beast/beast/hash/siphash.h b/src/ripple/beast/hash/siphash.h similarity index 100% rename from src/beast/beast/hash/siphash.h rename to src/ripple/beast/hash/siphash.h diff --git a/src/beast/beast/hash/spooky.h b/src/ripple/beast/hash/spooky.h similarity index 95% rename from src/beast/beast/hash/spooky.h rename to src/ripple/beast/hash/spooky.h index 228517ddab..29672d4ab8 100644 --- a/src/beast/beast/hash/spooky.h +++ b/src/ripple/beast/hash/spooky.h @@ -21,8 +21,8 @@ #ifndef BEAST_HASH_SPOOKY_H_INCLUDED #define BEAST_HASH_SPOOKY_H_INCLUDED -#include -#include +#include +#include namespace beast { diff --git a/src/beast/beast/hash/tests/hash_append_test.cpp b/src/ripple/beast/hash/tests/hash_append_test.cpp similarity index 98% rename from src/beast/beast/hash/tests/hash_append_test.cpp rename to src/ripple/beast/hash/tests/hash_append_test.cpp index 672082c7f2..ad288fd199 100644 --- a/src/beast/beast/hash/tests/hash_append_test.cpp +++ b/src/ripple/beast/hash/tests/hash_append_test.cpp @@ -21,12 +21,12 @@ #include #endif -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/beast/beast/hash/tests/hash_metrics.h b/src/ripple/beast/hash/tests/hash_metrics.h similarity index 100% rename from src/beast/beast/hash/tests/hash_metrics.h rename to src/ripple/beast/hash/tests/hash_metrics.h diff --git a/src/beast/beast/hash/tests/hash_speed_test.cpp b/src/ripple/beast/hash/tests/hash_speed_test.cpp similarity index 94% rename from src/beast/beast/hash/tests/hash_speed_test.cpp rename to src/ripple/beast/hash/tests/hash_speed_test.cpp index 3518e4a8f3..f9d59458b0 100644 --- a/src/beast/beast/hash/tests/hash_speed_test.cpp +++ b/src/ripple/beast/hash/tests/hash_speed_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/beast/beast/hash/uhash.h b/src/ripple/beast/hash/uhash.h similarity index 94% rename from src/beast/beast/hash/uhash.h rename to src/ripple/beast/hash/uhash.h index 456c8b2b26..51be507523 100644 --- a/src/beast/beast/hash/uhash.h +++ b/src/ripple/beast/hash/uhash.h @@ -21,8 +21,8 @@ #ifndef BEAST_HASH_UHASH_H_INCLUDED #define BEAST_HASH_UHASH_H_INCLUDED -#include -#include +#include +#include namespace beast { diff --git a/src/beast/beast/hash/xxhasher.h b/src/ripple/beast/hash/xxhasher.h similarity index 96% rename from src/beast/beast/hash/xxhasher.h rename to src/ripple/beast/hash/xxhasher.h index 057255f497..a3161d4855 100644 --- a/src/beast/beast/hash/xxhasher.h +++ b/src/ripple/beast/hash/xxhasher.h @@ -26,8 +26,8 @@ #if ! BEAST_NO_XXHASH -#include -#include +#include +#include #include #include diff --git a/src/ripple/beast/insight/Event.h b/src/ripple/beast/insight/Event.h index d49ada63ca..6dbaf1b25c 100644 --- a/src/ripple/beast/insight/Event.h +++ b/src/ripple/beast/insight/Event.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include diff --git a/src/ripple/beast/insight/impl/Groups.cpp b/src/ripple/beast/insight/impl/Groups.cpp index 0d2a76b04d..6a55ae3fff 100644 --- a/src/ripple/beast/insight/impl/Groups.cpp +++ b/src/ripple/beast/insight/impl/Groups.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include diff --git a/src/ripple/beast/insight/impl/StatsDCollector.cpp b/src/ripple/beast/insight/impl/StatsDCollector.cpp index fdb5279750..f4fc6605c3 100644 --- a/src/ripple/beast/insight/impl/StatsDCollector.cpp +++ b/src/ripple/beast/insight/impl/StatsDCollector.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/beast/net/IPAddress.h b/src/ripple/beast/net/IPAddress.h index c5ef343f65..a2de956f4b 100644 --- a/src/ripple/beast/net/IPAddress.h +++ b/src/ripple/beast/net/IPAddress.h @@ -22,8 +22,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/beast/net/IPAddressV4.h b/src/ripple/beast/net/IPAddressV4.h index 24c9e41c54..793b99077b 100644 --- a/src/ripple/beast/net/IPAddressV4.h +++ b/src/ripple/beast/net/IPAddressV4.h @@ -20,7 +20,7 @@ #ifndef BEAST_NET_IPADDRESSV4_H_INCLUDED #define BEAST_NET_IPADDRESSV4_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/net/IPEndpoint.h b/src/ripple/beast/net/IPEndpoint.h index 07d27c8674..5557a90289 100644 --- a/src/ripple/beast/net/IPEndpoint.h +++ b/src/ripple/beast/net/IPEndpoint.h @@ -21,8 +21,8 @@ #define BEAST_NET_IPENDPOINT_H_INCLUDED #include -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/beast/net/URL.h b/src/ripple/beast/net/URL.h deleted file mode 100644 index dd7fd80722..0000000000 --- a/src/ripple/beast/net/URL.h +++ /dev/null @@ -1,195 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_HTTP_URL_H_INCLUDED -#define BEAST_HTTP_URL_H_INCLUDED - -#include -#include - -namespace beast { - -/** A URL. - The accompanying robust parser is hardened against all forms of attack. -*/ -class URL -{ -public: - /** Construct a URL from it's components. */ - URL ( - std::string schema_, - std::string host_, - std::uint16_t port_, - std::string port_string_, - std::string path_, - std::string query_ = "", - std::string fragment_ = "", - std::string userinfo_ = ""); - - /** Construct an empty URL. */ - explicit URL () = default; - - /** Copy construct a URL. */ - URL (URL const& other) = default; - - /** Copy assign a URL. */ - URL& operator= (URL const& other) = default; - - /** Move construct a URL. */ - URL (URL&& other) = default; - - /** Returns `true` if this is an empty URL. */ - bool - empty () const; - - /** Returns the scheme of the URL. - If no scheme was specified, the string will be empty. - */ - std::string const& - scheme () const; - - /** Returns the host of the URL. - If no host was specified, the string will be empty. - */ - std::string const& - host () const; - - /** Returns the port number as an integer. - If no port was specified, the value will be zero. - */ - std::uint16_t - port () const; - - /** Returns the port number as a string. - If no port was specified, the string will be empty. - */ - std::string const& - port_string () const; - - /** Returns the path of the URL. - If no path was specified, the string will be empty. - */ - std::string const& - path () const; - - /** Returns the query parameters portion of the URL. - If no query parameters were present, the string will be empty. - */ - std::string const& - query () const; - - /** Returns the URL fragment, if any. */ - std::string const& - fragment () const; - - /** Returns the user information, if any. */ - std::string const& - userinfo () const; - -private: - std::string m_scheme; - std::string m_host; - std::uint16_t m_port = 0; - std::string m_port_string; - std::string m_path; - std::string m_query; - std::string m_fragment; - std::string m_userinfo; -}; - -/** Attempt to parse a string into a URL */ -std::pair -parse_URL(std::string const&); - -/** Retrieve the full URL as a single string. */ -std::string -to_string(URL const& url); - -/** Output stream conversion. */ -std::ostream& -operator<< (std::ostream& os, URL const& url); - -/** URL comparisons. */ -/** @{ */ -inline bool -operator== (URL const& lhs, URL const& rhs) -{ - return to_string (lhs) == to_string (rhs); -} - -inline bool -operator!= (URL const& lhs, URL const& rhs) -{ - return to_string (lhs) != to_string (rhs); -} - -inline bool -operator< (URL const& lhs, URL const& rhs) -{ - return to_string (lhs) < to_string (rhs); -} - -inline bool operator> (URL const& lhs, URL const& rhs) -{ - return to_string (rhs) < to_string (lhs); -} - -inline bool -operator<= (URL const& lhs, URL const& rhs) -{ - return ! (to_string (rhs) < to_string (lhs)); -} - -inline bool -operator>= (URL const& lhs, URL const& rhs) -{ - return ! (to_string (lhs) < to_string (rhs)); -} -/** @} */ - -/** boost::hash support */ -template -inline -void -hash_append (Hasher& h, URL const& url) -{ - using beast::hash_append; - hash_append (h, to_string (url)); -} - -} - -//------------------------------------------------------------------------------ - -namespace std { - -template <> -struct hash -{ - std::size_t operator() (beast::URL const& url) const - { - return std::hash{} (to_string (url)); - } -}; - -} - -//------------------------------------------------------------------------------ - -#endif diff --git a/src/ripple/beast/net/impl/URL.cpp b/src/ripple/beast/net/impl/URL.cpp deleted file mode 100644 index 83eba4e2ab..0000000000 --- a/src/ripple/beast/net/impl/URL.cpp +++ /dev/null @@ -1,231 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include - -namespace beast { - -URL::URL ( - std::string scheme_, - std::string host_, - std::uint16_t port_, - std::string port_string_, - std::string path_, - std::string query_, - std::string fragment_, - std::string userinfo_) - : m_scheme (scheme_) - , m_host (host_) - , m_port (port_) - , m_port_string (port_string_) - , m_path (path_) - , m_query (query_) - , m_fragment (fragment_) - , m_userinfo (userinfo_) -{ -} - -//------------------------------------------------------------------------------ - -bool -URL::empty () const -{ - return m_scheme.empty (); -} - -std::string -const& URL::scheme () const -{ - return m_scheme; -} - -std::string -const& URL::host () const -{ - return m_host; -} - -std::string -const& URL::port_string () const -{ - return m_port_string; -} - -std::uint16_t -URL::port () const -{ - return m_port; -} - -std::string -const& URL::path () const -{ - return m_path; -} - -std::string -const& URL::query () const -{ - return m_query; -} - -std::string -const& URL::fragment () const -{ - return m_fragment; -} - -std::string -const& URL::userinfo () const -{ - return m_userinfo; -} - -//------------------------------------------------------------------------------ -std::pair -parse_URL(std::string const& url) -{ - std::size_t const buflen (url.size ()); - char const* const buf (url.c_str ()); - - http_parser_url parser; - - if (http_parser_parse_url (buf, buflen, false, &parser) != 0) - return std::make_pair (false, URL{}); - - std::string scheme; - std::string host; - std::uint16_t port (0); - std::string port_string; - std::string path; - std::string query; - std::string fragment; - std::string userinfo; - - if ((parser.field_set & (1< #include -#include +#include #include diff --git a/src/beast/beast/asio/src/test/beast_asio_error_test.cpp b/src/ripple/beast/net/tests/beast_asio_error_test.cpp similarity index 95% rename from src/beast/beast/asio/src/test/beast_asio_error_test.cpp rename to src/ripple/beast/net/tests/beast_asio_error_test.cpp index 9026ea2bbb..dd62e11d32 100644 --- a/src/beast/beast/asio/src/test/beast_asio_error_test.cpp +++ b/src/ripple/beast/net/tests/beast_asio_error_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include namespace beast { diff --git a/src/ripple/beast/net/tests/beast_http_URL_test.cpp b/src/ripple/beast/net/tests/beast_http_URL_test.cpp deleted file mode 100644 index fd4e9a0941..0000000000 --- a/src/ripple/beast/net/tests/beast_http_URL_test.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include - -namespace beast { - -class URL_test : public unit_test::suite -{ -public: - void check_url_parsing (std::string const& url, bool expected) - { - auto result = parse_URL (url); - - expect (result.first == expected, - (expected ? "Failed to parse " : "Succeeded in parsing ") + url); - expect (to_string (result.second) == url); - } - - void test_url_parsing () - { - char const* const urls[] = - { - "http://en.wikipedia.org/wiki/URI#Examples_of_URI_references", - "ftp://ftp.funet.fi/pub/standards/RFC/rfc959.txt" - "ftp://test:test@example.com:21/path/specifier/is/here" - "http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/reference.html", - "foo://username:password@example.com:8042/over/there/index.dtb?type=animal&name=narwhal#nose", - }; - - testcase ("URL parsing"); - - for (auto url : urls) - check_url_parsing (url, true); - } - - void - run () - { - test_url_parsing (); - } -}; - -BEAST_DEFINE_TESTSUITE(URL,http,beast); - -} diff --git a/src/ripple/beast/nudb/test/beast_nudb_callgrind_test.cpp b/src/ripple/beast/nudb/test/beast_nudb_callgrind_test.cpp index a6d1465e05..f0cab45590 100644 --- a/src/ripple/beast/nudb/test/beast_nudb_callgrind_test.cpp +++ b/src/ripple/beast/nudb/test/beast_nudb_callgrind_test.cpp @@ -18,9 +18,9 @@ //============================================================================== #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -98,7 +98,7 @@ public: testcase (abort_on_fail); - beast::temp_dir tempDir; + beast::detail::temp_dir tempDir; do_test (N, tempDir.path()); } }; diff --git a/src/ripple/beast/nudb/test/beast_nudb_recover_test.cpp b/src/ripple/beast/nudb/test/beast_nudb_recover_test.cpp index c70dae4e4b..c497f31021 100644 --- a/src/ripple/beast/nudb/test/beast_nudb_recover_test.cpp +++ b/src/ripple/beast/nudb/test/beast_nudb_recover_test.cpp @@ -18,9 +18,9 @@ //============================================================================== #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -117,7 +117,7 @@ public: { testcase << count << " inserts"; - beast::temp_dir tempDir; + beast::detail::temp_dir tempDir; auto const path = tempDir.path(); for (std::size_t n = 1;;++n) diff --git a/src/ripple/beast/nudb/test/beast_nudb_store_test.cpp b/src/ripple/beast/nudb/test/beast_nudb_store_test.cpp index 9cb03d1bcc..31f6f8da67 100644 --- a/src/ripple/beast/nudb/test/beast_nudb_store_test.cpp +++ b/src/ripple/beast/nudb/test/beast_nudb_store_test.cpp @@ -18,9 +18,9 @@ //============================================================================== #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -44,7 +44,7 @@ public: std::size_t block_size, float load_factor) { testcase (abort_on_fail); - beast::temp_dir tempDir; + beast::detail::temp_dir tempDir; auto const dp = tempDir.file ("nudb.dat"); auto const kp = tempDir.file ("nudb.key"); diff --git a/src/ripple/beast/nudb/test/beast_nudb_varint_test.cpp b/src/ripple/beast/nudb/test/beast_nudb_varint_test.cpp index e10777f697..b3b71fac7d 100644 --- a/src/ripple/beast/nudb/test/beast_nudb_varint_test.cpp +++ b/src/ripple/beast/nudb/test/beast_nudb_varint_test.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include #include #include diff --git a/src/ripple/beast/nudb/test/beast_nudb_verify_test.cpp b/src/ripple/beast/nudb/test/beast_nudb_verify_test.cpp index d0454fa7c0..3f72278d46 100644 --- a/src/ripple/beast/nudb/test/beast_nudb_verify_test.cpp +++ b/src/ripple/beast/nudb/test/beast_nudb_verify_test.cpp @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/beast/nudb/test/common.h b/src/ripple/beast/nudb/test/common.h index 752a8bb8ca..ce0944df26 100644 --- a/src/ripple/beast/nudb/test/common.h +++ b/src/ripple/beast/nudb/test/common.h @@ -23,8 +23,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/beast/site_scons/Beast.py b/src/ripple/beast/site_scons/Beast.py similarity index 100% rename from src/beast/site_scons/Beast.py rename to src/ripple/beast/site_scons/Beast.py diff --git a/src/beast/site_scons/site_tools/Protoc.py b/src/ripple/beast/site_scons/site_tools/Protoc.py similarity index 100% rename from src/beast/site_scons/site_tools/Protoc.py rename to src/ripple/beast/site_scons/site_tools/Protoc.py diff --git a/src/beast/site_scons/site_tools/VSProject.py b/src/ripple/beast/site_scons/site_tools/VSProject.py similarity index 100% rename from src/beast/site_scons/site_tools/VSProject.py rename to src/ripple/beast/site_scons/site_tools/VSProject.py diff --git a/src/beast/beast/type_name.h b/src/ripple/beast/type_name.h similarity index 100% rename from src/beast/beast/type_name.h rename to src/ripple/beast/type_name.h diff --git a/src/beast/beast/unit_test.h b/src/ripple/beast/unit_test.h similarity index 64% rename from src/beast/beast/unit_test.h rename to src/ripple/beast/unit_test.h index 2c99801d02..23e929ac81 100644 --- a/src/beast/beast/unit_test.h +++ b/src/ripple/beast/unit_test.h @@ -20,16 +20,22 @@ #ifndef BEAST_UNIT_TEST_H_INCLUDED #define BEAST_UNIT_TEST_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace beast { +namespace unit_test { +using namespace beast::detail::unit_test; +} // unit_test +} // beast #endif diff --git a/src/beast/beast/unity/beast_clock_unity.cpp b/src/ripple/beast/unity/beast_clock_unity.cpp similarity index 88% rename from src/beast/beast/unity/beast_clock_unity.cpp rename to src/ripple/beast/unity/beast_clock_unity.cpp index cb54279ce3..1861eeb2b3 100644 --- a/src/beast/beast/unity/beast_clock_unity.cpp +++ b/src/ripple/beast/unity/beast_clock_unity.cpp @@ -17,5 +17,5 @@ */ //============================================================================== -#include -#include +#include +#include diff --git a/src/beast/beast/unity/beast_hash_unity.cpp b/src/ripple/beast/unity/beast_hash_unity.cpp similarity index 79% rename from src/beast/beast/unity/beast_hash_unity.cpp rename to src/ripple/beast/unity/beast_hash_unity.cpp index f1b89f4f7c..82a87f0dc6 100644 --- a/src/beast/beast/unity/beast_hash_unity.cpp +++ b/src/ripple/beast/unity/beast_hash_unity.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include +#include +#include #if ! BEAST_NO_XXHASH -#include +#include #endif -#include +#include -#include -#include +#include +#include diff --git a/src/ripple/beast/unity/beast_net_unity.cpp b/src/ripple/beast/unity/beast_net_unity.cpp index b50f4adfa5..5d71be2559 100644 --- a/src/ripple/beast/unity/beast_net_unity.cpp +++ b/src/ripple/beast/unity/beast_net_unity.cpp @@ -21,7 +21,5 @@ #include #include #include -#include -#include #include diff --git a/src/ripple/beast/utility/src/beast_Debug.cpp b/src/ripple/beast/utility/src/beast_Debug.cpp index f7841654f1..5218ef81af 100644 --- a/src/ripple/beast/utility/src/beast_Debug.cpp +++ b/src/ripple/beast/utility/src/beast_Debug.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include #include namespace beast { diff --git a/src/ripple/beast/utility/src/beast_PropertyStream.cpp b/src/ripple/beast/utility/src/beast_PropertyStream.cpp index 672eda2a1f..1a9c112e4c 100644 --- a/src/ripple/beast/utility/src/beast_PropertyStream.cpp +++ b/src/ripple/beast/utility/src/beast_PropertyStream.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include #include #include #include diff --git a/src/ripple/beast/utility/tagged_integer.h b/src/ripple/beast/utility/tagged_integer.h index fb79a5741f..01e95e5375 100644 --- a/src/ripple/beast/utility/tagged_integer.h +++ b/src/ripple/beast/utility/tagged_integer.h @@ -20,7 +20,7 @@ #ifndef BEAST_UTILITY_TAGGED_INTEGER_H_INCLUDED #define BEAST_UTILITY_TAGGED_INTEGER_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/utility/test/beast_Journal_test.cpp b/src/ripple/beast/utility/test/beast_Journal_test.cpp index 0ae36ea392..6483d3ffce 100644 --- a/src/ripple/beast/utility/test/beast_Journal_test.cpp +++ b/src/ripple/beast/utility/test/beast_Journal_test.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include namespace beast { diff --git a/src/ripple/beast/utility/test/beast_Zero_test.cpp b/src/ripple/beast/utility/test/beast_Zero_test.cpp index b614def638..6222708495 100644 --- a/src/ripple/beast/utility/test/beast_Zero_test.cpp +++ b/src/ripple/beast/utility/test/beast_Zero_test.cpp @@ -19,7 +19,7 @@ #include -#include +#include namespace beast { diff --git a/src/ripple/beast/utility/test/beast_tagged_integer_test.cpp b/src/ripple/beast/utility/test/beast_tagged_integer_test.cpp index 61f467f409..29c103dc2c 100644 --- a/src/ripple/beast/utility/test/beast_tagged_integer_test.cpp +++ b/src/ripple/beast/utility/test/beast_tagged_integer_test.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include namespace beast { diff --git a/src/ripple/beast/utility/test/beast_weak_fn_test.cpp b/src/ripple/beast/utility/test/beast_weak_fn_test.cpp index 91054740d9..eef16d1399 100644 --- a/src/ripple/beast/utility/test/beast_weak_fn_test.cpp +++ b/src/ripple/beast/utility/test/beast_weak_fn_test.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include namespace beast { diff --git a/src/ripple/beast/utility/weak_fn.h b/src/ripple/beast/utility/weak_fn.h index afeccaf215..e6f0b7aed0 100644 --- a/src/ripple/beast/utility/weak_fn.h +++ b/src/ripple/beast/utility/weak_fn.h @@ -20,7 +20,7 @@ #ifndef BEAST_WEAK_FN_H_INCLUDED #define BEAST_WEAK_FN_H_INCLUDED -#include +#include #include // Original version: @@ -87,7 +87,7 @@ namespace detail { template class weak_binder - : private beast::empty_base_optimization + : private beast::detail::empty_base_optimization { private: using member_type = R (T::*)(Args...); @@ -101,7 +101,7 @@ public: weak_binder (member_type member, Policy policy, pointer_type object) - : empty_base_optimization(std::move(policy)) + : beast::detail::empty_base_optimization(std::move(policy)) , member_(member) , object_(object) { } diff --git a/src/beast/beast/xor_shift_engine.h b/src/ripple/beast/xor_shift_engine.h similarity index 100% rename from src/beast/beast/xor_shift_engine.h rename to src/ripple/beast/xor_shift_engine.h diff --git a/src/ripple/core/Config.h b/src/ripple/core/Config.h index c924c6c7b8..c04782a080 100644 --- a/src/ripple/core/Config.h +++ b/src/ripple/core/Config.h @@ -26,9 +26,8 @@ #include // NIKB Breaks levelization (TEMP) #include // NIKB Breaks levelization (TEMP) #include -#include #include -#include +#include #include #include // VFALCO FIX: This include should not be here #include // VFALCO FIX: This include should not be here diff --git a/src/ripple/core/TimeKeeper.h b/src/ripple/core/TimeKeeper.h index a3722f8839..22d5a2cc47 100644 --- a/src/ripple/core/TimeKeeper.h +++ b/src/ripple/core/TimeKeeper.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_CORE_TIMEKEEPER_H_INCLUDED #define RIPPLE_CORE_TIMEKEEPER_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/core/impl/Config.cpp b/src/ripple/core/impl/Config.cpp index fd8b2726ea..9943ebd5b4 100644 --- a/src/ripple/core/impl/Config.cpp +++ b/src/ripple/core/impl/Config.cpp @@ -26,10 +26,8 @@ #include #include #include -#include #include -#include -#include +#include #include #include #include @@ -328,15 +326,15 @@ void Config::loadFromString (std::string const& fileContents) if (getSingleSection (secConfig, SECTION_NODE_SIZE, strTemp, j_)) { - if (beast::ci_equal(strTemp, "tiny")) + if (beast::detail::ci_equal(strTemp, "tiny")) NODE_SIZE = 0; - else if (beast::ci_equal(strTemp, "small")) + else if (beast::detail::ci_equal(strTemp, "small")) NODE_SIZE = 1; - else if (beast::ci_equal(strTemp, "medium")) + else if (beast::detail::ci_equal(strTemp, "medium")) NODE_SIZE = 2; - else if (beast::ci_equal(strTemp, "large")) + else if (beast::detail::ci_equal(strTemp, "large")) NODE_SIZE = 3; - else if (beast::ci_equal(strTemp, "huge")) + else if (beast::detail::ci_equal(strTemp, "huge")) NODE_SIZE = 4; else { @@ -398,9 +396,9 @@ void Config::loadFromString (std::string const& fileContents) if (getSingleSection (secConfig, SECTION_LEDGER_HISTORY, strTemp, j_)) { - if (beast::ci_equal(strTemp, "full")) + if (beast::detail::ci_equal(strTemp, "full")) LEDGER_HISTORY = 1000000000u; - else if (beast::ci_equal(strTemp, "none")) + else if (beast::detail::ci_equal(strTemp, "none")) LEDGER_HISTORY = 0; else LEDGER_HISTORY = beast::lexicalCastThrow (strTemp); @@ -408,9 +406,9 @@ void Config::loadFromString (std::string const& fileContents) if (getSingleSection (secConfig, SECTION_FETCH_DEPTH, strTemp, j_)) { - if (beast::ci_equal(strTemp, "none")) + if (beast::detail::ci_equal(strTemp, "none")) FETCH_DEPTH = 0; - else if (beast::ci_equal(strTemp, "full")) + else if (beast::detail::ci_equal(strTemp, "full")) FETCH_DEPTH = 1000000000u; else FETCH_DEPTH = beast::lexicalCastThrow (strTemp); diff --git a/src/ripple/core/impl/JobQueue.cpp b/src/ripple/core/impl/JobQueue.cpp index 78e4231017..b135b4f7f2 100644 --- a/src/ripple/core/impl/JobQueue.cpp +++ b/src/ripple/core/impl/JobQueue.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/core/impl/SNTPClock.cpp b/src/ripple/core/impl/SNTPClock.cpp index a976602fd8..25e4015f32 100644 --- a/src/ripple/core/impl/SNTPClock.cpp +++ b/src/ripple/core/impl/SNTPClock.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/core/impl/SNTPClock.h b/src/ripple/core/impl/SNTPClock.h index 0fb0b48150..35cd617566 100644 --- a/src/ripple/core/impl/SNTPClock.h +++ b/src/ripple/core/impl/SNTPClock.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_NET_SNTPCLOCK_H_INCLUDED #define RIPPLE_NET_SNTPCLOCK_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/core/impl/Workers.cpp b/src/ripple/core/impl/Workers.cpp index d654d00366..fcc8b9231d 100644 --- a/src/ripple/core/impl/Workers.cpp +++ b/src/ripple/core/impl/Workers.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include #include namespace ripple { diff --git a/src/ripple/core/tests/LoadFeeTrack.test.cpp b/src/ripple/core/tests/LoadFeeTrack.test.cpp index 5864a73018..9e49fb8297 100644 --- a/src/ripple/core/tests/LoadFeeTrack.test.cpp +++ b/src/ripple/core/tests/LoadFeeTrack.test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/core/tests/Stoppable.test.cpp b/src/ripple/core/tests/Stoppable.test.cpp index 8250f4c72f..5a4fe6989f 100644 --- a/src/ripple/core/tests/Stoppable.test.cpp +++ b/src/ripple/core/tests/Stoppable.test.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include #include namespace ripple { diff --git a/src/ripple/crypto/tests/CBigNum_test.cpp b/src/ripple/crypto/tests/CBigNum_test.cpp index 60df454a01..a573312866 100644 --- a/src/ripple/crypto/tests/CBigNum_test.cpp +++ b/src/ripple/crypto/tests/CBigNum_test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/crypto/tests/CKey.test.cpp b/src/ripple/crypto/tests/CKey.test.cpp index c17f70bbaf..c949da0d65 100644 --- a/src/ripple/crypto/tests/CKey.test.cpp +++ b/src/ripple/crypto/tests/CKey.test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/json/impl/Writer.cpp b/src/ripple/json/impl/Writer.cpp index 816322b0ec..9a8a47d83d 100644 --- a/src/ripple/json/impl/Writer.cpp +++ b/src/ripple/json/impl/Writer.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include namespace Json { diff --git a/src/ripple/json/tests/Object.test.cpp b/src/ripple/json/tests/Object.test.cpp index 5e9f512767..a6e51ae497 100644 --- a/src/ripple/json/tests/Object.test.cpp +++ b/src/ripple/json/tests/Object.test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace Json { diff --git a/src/ripple/json/tests/Writer.test.cpp b/src/ripple/json/tests/Writer.test.cpp index 3fb7933cb7..e761834167 100644 --- a/src/ripple/json/tests/Writer.test.cpp +++ b/src/ripple/json/tests/Writer.test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include namespace Json { diff --git a/src/ripple/json/tests/json_value.test.cpp b/src/ripple/json/tests/json_value.test.cpp index 851c151118..44d54e889b 100644 --- a/src/ripple/json/tests/json_value.test.cpp +++ b/src/ripple/json/tests/json_value.test.cpp @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/ledger/ReadView.h b/src/ripple/ledger/ReadView.h index 1a8b1b1346..e952b6e01a 100644 --- a/src/ripple/ledger/ReadView.h +++ b/src/ripple/ledger/ReadView.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/ledger/tests/PendingSaves_test.cpp b/src/ripple/ledger/tests/PendingSaves_test.cpp index f621640200..dfc5149080 100644 --- a/src/ripple/ledger/tests/PendingSaves_test.cpp +++ b/src/ripple/ledger/tests/PendingSaves_test.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include namespace ripple { namespace test { diff --git a/src/ripple/ledger/tests/SkipList_test.cpp b/src/ripple/ledger/tests/SkipList_test.cpp index 3dc4f87fe2..d7eda80d91 100644 --- a/src/ripple/ledger/tests/SkipList_test.cpp +++ b/src/ripple/ledger/tests/SkipList_test.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include namespace ripple { namespace test { diff --git a/src/ripple/net/impl/HTTPClient.cpp b/src/ripple/net/impl/HTTPClient.cpp index ae8767991b..eb30d37cc9 100644 --- a/src/ripple/net/impl/HTTPClient.cpp +++ b/src/ripple/net/impl/HTTPClient.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/net/impl/RPCCall.cpp b/src/ripple/net/impl/RPCCall.cpp index 216471964d..2142480e88 100644 --- a/src/ripple/net/impl/RPCCall.cpp +++ b/src/ripple/net/impl/RPCCall.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -422,9 +422,9 @@ private: // This may look reversed, but it's intentional: jss::vetoed // determines whether an amendment is vetoed - so "reject" means // that jss::vetoed is true. - if (beast::ci_equal(action, "reject")) + if (beast::detail::ci_equal(action, "reject")) jvRequest[jss::vetoed] = Json::Value (true); - else if (beast::ci_equal(action, "accept")) + else if (beast::detail::ci_equal(action, "accept")) jvRequest[jss::vetoed] = Json::Value (false); else return rpcError (rpcINVALID_PARAMS); diff --git a/src/ripple/nodestore/backend/MemoryFactory.cpp b/src/ripple/nodestore/backend/MemoryFactory.cpp index 28970d57f2..396bd259f9 100644 --- a/src/ripple/nodestore/backend/MemoryFactory.cpp +++ b/src/ripple/nodestore/backend/MemoryFactory.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -40,7 +40,7 @@ class MemoryFactory : public Factory { private: std::mutex mutex_; - std::map map_; + std::map map_; public: MemoryFactory(); diff --git a/src/ripple/nodestore/backend/NuDBFactory.cpp b/src/ripple/nodestore/backend/NuDBFactory.cpp index 5ad32afc19..5a2425ca81 100644 --- a/src/ripple/nodestore/backend/NuDBFactory.cpp +++ b/src/ripple/nodestore/backend/NuDBFactory.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/nodestore/impl/ManagerImp.cpp b/src/ripple/nodestore/impl/ManagerImp.cpp index 7187cac089..955023d9d1 100644 --- a/src/ripple/nodestore/impl/ManagerImp.cpp +++ b/src/ripple/nodestore/impl/ManagerImp.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include @@ -130,7 +130,7 @@ ManagerImp::find (std::string const& name) auto const iter = std::find_if(list_.begin(), list_.end(), [&name](Factory* other) { - return beast::ci_equal(name, other->getName()); + return beast::detail::ci_equal(name, other->getName()); } ); if (iter == list_.end()) return nullptr; diff --git a/src/ripple/nodestore/tests/Backend.test.cpp b/src/ripple/nodestore/tests/Backend.test.cpp index 4ea1b69512..c0d77d1dd7 100644 --- a/src/ripple/nodestore/tests/Backend.test.cpp +++ b/src/ripple/nodestore/tests/Backend.test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include namespace ripple { @@ -42,7 +42,7 @@ public: testcase ("Backend type=" + type); Section params; - beast::temp_dir tempDir; + beast::detail::temp_dir tempDir; params.set ("type", type); params.set ("path", tempDir.path()); diff --git a/src/ripple/nodestore/tests/Base.test.h b/src/ripple/nodestore/tests/Base.test.h index 2b222bec12..1f6b4a2910 100644 --- a/src/ripple/nodestore/tests/Base.test.h +++ b/src/ripple/nodestore/tests/Base.test.h @@ -23,9 +23,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include diff --git a/src/ripple/nodestore/tests/Database.test.cpp b/src/ripple/nodestore/tests/Database.test.cpp index 2d8164c242..61f3ddd58e 100644 --- a/src/ripple/nodestore/tests/Database.test.cpp +++ b/src/ripple/nodestore/tests/Database.test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include namespace ripple { @@ -35,7 +35,7 @@ public: { DummyScheduler scheduler; - beast::temp_dir node_db; + beast::detail::temp_dir node_db; Section srcParams; srcParams.set ("type", srcBackendType); srcParams.set ("path", node_db.path()); @@ -61,7 +61,7 @@ public: "test", scheduler, j, 2, srcParams); // Set up the destination database - beast::temp_dir dest_db; + beast::detail::temp_dir dest_db; Section destParams; destParams.set ("type", destBackendType); destParams.set ("path", dest_db.path()); @@ -98,7 +98,7 @@ public: testcase (s); - beast::temp_dir node_db; + beast::detail::temp_dir node_db; Section nodeParams; nodeParams.set ("type", type); nodeParams.set ("path", node_db.path()); diff --git a/src/ripple/nodestore/tests/Timing.test.cpp b/src/ripple/nodestore/tests/Timing.test.cpp index c07142a1f7..6ae0562b4e 100644 --- a/src/ripple/nodestore/tests/Timing.test.cpp +++ b/src/ripple/nodestore/tests/Timing.test.cpp @@ -23,10 +23,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -679,7 +679,7 @@ public: params.threads = threads; for (auto i = default_repeat; i--;) { - beast::temp_dir tempDir; + beast::detail::temp_dir tempDir; Section config = parse(config_string); config.set ("path", tempDir.path()); std::stringstream ss; diff --git a/src/ripple/nodestore/tests/import_test.cpp b/src/ripple/nodestore/tests/import_test.cpp index faf7ccc486..2e867db55e 100644 --- a/src/ripple/nodestore/tests/import_test.cpp +++ b/src/ripple/nodestore/tests/import_test.cpp @@ -18,15 +18,15 @@ //============================================================================== #include -#include +#include #include #include -#include -#include +#include +#include #include #include -#include -#include +#include +#include #include #include #include @@ -257,7 +257,7 @@ public: } }; -std::map +std::map parse_args(std::string const& s) { // '=' @@ -273,7 +273,7 @@ parse_args(std::string const& s) , boost::regex_constants::optimize ); std::map map; + std::string, beast::detail::ci_less> map; auto const v = beast::rfc2616::split( s.begin(), s.end(), ','); for (auto const& kv : v) diff --git a/src/ripple/overlay/Cluster.h b/src/ripple/overlay/Cluster.h index f3c130b58f..bea1c35d69 100644 --- a/src/ripple/overlay/Cluster.h +++ b/src/ripple/overlay/Cluster.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/overlay/Overlay.h b/src/ripple/overlay/Overlay.h index 7dc458f85d..0dcefb63ec 100644 --- a/src/ripple/overlay/Overlay.h +++ b/src/ripple/overlay/Overlay.h @@ -24,8 +24,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/overlay/PeerSet.h b/src/ripple/overlay/PeerSet.h index 818fe085bf..e529d9b811 100644 --- a/src/ripple/overlay/PeerSet.h +++ b/src/ripple/overlay/PeerSet.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/overlay/impl/ConnectAttempt.h b/src/ripple/overlay/impl/ConnectAttempt.h index 3a1c2d8ecd..b18cd9f280 100644 --- a/src/ripple/overlay/impl/ConnectAttempt.h +++ b/src/ripple/overlay/impl/ConnectAttempt.h @@ -28,11 +28,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/overlay/impl/OverlayImpl.cpp b/src/ripple/overlay/impl/OverlayImpl.cpp index b0ef3bfa9c..d87c538fe9 100644 --- a/src/ripple/overlay/impl/OverlayImpl.cpp +++ b/src/ripple/overlay/impl/OverlayImpl.cpp @@ -34,10 +34,10 @@ #include #include #include -#include +#include #include -#include -#include +#include +#include #include #include @@ -220,7 +220,7 @@ OverlayImpl::onHandoff (std::unique_ptr && ssl_bundle, if (std::find_if(types.begin(), types.end(), [](std::string const& s) { - return beast::ci_equal(s, "peer"); + return beast::detail::ci_equal(s, "peer"); }) == types.end()) { handoff.moved = false; @@ -461,7 +461,7 @@ OverlayImpl::setupValidatorKeyManifests (BasicConfig const& config, std::string s; for (auto const& line : validation_manifest.lines()) s += beast::rfc2616::trim(line); - s = beast::base64_decode(s); + s = beast::detail::base64_decode(s); if (auto mo = make_Manifest (std::move (s))) { manifestCache_.configManifest ( @@ -803,7 +803,7 @@ OverlayImpl::crawl() for_each ([&](std::shared_ptr&& sp) { auto& pv = av.append(Json::Value(Json::objectValue)); - pv[jss::public_key] = beast::base64_encode( + pv[jss::public_key] = beast::detail::base64_encode( sp->getNodePublic().data(), sp->getNodePublic().size()); pv[jss::type] = sp->slot()->inbound() ? diff --git a/src/ripple/overlay/impl/OverlayImpl.h b/src/ripple/overlay/impl/OverlayImpl.h index 60715e6592..e551e4eb1b 100644 --- a/src/ripple/overlay/impl/OverlayImpl.h +++ b/src/ripple/overlay/impl/OverlayImpl.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index 603fa5abc0..4adee98785 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -241,7 +240,7 @@ PeerImp::crawl() const auto const iter = headers_.find("Crawl"); if (iter == headers_.end()) return false; - return beast::ci_equal(iter->second, "public"); + return beast::detail::ci_equal(iter->second, "public"); } std::string diff --git a/src/ripple/overlay/impl/PeerImp.h b/src/ripple/overlay/impl/PeerImp.h index 44f2099717..c91307e5bf 100644 --- a/src/ripple/overlay/impl/PeerImp.h +++ b/src/ripple/overlay/impl/PeerImp.h @@ -36,11 +36,11 @@ #include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/overlay/impl/PeerSet.cpp b/src/ripple/overlay/impl/PeerSet.cpp index 4409f58415..aa82b9463c 100644 --- a/src/ripple/overlay/impl/PeerSet.cpp +++ b/src/ripple/overlay/impl/PeerSet.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/overlay/impl/TMHello.cpp b/src/ripple/overlay/impl/TMHello.cpp index 6c84af6b3c..70e5533ca9 100644 --- a/src/ripple/overlay/impl/TMHello.cpp +++ b/src/ripple/overlay/impl/TMHello.cpp @@ -25,8 +25,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -161,7 +161,7 @@ appendHello (beast::http::headers>& h, h.insert ("Public-Key", hello.nodepublic()); - h.insert ("Session-Signature", beast::base64_encode ( + h.insert ("Session-Signature", beast::detail::base64_encode ( hello.nodeproof())); if (hello.has_nettime()) @@ -171,11 +171,11 @@ appendHello (beast::http::headers>& h, h.insert ("Ledger", std::to_string (hello.ledgerindex())); if (hello.has_ledgerclosed()) - h.insert ("Closed-Ledger", beast::base64_encode ( + h.insert ("Closed-Ledger", beast::detail::base64_encode ( hello.ledgerclosed())); if (hello.has_ledgerprevious()) - h.insert ("Previous-Ledger", beast::base64_encode ( + h.insert ("Previous-Ledger", beast::detail::base64_encode ( hello.ledgerprevious())); if (hello.has_local_ip()) @@ -262,7 +262,7 @@ parseHello (bool request, beast::http::headers> const& h, b if (iter == h.end()) return boost::none; // TODO Security Review - hello.set_nodeproof (beast::base64_decode (iter->second)); + hello.set_nodeproof (beast::detail::base64_decode (iter->second)); } { @@ -297,13 +297,13 @@ parseHello (bool request, beast::http::headers> const& h, b { auto const iter = h.find ("Closed-Ledger"); if (iter != h.end()) - hello.set_ledgerclosed (beast::base64_decode (iter->second)); + hello.set_ledgerclosed (beast::detail::base64_decode (iter->second)); } { auto const iter = h.find ("Previous-Ledger"); if (iter != h.end()) - hello.set_ledgerprevious (beast::base64_decode (iter->second)); + hello.set_ledgerprevious (beast::detail::base64_decode (iter->second)); } { diff --git a/src/ripple/overlay/impl/TMHello.h b/src/ripple/overlay/impl/TMHello.h index e62d514696..1404c20ab4 100644 --- a/src/ripple/overlay/impl/TMHello.h +++ b/src/ripple/overlay/impl/TMHello.h @@ -24,7 +24,8 @@ #include #include #include -#include +#include +#include #include #include #include diff --git a/src/ripple/overlay/tests/TMHello.test.cpp b/src/ripple/overlay/tests/TMHello.test.cpp index 94506ab6e1..093e98d255 100644 --- a/src/ripple/overlay/tests/TMHello.test.cpp +++ b/src/ripple/overlay/tests/TMHello.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace ripple { diff --git a/src/ripple/overlay/tests/short_read.test.cpp b/src/ripple/overlay/tests/short_read.test.cpp index a904068f3a..4287592d36 100644 --- a/src/ripple/overlay/tests/short_read.test.cpp +++ b/src/ripple/overlay/tests/short_read.test.cpp @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/peerfinder/PeerfinderManager.h b/src/ripple/peerfinder/PeerfinderManager.h index ac99247288..5dc3758f20 100644 --- a/src/ripple/peerfinder/PeerfinderManager.h +++ b/src/ripple/peerfinder/PeerfinderManager.h @@ -21,7 +21,7 @@ #define RIPPLE_PEERFINDER_MANAGER_H_INCLUDED #include -#include +#include #include #include #include diff --git a/src/ripple/peerfinder/impl/Checker.h b/src/ripple/peerfinder/impl/Checker.h index 481c92871d..0a12c4a0b5 100644 --- a/src/ripple/peerfinder/impl/Checker.h +++ b/src/ripple/peerfinder/impl/Checker.h @@ -21,7 +21,7 @@ #define RIPPLE_PEERFINDER_CHECKER_H_INCLUDED #include -#include +#include #include #include #include diff --git a/src/ripple/peerfinder/tests/Livecache.test.cpp b/src/ripple/peerfinder/tests/Livecache.test.cpp index 8536074bfd..03fe78f7a5 100644 --- a/src/ripple/peerfinder/tests/Livecache.test.cpp +++ b/src/ripple/peerfinder/tests/Livecache.test.cpp @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include namespace ripple { namespace PeerFinder { diff --git a/src/ripple/peerfinder/tests/PeerFinder_test.cpp b/src/ripple/peerfinder/tests/PeerFinder_test.cpp index d26c13c28e..bf80611420 100644 --- a/src/ripple/peerfinder/tests/PeerFinder_test.cpp +++ b/src/ripple/peerfinder/tests/PeerFinder_test.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include namespace ripple { namespace PeerFinder { diff --git a/src/ripple/protocol/HashPrefix.h b/src/ripple/protocol/HashPrefix.h index 686ff0531a..0b98da886d 100644 --- a/src/ripple/protocol/HashPrefix.h +++ b/src/ripple/protocol/HashPrefix.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_HASHPREFIX_H_INCLUDED #define RIPPLE_PROTOCOL_HASHPREFIX_H_INCLUDED -#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/STObject.h b/src/ripple/protocol/STObject.h index 4a51d6e88e..a2a0cff096 100644 --- a/src/ripple/protocol/STObject.h +++ b/src/ripple/protocol/STObject.h @@ -36,10 +36,6 @@ #include #include -#include -#include -#include - namespace ripple { class STArray; @@ -268,29 +264,6 @@ private: reserveSize = 20 }; - struct Log - { - std::mutex mutex_; - std::unordered_map< - std::size_t, std::size_t> map_; - - ~Log() - { - beast::debug_ostream os; - for(auto const& e : map_) - os << e.first << "," << e.second; - } - - void - operator() (std::size_t n) - { - std::lock_guard lock(mutex_); - auto const result = map_.emplace(n, 1); - if (! result.second) - ++result.first->second; - } - }; - using list_type = std::vector; list_type v_; diff --git a/src/ripple/protocol/digest.h b/src/ripple/protocol/digest.h index 20d42f8999..1d6f705b16 100644 --- a/src/ripple/protocol/digest.h +++ b/src/ripple/protocol/digest.h @@ -21,9 +21,9 @@ #define RIPPLE_PROTOCOL_DIGEST_H_INCLUDED #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/impl/BuildInfo.cpp b/src/ripple/protocol/impl/BuildInfo.cpp index 1a9e7e4917..cd3666e3b5 100644 --- a/src/ripple/protocol/impl/BuildInfo.cpp +++ b/src/ripple/protocol/impl/BuildInfo.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include diff --git a/src/ripple/protocol/impl/STTx.cpp b/src/ripple/protocol/impl/STTx.cpp index 6d765a6d20..4aea634ebd 100644 --- a/src/ripple/protocol/impl/STTx.cpp +++ b/src/ripple/protocol/impl/STTx.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/protocol/impl/STVar.cpp b/src/ripple/protocol/impl/STVar.cpp index 4f7c067d0b..7609a76fb4 100644 --- a/src/ripple/protocol/impl/STVar.cpp +++ b/src/ripple/protocol/impl/STVar.cpp @@ -39,24 +39,6 @@ nonPresentObject_t nonPresentObject; //------------------------------------------------------------------------------ -STVar::Log::~Log() -{ - beast::debug_ostream os; - for(auto const& e : map_) - os << e.first << "," << e.second; -} - -void -STVar::Log::operator() (std::size_t n) -{ - std::lock_guard lock(mutex_); - auto const result = map_.emplace(n, 1); - if (! result.second) - ++result.first->second; -} - -//------------------------------------------------------------------------------ - STVar::~STVar() { destroy(); diff --git a/src/ripple/protocol/impl/STVar.h b/src/ripple/protocol/impl/STVar.h index e696948ffe..8722f24d7b 100644 --- a/src/ripple/protocol/impl/STVar.h +++ b/src/ripple/protocol/impl/STVar.h @@ -28,10 +28,6 @@ #include #include -#include -#include -#include - namespace ripple { namespace detail { @@ -49,16 +45,6 @@ private: std::aligned_storage<72>::type d_; STBase* p_ = nullptr; - struct Log - { - std::mutex mutex_; - std::unordered_map< - std::size_t, std::size_t> map_; - - ~Log(); - void operator() (std::size_t n); - }; - public: ~STVar(); STVar (STVar const& other); diff --git a/src/ripple/protocol/impl/SecretKey.cpp b/src/ripple/protocol/impl/SecretKey.cpp index 30fa7a4b5f..c481e21f81 100644 --- a/src/ripple/protocol/impl/SecretKey.cpp +++ b/src/ripple/protocol/impl/SecretKey.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/protocol/impl/Seed.cpp b/src/ripple/protocol/impl/Seed.cpp index f611ad3038..78a2a7eb9a 100644 --- a/src/ripple/protocol/impl/Seed.cpp +++ b/src/ripple/protocol/impl/Seed.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/protocol/tests/BuildInfo.test.cpp b/src/ripple/protocol/tests/BuildInfo.test.cpp index ce89ea7fef..af9d7fe57b 100644 --- a/src/ripple/protocol/tests/BuildInfo.test.cpp +++ b/src/ripple/protocol/tests/BuildInfo.test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/protocol/tests/IOUAmount.test.cpp b/src/ripple/protocol/tests/IOUAmount.test.cpp index 4ed4bef3a7..3ef3f9c8b2 100644 --- a/src/ripple/protocol/tests/IOUAmount.test.cpp +++ b/src/ripple/protocol/tests/IOUAmount.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace ripple { diff --git a/src/ripple/protocol/tests/InnerObjectFormats.test.cpp b/src/ripple/protocol/tests/InnerObjectFormats.test.cpp index cf3a1bdaf4..442e8a5125 100755 --- a/src/ripple/protocol/tests/InnerObjectFormats.test.cpp +++ b/src/ripple/protocol/tests/InnerObjectFormats.test.cpp @@ -23,7 +23,7 @@ #include // RPC::containsError #include // Json::Reader #include // STParsedJSONObject -#include +#include namespace ripple { diff --git a/src/ripple/protocol/tests/Issue.test.cpp b/src/ripple/protocol/tests/Issue.test.cpp index 74fbf2331d..0bff6d869a 100644 --- a/src/ripple/protocol/tests/Issue.test.cpp +++ b/src/ripple/protocol/tests/Issue.test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/protocol/tests/PublicKey_test.cpp b/src/ripple/protocol/tests/PublicKey_test.cpp index d64fd524f8..68be8dbd41 100644 --- a/src/ripple/protocol/tests/PublicKey_test.cpp +++ b/src/ripple/protocol/tests/PublicKey_test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/tests/Quality.test.cpp b/src/ripple/protocol/tests/Quality.test.cpp index 90adc3b858..ae8f5eb2ea 100644 --- a/src/ripple/protocol/tests/Quality.test.cpp +++ b/src/ripple/protocol/tests/Quality.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/tests/STAccount.test.cpp b/src/ripple/protocol/tests/STAccount.test.cpp index 8582c30367..aeb100918d 100644 --- a/src/ripple/protocol/tests/STAccount.test.cpp +++ b/src/ripple/protocol/tests/STAccount.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace ripple { diff --git a/src/ripple/protocol/tests/STAmount.test.cpp b/src/ripple/protocol/tests/STAmount.test.cpp index 1a496fa8d8..3ec27429c5 100644 --- a/src/ripple/protocol/tests/STAmount.test.cpp +++ b/src/ripple/protocol/tests/STAmount.test.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/protocol/tests/STObject.test.cpp b/src/ripple/protocol/tests/STObject.test.cpp index 9976e3dec8..7fd8e4e1db 100644 --- a/src/ripple/protocol/tests/STObject.test.cpp +++ b/src/ripple/protocol/tests/STObject.test.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/ripple/protocol/tests/STTx.test.cpp b/src/ripple/protocol/tests/STTx.test.cpp index 428dce5079..0076b6924a 100644 --- a/src/ripple/protocol/tests/STTx.test.cpp +++ b/src/ripple/protocol/tests/STTx.test.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/protocol/tests/SecretKey_test.cpp b/src/ripple/protocol/tests/SecretKey_test.cpp index 7cc6473c5e..6de8efd797 100644 --- a/src/ripple/protocol/tests/SecretKey_test.cpp +++ b/src/ripple/protocol/tests/SecretKey_test.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/protocol/tests/Seed_test.cpp b/src/ripple/protocol/tests/Seed_test.cpp index e39659b62d..ed03ffc3e5 100644 --- a/src/ripple/protocol/tests/Seed_test.cpp +++ b/src/ripple/protocol/tests/Seed_test.cpp @@ -22,9 +22,9 @@ #include #include #include -#include +#include #include -#include +#include #include diff --git a/src/ripple/protocol/tests/XRPAmount.test.cpp b/src/ripple/protocol/tests/XRPAmount.test.cpp index 3a7b2d2c96..2abea6e5ba 100644 --- a/src/ripple/protocol/tests/XRPAmount.test.cpp +++ b/src/ripple/protocol/tests/XRPAmount.test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace ripple { diff --git a/src/ripple/protocol/tests/digest_test.cpp b/src/ripple/protocol/tests/digest_test.cpp index 038f7dd750..52dbce7892 100644 --- a/src/ripple/protocol/tests/digest_test.cpp +++ b/src/ripple/protocol/tests/digest_test.cpp @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/tests/types_test.cpp b/src/ripple/protocol/tests/types_test.cpp index a11a13698c..e3e5ea097d 100644 --- a/src/ripple/protocol/tests/types_test.cpp +++ b/src/ripple/protocol/tests/types_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace ripple { diff --git a/src/ripple/resource/impl/Entry.h b/src/ripple/resource/impl/Entry.h index e48e325fde..7438758b93 100644 --- a/src/ripple/resource/impl/Entry.h +++ b/src/ripple/resource/impl/Entry.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/ripple/resource/impl/Logic.h b/src/ripple/resource/impl/Logic.h index 642999b365..8fe7059521 100644 --- a/src/ripple/resource/impl/Logic.h +++ b/src/ripple/resource/impl/Logic.h @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/resource/tests/Logic.test.cpp b/src/ripple/resource/tests/Logic.test.cpp index f72846e1dc..8660bab0d3 100644 --- a/src/ripple/resource/tests/Logic.test.cpp +++ b/src/ripple/resource/tests/Logic.test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include namespace ripple { diff --git a/src/ripple/rpc/tests/AccountLinesRPC.test.cpp b/src/ripple/rpc/tests/AccountLinesRPC.test.cpp index 8810239b5b..0da05a2777 100644 --- a/src/ripple/rpc/tests/AccountLinesRPC.test.cpp +++ b/src/ripple/rpc/tests/AccountLinesRPC.test.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/rpc/tests/Book.test.cpp b/src/ripple/rpc/tests/Book.test.cpp index 8960a01134..56e4206936 100644 --- a/src/ripple/rpc/tests/Book.test.cpp +++ b/src/ripple/rpc/tests/Book.test.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include namespace ripple { namespace test { diff --git a/src/ripple/rpc/tests/JSONRPC.test.cpp b/src/ripple/rpc/tests/JSONRPC.test.cpp index bd6c7f247f..cdac4126ab 100644 --- a/src/ripple/rpc/tests/JSONRPC.test.cpp +++ b/src/ripple/rpc/tests/JSONRPC.test.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/rpc/tests/LedgerRequestRPC.test.cpp b/src/ripple/rpc/tests/LedgerRequestRPC.test.cpp index 310b607eaf..0871c0a6e7 100644 --- a/src/ripple/rpc/tests/LedgerRequestRPC.test.cpp +++ b/src/ripple/rpc/tests/LedgerRequestRPC.test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/rpc/tests/RobustTransaction.test.cpp b/src/ripple/rpc/tests/RobustTransaction.test.cpp index 86e7e3d803..5fa7cd0877 100644 --- a/src/ripple/rpc/tests/RobustTransaction.test.cpp +++ b/src/ripple/rpc/tests/RobustTransaction.test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace ripple { namespace test { diff --git a/src/ripple/rpc/tests/Status.test.cpp b/src/ripple/rpc/tests/Status.test.cpp index 0a83231bab..41851f1bc5 100644 --- a/src/ripple/rpc/tests/Status.test.cpp +++ b/src/ripple/rpc/tests/Status.test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include namespace ripple { diff --git a/src/ripple/rpc/tests/Subscribe.test.cpp b/src/ripple/rpc/tests/Subscribe.test.cpp index 51f572039f..af12b1920c 100644 --- a/src/ripple/rpc/tests/Subscribe.test.cpp +++ b/src/ripple/rpc/tests/Subscribe.test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include namespace ripple { namespace test { diff --git a/src/ripple/server/Handler.h b/src/ripple/server/Handler.h index d40c2e6892..6b8aa37c5d 100644 --- a/src/ripple/server/Handler.h +++ b/src/ripple/server/Handler.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/ripple/server/Handoff.h b/src/ripple/server/Handoff.h index f70a2e5034..5c37b7a85e 100644 --- a/src/ripple/server/Handoff.h +++ b/src/ripple/server/Handoff.h @@ -21,8 +21,8 @@ #define RIPPLE_SERVER_HANDOFF_H_INCLUDED #include -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/server/JsonWriter.h b/src/ripple/server/JsonWriter.h index 1d2d45226c..805eea550c 100644 --- a/src/ripple/server/JsonWriter.h +++ b/src/ripple/server/JsonWriter.h @@ -20,10 +20,11 @@ #ifndef RIPPLE_SERVER_JSONWRITER_H_INCLUDED #define RIPPLE_SERVER_JSONWRITER_H_INCLUDED +#include #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/server/Port.h b/src/ripple/server/Port.h index c0ddbea130..0df7baad75 100644 --- a/src/ripple/server/Port.h +++ b/src/ripple/server/Port.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include @@ -39,7 +39,7 @@ struct Port std::string name; boost::asio::ip::address ip; std::uint16_t port = 0; - std::set protocol; + std::set protocol; std::vector admin_ip; std::vector secure_gateway_ip; std::string user; @@ -73,7 +73,7 @@ operator<< (std::ostream& os, Port const& p); struct ParsedPort { std::string name; - std::set protocol; + std::set protocol; std::string user; std::string password; std::string admin_user; diff --git a/src/ripple/server/ServerHandler.h b/src/ripple/server/ServerHandler.h index be02f7c8b6..4af6454560 100644 --- a/src/ripple/server/ServerHandler.h +++ b/src/ripple/server/ServerHandler.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/src/ripple/server/Session.h b/src/ripple/server/Session.h index eada300447..9384b9afac 100644 --- a/src/ripple/server/Session.h +++ b/src/ripple/server/Session.h @@ -22,8 +22,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/server/impl/BaseHTTPPeer.h b/src/ripple/server/impl/BaseHTTPPeer.h index fa164982f8..d0dfa8ee66 100644 --- a/src/ripple/server/impl/BaseHTTPPeer.h +++ b/src/ripple/server/impl/BaseHTTPPeer.h @@ -26,12 +26,12 @@ #include #include #include -#include -#include // for is_short_read? -#include -#include -#include -#include +#include +#include // for is_short_read? +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/server/impl/BaseWSPeer.h b/src/ripple/server/impl/BaseWSPeer.h index 031aa137d7..0992cfd044 100644 --- a/src/ripple/server/impl/BaseWSPeer.h +++ b/src/ripple/server/impl/BaseWSPeer.h @@ -22,9 +22,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include namespace ripple { @@ -47,7 +47,7 @@ private: friend class BasePeer; http_request_type request_; - beast::wsproto::opcode op_; + beast::websocket::opcode op_; beast::streambuf rb_; beast::streambuf wb_; std::list> wq_; @@ -164,7 +164,7 @@ BaseWSPeer::run() if(! strand_.running_in_this_thread()) return strand_.post(std::bind( &BaseWSPeer::run, impl().shared_from_this())); - impl().ws_.set_option(beast::wsproto::decorate(identity{})); + impl().ws_.set_option(beast::websocket::decorate(identity{})); using namespace beast::asio; impl().ws_.async_accept(request_, strand_.wrap(std::bind( &BaseWSPeer::on_write_sb, impl().shared_from_this(), @@ -275,7 +275,7 @@ template void BaseWSPeer::on_read(error_code const& ec) { - if(ec == beast::wsproto::error::closed) + if(ec == beast::websocket::error::closed) return do_close(); if(ec) return fail(ec, "read"); diff --git a/src/ripple/server/impl/Door.cpp b/src/ripple/server/impl/Door.cpp index eedc58a504..a645700f2d 100644 --- a/src/ripple/server/impl/Door.cpp +++ b/src/ripple/server/impl/Door.cpp @@ -24,8 +24,8 @@ #include #include #include -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/server/impl/Door.h b/src/ripple/server/impl/Door.h index 67e1d3840f..9b0e1020d4 100644 --- a/src/ripple/server/impl/Door.h +++ b/src/ripple/server/impl/Door.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/ripple/server/impl/PlainWSPeer.h b/src/ripple/server/impl/PlainWSPeer.h index 87d9250341..e75476d0c9 100644 --- a/src/ripple/server/impl/PlainWSPeer.h +++ b/src/ripple/server/impl/PlainWSPeer.h @@ -39,7 +39,7 @@ private: using waitable_timer = boost::asio::basic_waitable_timer ; using socket_type = boost::asio::ip::tcp::socket; - beast::wsproto::socket ws_; + beast::websocket::stream ws_; public: template diff --git a/src/ripple/server/impl/Port.cpp b/src/ripple/server/impl/Port.cpp index 11ff6b4a98..60403a48b5 100644 --- a/src/ripple/server/impl/Port.cpp +++ b/src/ripple/server/impl/Port.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include #include namespace ripple { @@ -192,7 +192,7 @@ parse_Port (ParsedPort& port, Section const& section, std::ostream& log) { auto const lim = get (section, "limit", "unlimited"); - if (!beast::ci_equal (lim, "unlimited")) + if (!beast::detail::ci_equal (lim, "unlimited")) { try { diff --git a/src/ripple/server/impl/SSLHTTPPeer.h b/src/ripple/server/impl/SSLHTTPPeer.h index 30cef69df7..3b8ff7cb23 100644 --- a/src/ripple/server/impl/SSLHTTPPeer.h +++ b/src/ripple/server/impl/SSLHTTPPeer.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include namespace ripple { diff --git a/src/ripple/server/impl/SSLWSPeer.h b/src/ripple/server/impl/SSLWSPeer.h index 3633606c02..ce6968147f 100644 --- a/src/ripple/server/impl/SSLWSPeer.h +++ b/src/ripple/server/impl/SSLWSPeer.h @@ -22,9 +22,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include namespace ripple { @@ -44,7 +44,7 @@ private: boost::asio::basic_waitable_timer ; std::unique_ptr ssl_bundle_; - beast::wsproto::socket< + beast::websocket::stream< beast::asio::ssl_bundle::stream_type&> ws_; public: diff --git a/src/ripple/server/impl/ServerHandlerImp.cpp b/src/ripple/server/impl/ServerHandlerImp.cpp index 8171ed8c9a..d9a9d6a66b 100644 --- a/src/ripple/server/impl/ServerHandlerImp.cpp +++ b/src/ripple/server/impl/ServerHandlerImp.cpp @@ -38,8 +38,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -676,7 +676,7 @@ ServerHandlerImp::authorized (Port const& port, return false; std::string strUserPass64 = it->second.substr (6); boost::trim (strUserPass64); - std::string strUserPass = beast::base64_decode (strUserPass64); + std::string strUserPass = beast::detail::base64_decode (strUserPass64); std::string::size_type nColon = strUserPass.find (":"); if (nColon == std::string::npos) return false; diff --git a/src/ripple/server/tests/Server_test.cpp b/src/ripple/server/tests/Server_test.cpp index 409b739590..aa7cbe3759 100644 --- a/src/ripple/server/tests/Server_test.cpp +++ b/src/ripple/server/tests/Server_test.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index e2e1a1d45d..10f077bdee 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/shamap/impl/SHAMapSync.cpp b/src/ripple/shamap/impl/SHAMapSync.cpp index 4417a52672..d0fbc9fa3d 100644 --- a/src/ripple/shamap/impl/SHAMapSync.cpp +++ b/src/ripple/shamap/impl/SHAMapSync.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include namespace ripple { diff --git a/src/ripple/shamap/tests/FetchPack.test.cpp b/src/ripple/shamap/tests/FetchPack.test.cpp index 072102a1b1..1b8882a746 100644 --- a/src/ripple/shamap/tests/FetchPack.test.cpp +++ b/src/ripple/shamap/tests/FetchPack.test.cpp @@ -25,8 +25,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/src/ripple/shamap/tests/SHAMap.test.cpp b/src/ripple/shamap/tests/SHAMap.test.cpp index 0c7cd85bec..64ee9caa1d 100644 --- a/src/ripple/shamap/tests/SHAMap.test.cpp +++ b/src/ripple/shamap/tests/SHAMap.test.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include namespace ripple { diff --git a/src/ripple/shamap/tests/SHAMapSync.test.cpp b/src/ripple/shamap/tests/SHAMapSync.test.cpp index 141e823647..b7d66ff81c 100644 --- a/src/ripple/shamap/tests/SHAMapSync.test.cpp +++ b/src/ripple/shamap/tests/SHAMapSync.test.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include namespace ripple { namespace tests { diff --git a/src/ripple/shamap/tests/common.h b/src/ripple/shamap/tests/common.h index 79db0f550e..2a1e316e4f 100644 --- a/src/ripple/shamap/tests/common.h +++ b/src/ripple/shamap/tests/common.h @@ -31,7 +31,7 @@ #include #include #include -#include +#include namespace ripple { namespace tests { diff --git a/src/ripple/test/BasicNetwork.h b/src/ripple/test/BasicNetwork.h index a16e1d4885..158e2f1f8b 100644 --- a/src/ripple/test/BasicNetwork.h +++ b/src/ripple/test/BasicNetwork.h @@ -21,9 +21,9 @@ #define RIPPLE_TEST_BASICNETWORK_H_INCLUDED #include -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/ripple/test/impl/BasicNetwork_test.cpp b/src/ripple/test/impl/BasicNetwork_test.cpp index 22b3085ba3..dbfb951d9d 100644 --- a/src/ripple/test/impl/BasicNetwork_test.cpp +++ b/src/ripple/test/impl/BasicNetwork_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include diff --git a/src/ripple/test/impl/JSONRPCClient.cpp b/src/ripple/test/impl/JSONRPCClient.cpp index 583b4326f9..c95fe14dec 100644 --- a/src/ripple/test/impl/JSONRPCClient.cpp +++ b/src/ripple/test/impl/JSONRPCClient.cpp @@ -18,12 +18,13 @@ //============================================================================== #include +#include #include #include #include #include -#include -#include +#include +#include #include #include diff --git a/src/ripple/test/impl/WSClient.cpp b/src/ripple/test/impl/WSClient.cpp index 9c1b1153fc..4a8281fd54 100644 --- a/src/ripple/test/impl/WSClient.cpp +++ b/src/ripple/test/impl/WSClient.cpp @@ -24,12 +24,12 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include -#include +#include namespace ripple { namespace test { @@ -93,8 +93,8 @@ class WSClientImpl : public WSClient boost::asio::io_service::strand strand_; std::thread thread_; boost::asio::ip::tcp::socket stream_; - beast::wsproto::socket ws_; - beast::wsproto::opcode op_; + beast::websocket::stream ws_; + beast::websocket::opcode op_; beast::streambuf rb_; // synchronize destructor diff --git a/src/ripple/test/impl/WSClient_test.cpp b/src/ripple/test/impl/WSClient_test.cpp index c4308e9713..54738e78da 100644 --- a/src/ripple/test/impl/WSClient_test.cpp +++ b/src/ripple/test/impl/WSClient_test.cpp @@ -20,10 +20,10 @@ #include #include #include -#include -#include +#include +#include -#include +#include namespace ripple { namespace test { @@ -34,7 +34,7 @@ public: void test_utf8checker() { - beast::wsproto::detail::utf8_checker utf8c; + beast::websocket::detail::utf8_checker utf8c; std::uint8_t buffer[] = {0Xff}; expect(! utf8c.write(buffer, 3)); diff --git a/src/ripple/test/jtx/Account.h b/src/ripple/test/jtx/Account.h index cb631a2eb3..f8ddf34c7d 100644 --- a/src/ripple/test/jtx/Account.h +++ b/src/ripple/test/jtx/Account.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/ripple/test/jtx/Env.h b/src/ripple/test/jtx/Env.h index 4bea39ee5d..c26a84f7f4 100644 --- a/src/ripple/test/jtx/Env.h +++ b/src/ripple/test/jtx/Env.h @@ -42,8 +42,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -587,7 +587,7 @@ protected: FN const&... fN) { maybe_invoke(stx, f, - beast::is_call_possible()); invoke(stx, fN...); } @@ -621,7 +621,7 @@ protected: FN const&... fN) { maybe_invoke(jt, f, - beast::is_call_possible()); invoke(jt, fN...); } diff --git a/src/ripple/test/jtx/impl/Env_test.cpp b/src/ripple/test/jtx/impl/Env_test.cpp index f7635b73bd..3bf0ad7241 100644 --- a/src/ripple/test/jtx/impl/Env_test.cpp +++ b/src/ripple/test/jtx/impl/Env_test.cpp @@ -23,8 +23,8 @@ #include #include #include -#include -#include +#include +#include #include #include diff --git a/src/ripple/unity/beast.cpp b/src/ripple/unity/beast.cpp index 2ca9031b73..2d410ba090 100644 --- a/src/ripple/unity/beast.cpp +++ b/src/ripple/unity/beast.cpp @@ -22,6 +22,6 @@ // MUST come first! #include #include -#include +#include #endif diff --git a/src/ripple/websocket/AutoSocket.h b/src/ripple/websocket/AutoSocket.h index 70ec510c37..be58b8aeef 100644 --- a/src/ripple/websocket/AutoSocket.h +++ b/src/ripple/websocket/AutoSocket.h @@ -22,8 +22,8 @@ #include #include -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/websocket/Connection.h b/src/ripple/websocket/Connection.h index 57db1099a9..137e8e8184 100644 --- a/src/ripple/websocket/Connection.h +++ b/src/ripple/websocket/Connection.h @@ -41,7 +41,7 @@ #include #include -#include +#include #include namespace ripple { diff --git a/src/websocketpp_02/src/sockets/autotls.hpp b/src/websocketpp_02/src/sockets/autotls.hpp index c18de9115e..dc11e1dcb2 100644 --- a/src/websocketpp_02/src/sockets/autotls.hpp +++ b/src/websocketpp_02/src/sockets/autotls.hpp @@ -29,7 +29,7 @@ #define WEBSOCKETPP_SOCKET_AUTOTLS_HPP #include -#include +#include #include // Note that AutoSocket.h must be included before this file