Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite5d08d2

Browse files
committed
Update HTTP Server documentation.
Fixes#387
1 parentbd0cf0b commite5d08d2

File tree

1 file changed

+20
-28
lines changed

1 file changed

+20
-28
lines changed

‎libs/network/doc/reference/http_server.rst‎

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,8 @@ And that the following typedef's have been put in place:
156156
typedef boost::network::http::server<handler_type> http_server;
157157

158158
struct handler_type {
159-
void operator()(
160-
http_server::request const & request,
161-
http_server::response & response
162-
) {
159+
void operator()(http_server::request const & request,
160+
http_server::response & response) {
163161
// do something here
164162
}
165163
};
@@ -227,13 +225,12 @@ To use the above supported named parameters, you'll have code that looks like th
227225

228226
using namespace boost::network::http; // parameters are in this namespace
229227
handler handler_instance;
230-
async_server<handler>::options options(handler_instance);
228+
sync_server<handler>::options options(handler_instance);
231229
options.address("0.0.0.0")
232230
.port("80")
233231
.io_service(boost::make_shared<boost::asio::io_service>())
234-
.thread_pool(boost::make_shared<boost::network::utils::thread_pool>(2))
235232
.reuse_address(true);
236-
async_server<handler> instance(options);
233+
sync_server<handler> instance(options);
237234
instance.run();
238235

239236
Public Members
@@ -391,10 +388,8 @@ And that the following typedef's have been put in place:
391388
typedef boost::network::http::server<handler_type> http_server;
392389

393390
struct handler_type {
394-
void operator()(
395-
http_server::request const & request,
396-
http_server::connection_ptr connection
397-
) {
391+
void operator()(http_server::request const & request,
392+
http_server::connection_ptr connection) {
398393
// do something here
399394
}
400395
};
@@ -537,31 +532,28 @@ used are defined in the link.
537532

538533
..code-block::c++
539534

540-
// Initialize SSL context
541-
boost::shared_ptr<boost::asio::ssl::context> ctx = boost::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::sslv23);
542-
ctx->set_options(
535+
// Initialize SSL context
536+
boost::shared_ptr<boost::asio::ssl::context> ctx = boost::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::sslv23);
537+
ctx->set_options(
543538
boost::asio::ssl::context::default_workarounds
544539
|boost::asio::ssl::context::no_sslv2
545540
|boost::asio::ssl::context::single_dh_use);
546-
547-
// Set keys
548-
ctx->set_password_callback(password_callback);
549-
ctx->use_certificate_chain_file("server.pem");
550-
ctx->use_private_key_file("server.pem", boost::asio::ssl::context::pem);
551-
ctx->use_tmp_dh_file("dh512.pem");
552-
541+
542+
// Set keys
543+
ctx->set_password_callback(password_callback);
544+
ctx->use_certificate_chain_file("server.pem");
545+
ctx->use_private_key_file("server.pem", boost::asio::ssl::context::pem);
546+
ctx->use_tmp_dh_file("dh512.pem");
547+
553548
handler_type handler;
554549
http_server::options options(handler);
555550
options.thread_pool(boost::make_shared<boost::network::utils::thread_pool>(2));
556551
http_server server(options.address("127.0.0.1").port("8442").context(ctx));
557552

558-
559-
..code-block::c++
560-
561-
std::string password_callback(std::size_t max_length, boost::asio::ssl::context_base::password_purpose purpose) {
562-
return std::string("test");
563-
}
564-
553+
std::string password_callback(std::size_t max_length, boost::asio::ssl::context_base::password_purpose purpose) {
554+
return std::string("test");
555+
}
556+
565557
.. _Boost.Range:http://www.boost.org/libs/range
566558
.. _Boost.Function:http://www.boost.org/libs/function
567559
.. _Boost.Asio.SSL.Context:http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/reference/ssl__context.html

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp