diff --git a/CHANGELOG.md b/CHANGELOG.md
index b909dafc..de4f4969 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@ Version 58:
* Fix unaligned reads in utf8-checker
* Qualify size_t in message template
+* Reorganize examples
--------------------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 19903ed5..413548a4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -183,8 +183,8 @@ file(GLOB_RECURSE BEAST_INCLUDES
${PROJECT_SOURCE_DIR}/include/beast/*.ipp
)
-file(GLOB_RECURSE EXAMPLES_INCLUDES
- ${PROJECT_SOURCE_DIR}/examples/*.hpp
+file(GLOB_RECURSE EXAMPLE_INCLUDES
+ ${PROJECT_SOURCE_DIR}/example/*.hpp
)
file(GLOB_RECURSE EXTRAS_INCLUDES
@@ -192,16 +192,17 @@ file(GLOB_RECURSE EXTRAS_INCLUDES
${PROJECT_SOURCE_DIR}/extras/beast/*.ipp
)
-add_subdirectory (examples)
-if (NOT OPENSSL_FOUND)
- message("OpenSSL not found. Not building SSL tests and examples")
-else()
- add_subdirectory (examples/ssl)
- add_subdirectory (test/websocket/ssl)
-endif()
-
add_subdirectory (test)
add_subdirectory (test/core)
add_subdirectory (test/http)
add_subdirectory (test/websocket)
add_subdirectory (test/zlib)
+
+add_subdirectory (example)
+
+if (NOT OPENSSL_FOUND)
+ message("OpenSSL not found. Not building SSL tests and examples")
+else()
+ add_subdirectory (example/ssl)
+ add_subdirectory (test/websocket/ssl)
+endif()
diff --git a/Jamroot b/Jamroot
index 38f77417..bc67dc5f 100644
--- a/Jamroot
+++ b/Jamroot
@@ -112,4 +112,4 @@ project beast
;
build-project test ;
-build-project examples ;
+build-project example ;
diff --git a/appveyor.yml b/appveyor.yml
index 93614033..20125e5e 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -97,5 +97,5 @@ install:
build: off
test_script:
- - b2 libs/beast/examples toolset=msvc-14.0
+ - b2 libs/beast/example toolset=msvc-14.0
- b2 libs/beast/test toolset=msvc-14.0
diff --git a/doc/0_main.qbk b/doc/0_main.qbk
index b660a332..7cbbaeca 100644
--- a/doc/0_main.qbk
+++ b/doc/0_main.qbk
@@ -23,7 +23,6 @@
[template indexterm1[term1] ''''''[term1]'''''']
[template indexterm2[term1 term2] ''''''[term1]''''''[term2]'''''']
[template repo_file[path] ''''''[path]'''''']
-
[template include_file[path][^<''''''[path]''''''>]]
[def __N3747__ [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3747.pdf [*N3747]]]
@@ -76,12 +75,13 @@
[def __static_buffer__ [link beast.ref.beast__static_buffer `static_buffer`]]
[def __static_buffer_n__ [link beast.ref.beast__static_buffer_n `static_buffer_n`]]
-[import ../examples/file_body.hpp]
-[import ../examples/http_example.cpp]
-[import ../examples/websocket_example.cpp]
-[import ../examples/echo_op.cpp]
-[import ../examples/doc_core_samples.hpp]
-[import ../examples/doc_http_samples.hpp]
+[import ../example/doc/core_examples.hpp]
+[import ../example/doc/http_examples.hpp]
+[import ../example/echo-op/echo_op.cpp]
+[import ../example/http-client/http_client.cpp]
+[import ../example/http-server/file_body.hpp]
+[import ../example/websocket-client/websocket_client.cpp]
+
[import ../test/core/doc_snippets.cpp]
[import ../test/http/doc_snippets.cpp]
[import ../test/websocket/doc_snippets.cpp]
diff --git a/doc/2_examples.qbk b/doc/2_examples.qbk
index e7b043e6..6bc6c4be 100644
--- a/doc/2_examples.qbk
+++ b/doc/2_examples.qbk
@@ -17,47 +17,59 @@ in the examples directory.
Use HTTP to make a GET request to a website and print the response:
-File: [repo_file examples/http_example.cpp]
+File: [repo_file example/http-client/http_client.cpp]
+
+[example_http_client]
+
-[http_example_get]
[heading WebSocket]
Establish a WebSocket connection, send a message and receive the reply:
-File: [repo_file examples/websocket_example.cpp]
+File: [repo_file example/websocket-client/websocket_client.cpp]
+
+[example_websocket_client]
+
-[websocket_example_client_echo]
[heading WebSocket Echo Server]
This example demonstrates both synchronous and asynchronous
WebSocket server implementations.
-* [repo_file examples/websocket_async_echo_server.hpp]
-* [repo_file examples/websocket_sync_echo_server.hpp]
-* [repo_file examples/websocket_echo.cpp]
+* [repo_file example/websocket-server/main.cpp]
+* [repo_file example/websocket-server/websocket_async_echo_server.hpp]
+* [repo_file example/websocket-server/websocket_sync_echo_server.hpp]
+
+
[heading Secure WebSocket]
Establish a WebSocket connection over an encrypted TLS connection,
send a message and receive the reply. Requires OpenSSL to build.
-* [repo_file examples/ssl/websocket_ssl_example.cpp]
+* [repo_file example/ssl/websocket_ssl_example.cpp]
+
+
[heading HTTPS GET]
This example demonstrates sending and receiving HTTP messages
over a TLS connection. Requires OpenSSL to build.
-* [repo_file examples/ssl/http_ssl_example.cpp]
+* [repo_file example/ssl/http_ssl_example.cpp]
+
+
[heading HTTP Crawl]
This example retrieves the page at each of the most popular domains
as measured by Alexa.
-* [repo_file examples/http_crawl.cpp]
+* [repo_file example/http-crawl/http_crawl.cpp]
+
+
[heading HTTP Server]
@@ -65,19 +77,23 @@ This example demonstrates both synchronous and asynchronous server
implementations. It also provides an example of implementing a [*Body]
type, in `file_body`.
-* [repo_file examples/file_body.hpp]
-* [repo_file examples/http_async_server.hpp]
-* [repo_file examples/http_sync_server.hpp]
-* [repo_file examples/http_server.cpp]
+* [repo_file example/http-server/file_body.hpp]
+* [repo_file example/http-server/http_async_server.hpp]
+* [repo_file example/http-server/http_sync_server.hpp]
+* [repo_file example/http-server/main.cpp]
+
+
[heading Composed Operations]
-This program shows how to use Beast's core foundations to build a
+This program shows how to use Beast's network foundations to build a
composable asynchronous initiation function with associated composed
operation implementation. This is a complete, runnable version of
the example described in the Core Foundations document section.
-* [repo_file examples/echo_op.cpp]
+* [repo_file example/echo-op/echo_op.cpp]
+
+
[heading Documentation Samples]
@@ -85,8 +101,10 @@ Here are all of the example functions and classes presented
throughout the documentation, they can be included and used
in your program without modification
-* [repo_file examples/doc_core_samples.hpp]
+* [repo_file example/doc/core_examples.hpp]
+
+* [repo_file example/doc/http_examples.hpp]
+
-* [repo_file examples/doc_http_samples.hpp]
[endsect]
diff --git a/doc/3_4_composed.qbk b/doc/3_4_composed.qbk
index 50c083f7..48f9cc98 100644
--- a/doc/3_4_composed.qbk
+++ b/doc/3_4_composed.qbk
@@ -6,6 +6,7 @@
]
[section:composed Composed Operations]
+[block'''''']
Asynchronous operations are started by calling a free function or member
function known as an ['asynchronous initiation function]. The initiation
@@ -100,7 +101,9 @@ available:
]]
]
-[heading Example: Asynchronous Echo]
+
+
+[section Asynchronous Echo]
Here we develop an asynchronous composed operation called [*echo].
This operation will read up to the first newline on a stream, and
@@ -112,14 +115,14 @@ initiation function. For our echo operation the only inputs are the
stream and the completion token. The output is the error code which
is usually included in all completion handler signatures.
-[core_sample_echo_op_1]
+[example_core_echo_op_1]
Now that we have a declaration, we will define the body of the function.
We want to achieve the following goals: perform static type checking on
the input parameters, set up the return value as per __N3747__, and launch
the composed operation by constructing the object and invoking it.
-[core_sample_echo_op_2]
+[example_core_echo_op_2]
The initiation function contains a few relatively simple parts. There is
the customization of the return value type, static type checking, building
@@ -133,7 +136,7 @@ without explaining them in depth.
Here is the boilerplate present in all composed operations written
in this style:
-[core_sample_echo_op_3]
+[example_core_echo_op_3]
We have the common boilerplate for a composed operation and now we just need
to implement the function call operator. Our strategy is to make our composed
@@ -147,9 +150,13 @@ care must be taken to ensure that no access to data members are made after the
move takes place. Here is the implementation of the function call operator for
this echo operation:
-[core_sample_echo_op_4]
+[example_core_echo_op_4]
A complete, runnable version of this example may be found in the examples
directory.
[endsect]
+
+
+
+[endsect]
diff --git a/doc/3_5_detect_ssl.qbk b/doc/3_5_detect_ssl.qbk
index afe75fda..3fe70cbd 100644
--- a/doc/3_5_detect_ssl.qbk
+++ b/doc/3_5_detect_ssl.qbk
@@ -18,23 +18,23 @@ Here is the declaration for a function to detect the SSL client handshake.
The input to the function is simply a buffer sequence, no stream. This
allows the detection algorithm to be used elsewhere.
-[core_sample_detect_tls_1]
+[example_core_detect_tls_1]
The implementation checks the buffer for the presence of the SSL
Handshake message octet sequence and returns an apporopriate value:
-[core_sample_detect_tls_2]
+[example_core_detect_tls_2]
Now we define a stream operation. We start with the simple,
synchronous version which takes the stream and buffer as input:
-[core_sample_detect_tls_3]
+[example_core_detect_tls_3]
The synchronous algorithm is the model for building the asynchronous
operation which has more boilerplate. First, we declare the asynchronous
initiation function:
-[core_sample_detect_tls_4]
+[example_core_detect_tls_4]
The implementation of the initiation function is straightforward
and contains mostly boilerplate. It is to construct the return
@@ -43,13 +43,13 @@ then create the composed operation and launch it. The actual
code for interacting with the stream is in the composed operation,
which is written as a separate class.
-[core_sample_detect_tls_5]
+[example_core_detect_tls_5]
Now we will declare our composed operation. There is a considerable
amount of necessary boilerplate to get this right, but the result
is worth the effort.
-[core_sample_detect_tls_6]
+[example_core_detect_tls_6]
The boilerplate is all done, and now we need to implemnt the function
call operator that turns this composed operation a completion handler
@@ -59,6 +59,6 @@ is a transformation of the synchronous version of `detect_ssl` above,
but with the inversion of flow that characterizes code written in the
callback style:
-[core_sample_detect_tls_7]
+[example_core_detect_tls_7]
[endsect]
diff --git a/doc/5_06_serializer_buffers.qbk b/doc/5_06_serializer_buffers.qbk
index b961531f..1662ccd6 100644
--- a/doc/5_06_serializer_buffers.qbk
+++ b/doc/5_06_serializer_buffers.qbk
@@ -6,6 +6,7 @@
]
[section:serializer_buffers Buffer-Oriented Serializing]
+[block'''''']
An instance of __serializer__ can be invoked directly, without using
the provided stream operations. This could be useful for implementing
@@ -53,14 +54,16 @@ C++14 example we print the header first, followed by the body:
[http_snippet_16]
-[heading Example: Write To std::ostream]
+
+
+[section Write To std::ostream]
The standard library provides the type `std::ostream` for performing high
level write operations on character streams. The variable `std::cout` is
based on this output stream. This example uses the buffer oriented interface
of __serializer__ to write an HTTP message to a `std::ostream`:
-[http_sample_write_ostream]
+[example_http_write_ostream]
[tip
Serializing to a `std::ostream` could be implemented using an alternate
@@ -69,6 +72,8 @@ of __serializer__ to write an HTTP message to a `std::ostream`:
left as an exercise for the reader.
]
+[endsect]
+
[endsect]
diff --git a/doc/5_07_parser_buffers.qbk b/doc/5_07_parser_buffers.qbk
index 045812da..2f966271 100644
--- a/doc/5_07_parser_buffers.qbk
+++ b/doc/5_07_parser_buffers.qbk
@@ -6,6 +6,7 @@
]
[section:parser_buffers Buffer-Oriented Parsing]
+[block'''''']
A subclass of __basic_parser__ can be invoked directly, without using
the provided stream operations. This could be useful for implementing
@@ -59,7 +60,9 @@ The parser provides two options which may be set before parsing begins:
]]
]
-[heading Example: Read From std::istream]
+
+
+[section Read From std::istream]
The standard library provides the type `std::istream` for performing high
level read operations on character streams. The variable `std::cin` is based
@@ -67,7 +70,7 @@ on this input stream. This example uses the buffer oriented interface of
__basic_parser__ to build a stream operation which parses an HTTP message
from a `std::istream`:
-[http_sample_read_istream]
+[example_http_read_istream]
[tip
Parsing from a `std::istream` could be implemented using an alternate
@@ -77,3 +80,7 @@ from a `std::istream`:
]
[endsect]
+
+
+
+[endsect]
diff --git a/doc/5_08_custom_parsers.qbk b/doc/5_08_custom_parsers.qbk
index e495f05c..4e0f2370 100644
--- a/doc/5_08_custom_parsers.qbk
+++ b/doc/5_08_custom_parsers.qbk
@@ -34,6 +34,6 @@ Buffers provided by the parser are non-owning references; it is the
responsibility of the derived class to copy any information it needs before
returning from the callback.
-[http_sample_custom_parser]
+[example_http_custom_parser]
[endsect]
diff --git a/doc/5_09_custom_body.qbk b/doc/5_09_custom_body.qbk
index 71f1f045..6f7294ed 100644
--- a/doc/5_09_custom_body.qbk
+++ b/doc/5_09_custom_body.qbk
@@ -6,6 +6,7 @@
]
[section:custom_body Custom Body Types]
+[block'''''']
User-defined types are possible for the message body, where the type meets the
__Body__ requirements. This simplified class declaration
@@ -72,7 +73,9 @@ As long as a suitable reader or writer is available to provide the
algorithm for transferring buffers in and out of the value type,
those bodies may be serialized or parsed.
-[heading Example: File Body Type]
+
+
+[section File Body Type]
Use of the flexible __Body__ concept customization point enables authors to
preserve the self-contained nature of the __message__ object while allowing
@@ -83,32 +86,32 @@ to a file on the file system.
First we declare the type itself, along with the required members:
-[http_sample_file_body_1]
+[example_http_file_body_1]
The `size` function is a simple call to retrieve the file size:
-[http_sample_file_body_2]
+[example_http_file_body_2]
Our implementation of __BodyReader__ will contain a small buffer
from which the file contents are read. The buffer is provided to
the implementation on each call until everything has been read in.
-[http_sample_file_body_3]
+[example_http_file_body_3]
And here are the definitions for the functions we have declared:
-[http_sample_file_body_4]
+[example_http_file_body_4]
Files can be read now, and the next step is to allow writing to files
by implementing the __BodyWriter__. The style is similar to the reader,
except that buffers are incoming instead of outgoing. Here's the
declaration:
-[http_sample_file_body_5]
+[example_http_file_body_5]
Finally, here is the implementation of the writer member functions:
-[http_sample_file_body_6]
+[example_http_file_body_6]
We have created a full featured body type capable of reading and
writing files on the filesystem, integrating seamlessly with the
@@ -117,3 +120,7 @@ type, and HTTP servers that use it, are available in the examples
directory.
[endsect]
+
+
+
+[endsect]
diff --git a/doc/6_0_http_examples.qbk b/doc/6_0_http_examples.qbk
index 2e8cd7fb..de7b5061 100644
--- a/doc/6_0_http_examples.qbk
+++ b/doc/6_0_http_examples.qbk
@@ -5,7 +5,7 @@
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
]
-[section HTTP Examples]
+[section More Examples]
These examples in this section are working functions that may be found
in the examples directory. They demonstrate the usage of the library for
@@ -27,7 +27,7 @@ by information from the header or elsewhere.
This example illustrates how a server may make the commitment of a body
type depending on the method verb:
-[http_sample_defer_body]
+[example_http_defer_body]
[endsect]
@@ -46,7 +46,7 @@ the server response, and finally conditionally send the body using the same
serializer instance. A synchronous, simplified version (no timeout) of
this client action looks like this:
-[http_sample_send_expect_100_continue]
+[example_http_send_expect_100_continue]
[endsect]
@@ -64,7 +64,7 @@ a __parser__ to read the header first, then send an informational HTTP
response, and finally read the body using the same parser instance. A
synchronous version of this server action looks like this:
-[http_sample_receive_expect_100_continue]
+[example_http_receive_expect_100_continue]
[endsect]
@@ -78,7 +78,7 @@ method indicates to the server that the client wishes to receive the
entire header that would be delivered if the method was GET, except
that the body is omitted.
-[http_sample_do_head_request]
+[example_http_do_head_request]
[endsect]
@@ -91,7 +91,7 @@ When a server receives a
the response should contain the entire header that would be delivered
if the method was GET, except that the body is omitted.
-[http_sample_do_head_response]
+[example_http_do_head_response]
[endsect]
@@ -111,7 +111,7 @@ connection sees a header without unnecessary latency. This example brings
together all of the concepts discussed so far, it uses both a __serializer__
and a __parser__ to achieve its goal:
-[http_sample_relay]
+[example_http_relay]
[endsect]
@@ -134,7 +134,7 @@ the pointer and size fields before calling a stream write function.
This example reads from a child process and sends the output back in an
HTTP response. The output of the process is sent as it becomes available:
-[http_sample_send_cgi_response]
+[example_http_send_cgi_response]
[endsect]
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
new file mode 100644
index 00000000..fac79004
--- /dev/null
+++ b/example/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Part of Beast
+
+add_subdirectory (echo-op)
+add_subdirectory (http-client)
+add_subdirectory (http-crawl)
+add_subdirectory (http-server)
+add_subdirectory (websocket-client)
+add_subdirectory (websocket-server)
diff --git a/example/Jamfile b/example/Jamfile
new file mode 100644
index 00000000..d0840b73
--- /dev/null
+++ b/example/Jamfile
@@ -0,0 +1,13 @@
+#
+# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#
+
+build-project echo-op ;
+build-project http-client ;
+build-project http-crawl ;
+build-project http-server ;
+build-project websocket-client ;
+build-project websocket-server ;
diff --git a/examples/doc_core_samples.hpp b/example/doc/core_examples.hpp
similarity index 97%
rename from examples/doc_core_samples.hpp
rename to example/doc/core_examples.hpp
index 7f6449e1..268f7292 100644
--- a/examples/doc_core_samples.hpp
+++ b/example/doc/core_examples.hpp
@@ -8,13 +8,19 @@
#include
#include
+/* This file contains the functions and classes found in the documentation
+
+ They are compiled and run as part of the unit tests, so you can copy
+ the code and use it in your own projects as a starting point for
+ building a network application.
+*/
//------------------------------------------------------------------------------
//
// Example: Detect TLS/SSL
//
//------------------------------------------------------------------------------
-//[core_sample_detect_tls_1
+//[example_core_detect_tls_1
#include
#include
@@ -49,7 +55,7 @@ is_ssl_handshake(ConstBufferSequence const& buffers);
using namespace beast;
-//[core_sample_detect_tls_2
+//[example_core_detect_tls_2
template<
class ConstBufferSequence>
@@ -88,7 +94,7 @@ is_ssl_handshake(
//]
-//[core_sample_detect_tls_3
+//[example_core_detect_tls_3
/** Detect a TLS/SSL handshake on a stream.
@@ -170,7 +176,7 @@ detect_ssl(
//]
-//[core_sample_detect_tls_4
+//[example_core_detect_tls_4
/** Detect a TLS/SSL handshake asynchronously on a stream.
@@ -228,7 +234,7 @@ async_detect_ssl(
//]
-//[core_sample_detect_tls_5
+//[example_core_detect_tls_5
// This is the composed operation.
template<
@@ -286,7 +292,7 @@ async_detect_ssl(
//]
-//[core_sample_detect_tls_6
+//[example_core_detect_tls_6
// Read from a stream to invoke is_tls_handshake asynchronously
//
@@ -383,7 +389,7 @@ public:
//]
-//[core_sample_detect_tls_7
+//[example_core_detect_tls_7
// detect_ssl_op is callable with the signature
// void(error_code, bytes_transferred),
diff --git a/examples/doc_http_samples.hpp b/example/doc/http_examples.hpp
similarity index 97%
rename from examples/doc_http_samples.hpp
rename to example/doc/http_examples.hpp
index 7cfa76b1..f1add098 100644
--- a/examples/doc_http_samples.hpp
+++ b/example/doc/http_examples.hpp
@@ -7,7 +7,12 @@
#include
-// Contains the HTTP Examples from the documentation.
+/* This file contains the functions and classes found in the documentation
+
+ They are compiled and run as part of the unit tests, so you can copy
+ the code and use it in your own projects as a starting point for
+ building a network application.
+*/
// The documentation assumes the beast::http namespace
namespace beast {
@@ -19,7 +24,7 @@ namespace http {
//
//------------------------------------------------------------------------------
-//[http_sample_send_expect_100_continue
+//[example_http_send_expect_100_continue
/** Send a request with Expect: 100-continue
@@ -88,7 +93,7 @@ send_expect_100_continue(
//]
-//[http_sample_receive_expect_100_continue
+//[example_http_receive_expect_100_continue
/** Receive a request, handling Expect: 100-continue if present.
@@ -155,7 +160,7 @@ receive_expect_100_continue(
//
//------------------------------------------------------------------------------
-//[http_sample_send_cgi_response
+//[example_http_send_cgi_response
/** Send the output of a child process as an HTTP response.
@@ -273,7 +278,7 @@ send_cgi_response(
//
//--------------------------------------------------------------------------
-//[http_sample_do_head_response
+//[example_http_do_head_response
/** Handle a HEAD request for a resource.
*/
@@ -347,7 +352,7 @@ void do_server_head(
//]
-//[http_sample_do_head_request
+//[example_http_do_head_request
/** Send a HEAD request for a resource.
@@ -425,7 +430,7 @@ do_head_request(
//
//------------------------------------------------------------------------------
-//[http_sample_relay
+//[example_http_relay
/** Relay an HTTP message.
@@ -552,7 +557,7 @@ relay(
//
//------------------------------------------------------------------------------
-//[http_sample_write_ostream
+//[example_http_write_ostream
// The detail namespace means "not public"
namespace detail {
@@ -662,7 +667,7 @@ write_ostream(
//
//------------------------------------------------------------------------------
-//[http_sample_read_istream
+//[example_http_read_istream
/** Read a message from a `std::istream`.
@@ -771,7 +776,7 @@ read_istream(
//
//------------------------------------------------------------------------------
-//[http_sample_defer_body
+//[example_http_defer_body
/** Handle a form PUT request, choosing a body type depending on the Content-Type.
@@ -865,7 +870,7 @@ do_form_request(
//
//------------------------------------------------------------------------------
-//[http_sample_custom_parser
+//[example_http_custom_parser
template
class custom_parser
diff --git a/example/echo-op/CMakeLists.txt b/example/echo-op/CMakeLists.txt
new file mode 100644
index 00000000..5d0ced78
--- /dev/null
+++ b/example/echo-op/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Part of Beast
+
+GroupSources(extras/beast extras)
+GroupSources(include/beast beast)
+
+GroupSources(example/echo-op "/")
+
+add_executable (echo-op
+ ${BEAST_INCLUDES}
+ echo_op.cpp
+)
+
+if (NOT WIN32)
+ target_link_libraries(echo-op ${Boost_LIBRARIES} Threads::Threads)
+else()
+ target_link_libraries(echo-op ${Boost_LIBRARIES})
+endif()
diff --git a/example/echo-op/Jamfile b/example/echo-op/Jamfile
new file mode 100644
index 00000000..47415002
--- /dev/null
+++ b/example/echo-op/Jamfile
@@ -0,0 +1,10 @@
+#
+# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#
+
+exe echo-op/echo-op :
+ echo_op.cpp
+ ;
diff --git a/examples/echo_op.cpp b/example/echo-op/echo_op.cpp
similarity index 99%
rename from examples/echo_op.cpp
rename to example/echo-op/echo_op.cpp
index 95cfffb8..108c1853 100644
--- a/examples/echo_op.cpp
+++ b/example/echo-op/echo_op.cpp
@@ -11,7 +11,7 @@
#include
#include
-//[core_sample_echo_op_1
+//[example_core_echo_op_1
/** Asynchronously read a line and echo it back.
@@ -61,7 +61,7 @@ async_echo(
//]
-//[core_sample_echo_op_3
+//[example_core_echo_op_3
// This composed operation reads a line of input and echoes it back.
//
@@ -181,7 +181,7 @@ public:
//]
-//[core_sample_echo_op_4
+//[example_core_echo_op_4
// echo_op is callable with the signature void(error_code, bytes_transferred),
// allowing `*this` to be used as both a ReadHandler and a WriteHandler.
@@ -228,7 +228,7 @@ operator()(beast::error_code ec, std::size_t bytes_transferred)
//]
-//[core_sample_echo_op_2
+//[example_core_echo_op_2
template
class echo_op;
diff --git a/example/http-client/CMakeLists.txt b/example/http-client/CMakeLists.txt
new file mode 100644
index 00000000..0ec62123
--- /dev/null
+++ b/example/http-client/CMakeLists.txt
@@ -0,0 +1,18 @@
+# Part of Beast
+
+GroupSources(extras/beast extras)
+GroupSources(include/beast beast)
+
+GroupSources(example/http-client "/")
+
+add_executable (http-client
+ ${BEAST_INCLUDES}
+ ${EXTRAS_INCLUDES}
+ http_client.cpp
+)
+
+if (NOT WIN32)
+ target_link_libraries(http-client ${Boost_LIBRARIES} Threads::Threads)
+else()
+ target_link_libraries(http-client ${Boost_LIBRARIES})
+endif()
diff --git a/example/http-client/Jamfile b/example/http-client/Jamfile
new file mode 100644
index 00000000..ce558d81
--- /dev/null
+++ b/example/http-client/Jamfile
@@ -0,0 +1,10 @@
+#
+# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#
+
+exe http-client :
+ http_client.cpp
+ ;
diff --git a/examples/http_example.cpp b/example/http-client/http_client.cpp
similarity index 98%
rename from examples/http_example.cpp
rename to example/http-client/http_client.cpp
index b2c4fe07..2982d1d7 100644
--- a/examples/http_example.cpp
+++ b/example/http-client/http_client.cpp
@@ -5,7 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-//[http_example_get
+//[example_http_client
#include
#include
diff --git a/example/http-crawl/CMakeLists.txt b/example/http-crawl/CMakeLists.txt
new file mode 100644
index 00000000..999efe48
--- /dev/null
+++ b/example/http-crawl/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Part of Beast
+
+GroupSources(extras/beast extras)
+GroupSources(include/beast beast)
+
+GroupSources(example/http-crawl "/")
+
+add_executable (http-crawl
+ ${BEAST_INCLUDES}
+ ${EXTRAS_INCLUDES}
+ urls_large_data.hpp
+ urls_large_data.cpp
+ http_crawl.cpp
+)
+
+if (NOT WIN32)
+ target_link_libraries(http-crawl ${Boost_LIBRARIES} Threads::Threads)
+else()
+ target_link_libraries(http-crawl ${Boost_LIBRARIES})
+endif()
diff --git a/examples/Jamfile b/example/http-crawl/Jamfile
similarity index 55%
rename from examples/Jamfile
rename to example/http-crawl/Jamfile
index d4291648..afb12370 100644
--- a/examples/Jamfile
+++ b/example/http-crawl/Jamfile
@@ -5,27 +5,7 @@
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
-exe echo-op :
- echo_op.cpp
- ;
-
exe http-crawl :
http_crawl.cpp
urls_large_data.cpp
;
-
-exe http-server :
- http_server.cpp
- ;
-
-exe http-example :
- http_example.cpp
- ;
-
-exe websocket-echo :
- websocket_echo.cpp
- ;
-
-exe websocket-example :
- websocket_example.cpp
- ;
diff --git a/examples/http_crawl.cpp b/example/http-crawl/http_crawl.cpp
similarity index 100%
rename from examples/http_crawl.cpp
rename to example/http-crawl/http_crawl.cpp
diff --git a/examples/urls_large_data.cpp b/example/http-crawl/urls_large_data.cpp
similarity index 100%
rename from examples/urls_large_data.cpp
rename to example/http-crawl/urls_large_data.cpp
diff --git a/examples/urls_large_data.hpp b/example/http-crawl/urls_large_data.hpp
similarity index 100%
rename from examples/urls_large_data.hpp
rename to example/http-crawl/urls_large_data.hpp
diff --git a/example/http-server/CMakeLists.txt b/example/http-server/CMakeLists.txt
new file mode 100644
index 00000000..de6266e1
--- /dev/null
+++ b/example/http-server/CMakeLists.txt
@@ -0,0 +1,22 @@
+# Part of Beast
+
+GroupSources(extras/beast extras)
+GroupSources(include/beast beast)
+
+GroupSources(example/http-server "/")
+
+add_executable (http-server
+ ${BEAST_INCLUDES}
+ ${EXTRAS_INCLUDES}
+ file_body.hpp
+ mime_type.hpp
+ http_async_server.hpp
+ http_sync_server.hpp
+ main.cpp
+)
+
+if (NOT WIN32)
+ target_link_libraries(http-server ${Boost_LIBRARIES} Threads::Threads)
+else()
+ target_link_libraries(http-server ${Boost_LIBRARIES})
+endif()
diff --git a/example/http-server/Jamfile b/example/http-server/Jamfile
new file mode 100644
index 00000000..137770a2
--- /dev/null
+++ b/example/http-server/Jamfile
@@ -0,0 +1,10 @@
+#
+# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#
+
+exe http-server :
+ main.cpp
+ ;
diff --git a/examples/file_body.hpp b/example/http-server/file_body.hpp
similarity index 98%
rename from examples/file_body.hpp
rename to example/http-server/file_body.hpp
index 57d7ca77..512381f6 100644
--- a/examples/file_body.hpp
+++ b/example/http-server/file_body.hpp
@@ -21,7 +21,7 @@
namespace beast {
namespace http {
-//[http_sample_file_body_1
+//[example_http_file_body_1
struct file_body
{
@@ -70,7 +70,7 @@ struct file_body
//]
-//[http_sample_file_body_2
+//[example_http_file_body_2
template
std::uint64_t
@@ -82,7 +82,7 @@ size(message const& m)
//]
-//[http_sample_file_body_3
+//[example_http_file_body_3
class file_body::reader
{
@@ -145,7 +145,7 @@ public:
//]
-//[http_sample_file_body_4
+//[example_http_file_body_4
// Here we just stash a reference to the path for later.
// Rather than dealing with messy constructor exceptions,
@@ -266,7 +266,7 @@ file_body::reader::
//]
-//[http_sample_file_body_5
+//[example_http_file_body_5
class file_body::writer
{
@@ -317,7 +317,7 @@ public:
//]
-//[http_sample_file_body_6
+//[example_http_file_body_6
// Just stash a reference to the path so we can open the file later.
template
diff --git a/examples/http_async_server.hpp b/example/http-server/http_async_server.hpp
similarity index 100%
rename from examples/http_async_server.hpp
rename to example/http-server/http_async_server.hpp
diff --git a/examples/http_sync_server.hpp b/example/http-server/http_sync_server.hpp
similarity index 100%
rename from examples/http_sync_server.hpp
rename to example/http-server/http_sync_server.hpp
diff --git a/examples/http_server.cpp b/example/http-server/main.cpp
similarity index 100%
rename from examples/http_server.cpp
rename to example/http-server/main.cpp
diff --git a/examples/mime_type.hpp b/example/http-server/mime_type.hpp
similarity index 100%
rename from examples/mime_type.hpp
rename to example/http-server/mime_type.hpp
diff --git a/examples/ssl/CMakeLists.txt b/example/ssl/CMakeLists.txt
similarity index 95%
rename from examples/ssl/CMakeLists.txt
rename to example/ssl/CMakeLists.txt
index df35e5f3..9962a9dc 100644
--- a/examples/ssl/CMakeLists.txt
+++ b/example/ssl/CMakeLists.txt
@@ -3,7 +3,7 @@
GroupSources(extras/beast extras)
GroupSources(include/beast beast)
-GroupSources(examples/ssl "/")
+GroupSources(example/ssl "/")
include_directories(${OPENSSL_INCLUDE_DIR})
diff --git a/examples/ssl/Jamfile.v2 b/example/ssl/Jamfile.v2
similarity index 100%
rename from examples/ssl/Jamfile.v2
rename to example/ssl/Jamfile.v2
diff --git a/examples/ssl/http_ssl_example.cpp b/example/ssl/http_ssl_example.cpp
similarity index 100%
rename from examples/ssl/http_ssl_example.cpp
rename to example/ssl/http_ssl_example.cpp
diff --git a/examples/ssl/websocket_ssl_example.cpp b/example/ssl/websocket_ssl_example.cpp
similarity index 100%
rename from examples/ssl/websocket_ssl_example.cpp
rename to example/ssl/websocket_ssl_example.cpp
diff --git a/example/websocket-client/CMakeLists.txt b/example/websocket-client/CMakeLists.txt
new file mode 100644
index 00000000..e998356d
--- /dev/null
+++ b/example/websocket-client/CMakeLists.txt
@@ -0,0 +1,19 @@
+# Part of Beast
+
+GroupSources(extras/beast extras)
+GroupSources(include/beast beast)
+
+GroupSources(example/websocket-client "/")
+
+add_executable (websocket-client
+ ${BEAST_INCLUDES}
+ ${EXTRAS_INCLUDES}
+ websocket_client.cpp
+)
+
+if (NOT WIN32)
+ target_link_libraries(websocket-client ${Boost_LIBRARIES} Threads::Threads)
+else()
+ target_link_libraries(websocket-client ${Boost_LIBRARIES})
+endif()
+
diff --git a/example/websocket-client/Jamfile b/example/websocket-client/Jamfile
new file mode 100644
index 00000000..f09ea43a
--- /dev/null
+++ b/example/websocket-client/Jamfile
@@ -0,0 +1,10 @@
+#
+# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#
+
+exe websocket-client :
+ websocket_client.cpp
+ ;
diff --git a/examples/websocket_example.cpp b/example/websocket-client/websocket_client.cpp
similarity index 97%
rename from examples/websocket_example.cpp
rename to example/websocket-client/websocket_client.cpp
index 69e6df8b..2e6241d6 100644
--- a/examples/websocket_example.cpp
+++ b/example/websocket-client/websocket_client.cpp
@@ -5,7 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-//[websocket_example_client_echo
+//[example_websocket_client
#include
#include
diff --git a/example/websocket-server/CMakeLists.txt b/example/websocket-server/CMakeLists.txt
new file mode 100644
index 00000000..48dc3e76
--- /dev/null
+++ b/example/websocket-server/CMakeLists.txt
@@ -0,0 +1,19 @@
+# Part of Beast
+
+GroupSources(extras/beast extras)
+GroupSources(include/beast beast)
+
+GroupSources(example/websocket-server "/")
+
+add_executable (websocket-server
+ ${BEAST_INCLUDES}
+ main.cpp
+ websocket_async_echo_server.hpp
+ websocket_sync_echo_server.hpp
+)
+
+if (NOT WIN32)
+ target_link_libraries(websocket-server ${Boost_LIBRARIES} Threads::Threads)
+else()
+ target_link_libraries(websocket-server ${Boost_LIBRARIES})
+endif()
diff --git a/example/websocket-server/Jamfile b/example/websocket-server/Jamfile
new file mode 100644
index 00000000..97223064
--- /dev/null
+++ b/example/websocket-server/Jamfile
@@ -0,0 +1,10 @@
+#
+# Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
+#
+# Distributed under the Boost Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#
+
+exe websocket-server :
+ main.cpp
+ ;
diff --git a/examples/websocket_echo.cpp b/example/websocket-server/main.cpp
similarity index 100%
rename from examples/websocket_echo.cpp
rename to example/websocket-server/main.cpp
diff --git a/examples/websocket_async_echo_server.hpp b/example/websocket-server/websocket_async_echo_server.hpp
similarity index 100%
rename from examples/websocket_async_echo_server.hpp
rename to example/websocket-server/websocket_async_echo_server.hpp
diff --git a/examples/websocket_sync_echo_server.hpp b/example/websocket-server/websocket_sync_echo_server.hpp
similarity index 100%
rename from examples/websocket_sync_echo_server.hpp
rename to example/websocket-server/websocket_sync_echo_server.hpp
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
deleted file mode 100644
index ad53efe0..00000000
--- a/examples/CMakeLists.txt
+++ /dev/null
@@ -1,87 +0,0 @@
-# Part of Beast
-
-GroupSources(extras/beast extras)
-GroupSources(include/beast beast)
-
-GroupSources(examples "/")
-
-add_executable (echo-op
- ${BEAST_INCLUDES}
- echo_op.cpp
-)
-
-if (NOT WIN32)
- target_link_libraries(echo-op ${Boost_LIBRARIES} Threads::Threads)
-else()
- target_link_libraries(echo-op ${Boost_LIBRARIES})
-endif()
-
-add_executable (http-crawl
- ${BEAST_INCLUDES}
- ${EXTRAS_INCLUDES}
- urls_large_data.hpp
- urls_large_data.cpp
- http_crawl.cpp
-)
-
-if (NOT WIN32)
- target_link_libraries(http-crawl ${Boost_LIBRARIES} Threads::Threads)
-else()
- target_link_libraries(http-crawl ${Boost_LIBRARIES})
-endif()
-
-add_executable (http-server
- ${BEAST_INCLUDES}
- ${EXTRAS_INCLUDES}
- file_body.hpp
- mime_type.hpp
- http_async_server.hpp
- http_sync_server.hpp
- http_server.cpp
-)
-
-if (NOT WIN32)
- target_link_libraries(http-server ${Boost_LIBRARIES} Threads::Threads)
-else()
- target_link_libraries(http-server ${Boost_LIBRARIES})
-endif()
-
-
-add_executable (http-example
- ${BEAST_INCLUDES}
- ${EXTRAS_INCLUDES}
- http_example.cpp
-)
-
-if (NOT WIN32)
- target_link_libraries(http-example ${Boost_LIBRARIES} Threads::Threads)
-else()
- target_link_libraries(http-example ${Boost_LIBRARIES})
-endif()
-
-
-add_executable (websocket-echo
- ${BEAST_INCLUDES}
- websocket_async_echo_server.hpp
- websocket_sync_echo_server.hpp
- websocket_echo.cpp
-)
-
-if (NOT WIN32)
- target_link_libraries(websocket-echo ${Boost_LIBRARIES} Threads::Threads)
-else()
- target_link_libraries(websocket-echo ${Boost_LIBRARIES})
-endif()
-
-
-add_executable (websocket-example
- ${BEAST_INCLUDES}
- ${EXTRAS_INCLUDES}
- websocket_example.cpp
-)
-
-if (NOT WIN32)
- target_link_libraries(websocket-example ${Boost_LIBRARIES} Threads::Threads)
-else()
- target_link_libraries(websocket-example ${Boost_LIBRARIES})
-endif()
diff --git a/examples/doc_websocket_samples.hpp b/examples/doc_websocket_samples.hpp
deleted file mode 100644
index 7977fedb..00000000
--- a/examples/doc_websocket_samples.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#include
-
-// Contains the WebSocket Examples from the documentation.
-
-
-// The documentation assumes the beast::websocket namespace
-
-namespace beast {
-namespace websocket {
-
-} // websocket
-} // beast
diff --git a/test/Jamfile b/test/Jamfile
index e149a636..5fac3da3 100644
--- a/test/Jamfile
+++ b/test/Jamfile
@@ -25,7 +25,7 @@ unit-test core-tests :
core/buffers_adapter.cpp
core/clamp.cpp
core/consuming_buffers.cpp
- core/doc_core_samples.cpp
+ core/doc_examples.cpp
core/doc_snippets.cpp
core/drain_buffer.cpp
core/error.cpp
@@ -49,7 +49,7 @@ unit-test http-tests :
../extras/beast/unit_test/main.cpp
http/basic_parser.cpp
http/buffer_body.cpp
- http/doc_http_samples.cpp
+ http/doc_examples.cpp
http/doc_snippets.cpp
http/dynamic_body.cpp
http/error.cpp
diff --git a/test/core/CMakeLists.txt b/test/core/CMakeLists.txt
index f40db665..7a39b036 100644
--- a/test/core/CMakeLists.txt
+++ b/test/core/CMakeLists.txt
@@ -7,7 +7,7 @@ GroupSources(test/core "/")
add_executable (core-tests
${BEAST_INCLUDES}
- ${EXAMPLES_INCLUDES}
+ ${EXAMPLE_INCLUDES}
${EXTRAS_INCLUDES}
../../extras/beast/unit_test/main.cpp
async_result.cpp
@@ -20,7 +20,7 @@ add_executable (core-tests
buffers_adapter.cpp
clamp.cpp
consuming_buffers.cpp
- doc_core_samples.cpp
+ doc_examples.cpp
doc_snippets.cpp
drain_buffer.cpp
error.cpp
diff --git a/test/core/doc_core_samples.cpp b/test/core/doc_examples.cpp
similarity index 98%
rename from test/core/doc_core_samples.cpp
rename to test/core/doc_examples.cpp
index e669e68a..df2f1ddb 100644
--- a/test/core/doc_core_samples.cpp
+++ b/test/core/doc_examples.cpp
@@ -5,7 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#include
+#include "example/doc/core_examples.hpp"
#include
#include
diff --git a/test/http/CMakeLists.txt b/test/http/CMakeLists.txt
index 1d306a55..39bb65dd 100644
--- a/test/http/CMakeLists.txt
+++ b/test/http/CMakeLists.txt
@@ -1,20 +1,21 @@
# Part of Beast
-GroupSources(examples examples)
+GroupSources(example example)
GroupSources(extras/beast extras)
GroupSources(include/beast beast)
+
GroupSources(test/http "/")
add_executable (http-tests
${BEAST_INCLUDES}
- ${EXAMPLES_INCLUDES}
+ ${EXAMPLE_INCLUDES}
${EXTRAS_INCLUDES}
message_fuzz.hpp
test_parser.hpp
../../extras/beast/unit_test/main.cpp
basic_parser.cpp
buffer_body.cpp
- doc_http_samples.cpp
+ doc_examples.cpp
doc_snippets.cpp
dynamic_body.cpp
empty_body.cpp
diff --git a/test/http/doc_http_samples.cpp b/test/http/doc_examples.cpp
similarity index 99%
rename from test/http/doc_http_samples.cpp
rename to test/http/doc_examples.cpp
index 83c33467..d1900e8f 100644
--- a/test/http/doc_http_samples.cpp
+++ b/test/http/doc_examples.cpp
@@ -5,8 +5,8 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
-#include
-#include
+#include "example/doc/http_examples.hpp"
+#include "example/http-server/file_body.hpp"
#include
#include