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

Update HTTP Server documentation.#433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update HTTP Server documentation.
Fixes#387
  • Loading branch information
@deanberris
deanberris committedSep 1, 2014
commite5d08d2331ab7ec7d9237406dce92f54ff65b617
48 changes: 20 additions & 28 deletionslibs/network/doc/reference/http_server.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -156,10 +156,8 @@ And that the following typedef's have been put in place:
typedef boost::network::http::server<handler_type> http_server;

struct handler_type {
void operator()(
http_server::request const & request,
http_server::response & response
) {
void operator()(http_server::request const & request,
http_server::response & response) {
// do something here
}
};
Expand DownExpand Up@@ -227,13 +225,12 @@ To use the above supported named parameters, you'll have code that looks like th

using namespace boost::network::http; // parameters are in this namespace
handler handler_instance;
async_server<handler>::options options(handler_instance);
sync_server<handler>::options options(handler_instance);
options.address("0.0.0.0")
.port("80")
.io_service(boost::make_shared<boost::asio::io_service>())
.thread_pool(boost::make_shared<boost::network::utils::thread_pool>(2))
.reuse_address(true);
async_server<handler> instance(options);
sync_server<handler> instance(options);
instance.run();

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

struct handler_type {
void operator()(
http_server::request const & request,
http_server::connection_ptr connection
) {
void operator()(http_server::request const & request,
http_server::connection_ptr connection) {
// do something here
}
};
Expand DownExpand Up@@ -537,31 +532,28 @@ used are defined in the link.

.. code-block:: c++

// Initialize SSL context
boost::shared_ptr<boost::asio::ssl::context> ctx = boost::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::sslv23);
ctx->set_options(
// Initialize SSL context
boost::shared_ptr<boost::asio::ssl::context> ctx = boost::make_shared<boost::asio::ssl::context>(boost::asio::ssl::context::sslv23);
ctx->set_options(
boost::asio::ssl::context::default_workarounds
| boost::asio::ssl::context::no_sslv2
| boost::asio::ssl::context::single_dh_use);
// Set keys
ctx->set_password_callback(password_callback);
ctx->use_certificate_chain_file("server.pem");
ctx->use_private_key_file("server.pem", boost::asio::ssl::context::pem);
ctx->use_tmp_dh_file("dh512.pem");
// Set keys
ctx->set_password_callback(password_callback);
ctx->use_certificate_chain_file("server.pem");
ctx->use_private_key_file("server.pem", boost::asio::ssl::context::pem);
ctx->use_tmp_dh_file("dh512.pem");
handler_type handler;
http_server::options options(handler);
options.thread_pool(boost::make_shared<boost::network::utils::thread_pool>(2));
http_server server(options.address("127.0.0.1").port("8442").context(ctx));


.. code-block:: c++

std::string password_callback(std::size_t max_length, boost::asio::ssl::context_base::password_purpose purpose) {
return std::string("test");
}

std::string password_callback(std::size_t max_length, boost::asio::ssl::context_base::password_purpose purpose) {
return std::string("test");
}

.. _Boost.Range: http://www.boost.org/libs/range
.. _Boost.Function: http://www.boost.org/libs/function
.. _Boost.Asio.SSL.Context: http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/reference/ssl__context.html

[8]ページ先頭

©2009-2025 Movatter.jp