Files
boost_beast/doc/qbk/02_examples.qbk

197 lines
4.7 KiB
Plaintext
Raw Normal View History

2016-09-25 11:19:51 -04:00
[/
2017-07-28 19:32:33 -07:00
Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
2016-09-25 11:19:51 -04:00
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
2017-07-28 19:32:33 -07:00
Official repository: https://github.com/boostorg/beast
2016-09-25 11:19:51 -04:00
]
Refactor chunked-encoding serialization: New buffer sequence classes are provided to allow full control over the serialization of chunk-encoded message payloads: * chunk_header A ConstBufferSequence representing the chunk header. It includes a hexadecimal-encoded size, an optional set of chunk extensions, and the trailing CRLF required to denote the end of the chunk header. This allows the caller to manually serialize the chunk body in one or more calls to a stream output function. The caller must also output an object of type `chunk_crlf` to the stream to indicate the end of the chunk body. * chunk_crlf A small ConstBufferSequence that simply represents the two character sequence "\r\n" (CRLF). This is needed for the case where the caller wants to output a chunk body as a series of buffers (i.e. "chunking a chunk"). * chunk_body A ConstBufferSequence representing a complete chunk. This includes the size, an optional set of chunk extensions, a caller provided buffer containing the body, and the required CRLF that follows. * chunk_final A ConstBufferSequence representing a final chunk. It includes an optional set of caller-provided field trailers * chunk_extensions A container for building a set of chunk extensions to use during serialization. The use of the container is optional, callers may provide their own buffer containing a correctly formatted set of chunk extensions, or they may use their own convenience container which meets the requirements. The basic_fields container is modified to allow construction outside the context of a message. The container can be used to provide trailers to `chunk_final`. Actions Required: * Remove references to ChunkDecorators. Use the new chunk-encoding buffer sequences to manually produce a chunked payload body in the case where control over the chunk-extensions and/or trailers is required.
2017-07-09 20:09:30 -07:00
[section Quick Start]
[block'''<?dbhtml stop-chunking?>''']
2016-09-25 11:19:51 -04:00
2017-06-19 20:03:05 -07:00
These complete programs are intended to quickly impress upon readers
the flavor of the library. Source code and build scripts for them are
located in the example/ directory.
Refactor chunked-encoding serialization: New buffer sequence classes are provided to allow full control over the serialization of chunk-encoded message payloads: * chunk_header A ConstBufferSequence representing the chunk header. It includes a hexadecimal-encoded size, an optional set of chunk extensions, and the trailing CRLF required to denote the end of the chunk header. This allows the caller to manually serialize the chunk body in one or more calls to a stream output function. The caller must also output an object of type `chunk_crlf` to the stream to indicate the end of the chunk body. * chunk_crlf A small ConstBufferSequence that simply represents the two character sequence "\r\n" (CRLF). This is needed for the case where the caller wants to output a chunk body as a series of buffers (i.e. "chunking a chunk"). * chunk_body A ConstBufferSequence representing a complete chunk. This includes the size, an optional set of chunk extensions, a caller provided buffer containing the body, and the required CRLF that follows. * chunk_final A ConstBufferSequence representing a final chunk. It includes an optional set of caller-provided field trailers * chunk_extensions A container for building a set of chunk extensions to use during serialization. The use of the container is optional, callers may provide their own buffer containing a correctly formatted set of chunk extensions, or they may use their own convenience container which meets the requirements. The basic_fields container is modified to allow construction outside the context of a message. The container can be used to provide trailers to `chunk_final`. Actions Required: * Remove references to ChunkDecorators. Use the new chunk-encoding buffer sequences to manually produce a chunked payload body in the case where control over the chunk-extensions and/or trailers is required.
2017-07-09 20:09:30 -07:00
[section HTTP Client]
2016-09-25 11:19:51 -04:00
2017-06-04 17:25:55 -07:00
Use HTTP to make a GET request to a website and print the response:
File: [repo_file example/http-client/http_client.cpp]
[example_http_client]
[endsect]
2017-06-04 17:25:55 -07:00
2017-06-16 19:27:00 -07:00
[section WebSocket Client]
2017-06-04 17:25:55 -07:00
2017-06-16 19:27:00 -07:00
Establish a WebSocket connection, send a message and receive the reply:
2016-09-25 11:19:51 -04:00
2017-06-16 19:27:00 -07:00
File: [repo_file example/websocket-client/websocket_client.cpp]
2017-06-04 17:25:55 -07:00
2017-06-16 19:27:00 -07:00
[example_websocket_client]
2017-06-16 19:27:00 -07:00
[endsect]
[endsect]
2017-06-04 17:25:55 -07:00
2016-09-25 11:19:51 -04:00
Refactor chunked-encoding serialization: New buffer sequence classes are provided to allow full control over the serialization of chunk-encoded message payloads: * chunk_header A ConstBufferSequence representing the chunk header. It includes a hexadecimal-encoded size, an optional set of chunk extensions, and the trailing CRLF required to denote the end of the chunk header. This allows the caller to manually serialize the chunk body in one or more calls to a stream output function. The caller must also output an object of type `chunk_crlf` to the stream to indicate the end of the chunk body. * chunk_crlf A small ConstBufferSequence that simply represents the two character sequence "\r\n" (CRLF). This is needed for the case where the caller wants to output a chunk body as a series of buffers (i.e. "chunking a chunk"). * chunk_body A ConstBufferSequence representing a complete chunk. This includes the size, an optional set of chunk extensions, a caller provided buffer containing the body, and the required CRLF that follows. * chunk_final A ConstBufferSequence representing a final chunk. It includes an optional set of caller-provided field trailers * chunk_extensions A container for building a set of chunk extensions to use during serialization. The use of the container is optional, callers may provide their own buffer containing a correctly formatted set of chunk extensions, or they may use their own convenience container which meets the requirements. The basic_fields container is modified to allow construction outside the context of a message. The container can be used to provide trailers to `chunk_final`. Actions Required: * Remove references to ChunkDecorators. Use the new chunk-encoding buffer sequences to manually produce a chunked payload body in the case where control over the chunk-extensions and/or trailers is required.
2017-07-09 20:09:30 -07:00
[section Examples]
2017-06-16 19:27:00 -07:00
[block'''<?dbhtml stop-chunking?>''']
2017-06-19 20:03:05 -07:00
Source code and build scripts for these programs are located
in the example/ directory.
2017-06-16 19:27:00 -07:00
[section HTTP Crawl]
This example retrieves the page at each of the most popular domains
as measured by Alexa.
* [repo_file example/http-crawl/http_crawl.cpp]
[endsect]
2016-10-02 16:42:50 -04:00
2017-06-16 19:27:00 -07:00
[section HTTP Client (with SSL)]
2017-06-16 19:27:00 -07:00
This example demonstrates sending and receiving HTTP messages
over a TLS connection. Requires OpenSSL to build.
2016-10-02 16:42:50 -04:00
2017-06-18 17:10:38 -07:00
* [repo_file example/http-client-ssl/http_client_ssl.cpp]
2016-10-02 16:33:42 -04:00
[endsect]
2016-10-02 16:33:42 -04:00
2017-06-23 18:23:55 -07:00
[section HTTP Server (Fast)]
2017-06-23 01:44:25 -07:00
This example implements a very simple HTTP server with
some optimizations suitable for calculating benchmarks.
2017-06-24 12:45:38 -07:00
* [repo_file example/http-server-fast/fields_alloc.hpp]
2017-06-25 12:03:45 -07:00
* [repo_file example/http-server-fast/http_server_fast.cpp]
2017-06-23 01:44:25 -07:00
[endsect]
2017-06-23 18:23:55 -07:00
[section HTTP Server (Small)]
This example implements a very simple HTTP server
suitable as a starting point on an embedded device.
* [repo_file example/http-server-small/http_server_small.cpp]
[endsect]
2017-07-02 11:24:10 -07:00
[section HTTP Server (Threaded)]
This example implements a very simple HTTP server using
synchronous interfaces and using one thread per connection:
* [repo_file example/http-server-threaded/http_server_threaded.cpp]
[endsect]
[section WebSocket Client (with SSL)]
2016-10-02 16:33:42 -04:00
Establish a WebSocket connection over an encrypted TLS connection,
send a message and receive the reply. Requires OpenSSL to build.
2016-09-25 11:19:51 -04:00
2017-06-18 17:10:38 -07:00
* [repo_file example/websocket-client-ssl/websocket_client_ssl.cpp]
2016-09-25 11:19:51 -04:00
[endsect]
2016-09-25 11:19:51 -04:00
2017-07-02 18:22:36 -07:00
[section WebSocket Server (Asynchronous)]
This program implements a WebSocket echo server using asynchronous
interfaces and a configurable number of threads.
* [repo_file example/websocket-server-async/websocket_server_async.cpp]
[endsect]
2017-06-16 19:27:00 -07:00
[section Documentation Samples]
2016-09-25 11:19:51 -04:00
2017-06-16 19:27:00 -07:00
Here are all of the example functions and classes presented
throughout the documentation, they can be included and used
in your program without modification
2016-09-25 11:19:51 -04:00
2017-06-16 19:27:00 -07:00
* [repo_file example/doc/http_examples.hpp]
[endsect]
2016-09-25 11:19:51 -04:00
[section Composed Operations]
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 example/echo-op/echo_op.cpp]
[endsect]
2017-06-11 09:59:13 -07:00
2017-06-24 22:24:39 -07:00
[section Common Code]
This code is reused between some of the examples. The header files
stand alone can be directly included in your projects.
* [repo_file example/common/detect_ssl.hpp]
2017-07-02 18:22:36 -07:00
* [repo_file example/common/helpers.hpp]
2017-06-24 22:24:39 -07:00
* [repo_file example/common/mime_types.hpp]
* [repo_file example/common/rfc7231.hpp]
* [repo_file example/common/ssl_stream.hpp]
* [repo_file example/common/write_msg.hpp]
[endsect]
2017-06-16 19:27:00 -07:00
[section Server Framework]
2016-09-25 11:19:51 -04:00
2017-06-16 19:27:00 -07:00
This is a complete program and framework of classes implementing
a general purpose server that users may copy to use as the basis
for writing their own servers. It serves both HTTP and WebSocket.
2017-06-16 19:27:00 -07:00
* [repo_file example/server-framework/file_service.hpp]
* [repo_file example/server-framework/framework.hpp]
* [repo_file example/server-framework/http_async_port.hpp]
* [repo_file example/server-framework/http_base.hpp]
* [repo_file example/server-framework/http_sync_port.hpp]
* [repo_file example/server-framework/https_ports.hpp]
2017-06-16 19:27:00 -07:00
* [repo_file example/server-framework/main.cpp]
2017-06-18 06:51:51 -07:00
* [repo_file example/server-framework/multi_port.hpp]
2017-06-16 19:27:00 -07:00
* [repo_file example/server-framework/server.hpp]
* [repo_file example/server-framework/service_list.hpp]
* [repo_file example/server-framework/ssl_certificate.hpp]
2017-06-16 19:27:00 -07:00
* [repo_file example/server-framework/ws_async_port.hpp]
* [repo_file example/server-framework/ws_sync_port.hpp]
* [repo_file example/server-framework/ws_upgrade_service.hpp]
* [repo_file example/server-framework/wss_ports.hpp]
[endsect]
2016-09-25 11:19:51 -04:00
[endsect]