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

Commit6ba8f9a

Browse files
committed
Implementation of options for client and server.
1 parentd5a4f80 commit6ba8f9a

File tree

2 files changed

+209
-0
lines changed

2 files changed

+209
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP_20130128
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP_20130128
3+
4+
// Copyright 2013 Google, Inc.
5+
// Copyright 2013 Dean Michael Berris <dberris@google.com>
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
namespaceboost {namespacenetwork {namespacehttp {
11+
12+
template<classTag>
13+
structclient_options {
14+
typedeftypename string<Tag>::type string_type;
15+
16+
client_options()
17+
: cache_resolved_(false)
18+
, follow_redirects_(false)
19+
, openssl_certificate_()
20+
, openssl_verify_path_()
21+
, io_service_()
22+
{}
23+
24+
client_options(client_optionsconst &other)
25+
: cache_resolved_(other.cache_resolved_)
26+
, follow_redirects_(other.follow_redirects_)
27+
, openssl_certificate_(other.openssl_certificate_)
28+
, openssl_verify_path_(other.openssl_verify_path_)
29+
, io_service_(other.io_service_)
30+
{}
31+
32+
client_options&operator=(client_options other) {
33+
other.swap(*this);
34+
return *this;
35+
}
36+
37+
voidswap(client_options& other) {
38+
using std::swap;
39+
swap(cache_resolved_, other.cache_resolved_);
40+
swap(follow_redirects_, other.follow_redirects_);
41+
swap(openssl_certificate_, other.openssl_certificate_);
42+
swap(openssl_verify_path, other.openssl_verify_path_);
43+
swap(io_service_, other.io_service_);
44+
}
45+
46+
client_options&cache_resolved(bool v) { cache_resolved_ = v;return *this; };
47+
client_options&follow_redirects(bool v) { follow_redirects_ = v;return *this; };
48+
client_options&openssl_certificate(string_typeconst & v) { openssl_certificate_ = v;return *this; }
49+
client_options&openssl_verify_path(string_typeconst & v) { openssl_verify_path_ = v;return *this; }
50+
client_options&io_service(boost::shared_ptr<boost::asio::io_service> v) { io_service_ = v;return *this; }
51+
52+
boolcache_resolved()const {return cache_resolved_; }
53+
boolfollow_redirects()const {return follow_redirects_; }
54+
boost::optional<string_type>openssl_certificate()const {return openssl_certificate_; }
55+
boost::optional<string_type>openssl_verify_path()const {return openssl_verify_path_; }
56+
boost::shared_ptr<boost::asio::io_service>io_service()const {return io_service_; }
57+
58+
private:
59+
bool cache_resolved_;
60+
bool follow_redirects_;
61+
boost::optional<string_type> openssl_certificate_;
62+
boost::optional<string_type> openssl_verify_path_;
63+
boost::shared_ptr<boost::asio::io_service> io_service_;
64+
};
65+
66+
template<classTag>
67+
inlinevoidswap(client_options<Tag>& a, client_options<Tag>& b) {
68+
a.swap(b);
69+
}
70+
71+
}/* http*/
72+
}/* network*/
73+
}/* boost*/
74+
75+
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_CLIENT_OPTIONS_HPP_20130128*/
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_20130128
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_20130128
3+
4+
// Copyright 2013 Google, Inc.
5+
// Copyright 2013 Dean Michael Berris <dberris@google.com>
6+
// Distributed under the Boost Software License, Version 1.0.
7+
// (See accompanying file LICENSE_1_0.txt or copy at
8+
// http://www.boost.org/LICENSE_1_0.txt)
9+
10+
#include<boost/asio/io_service.hpp>
11+
#include<boost/asio/socket_base.hpp>
12+
#include<boost/network/traits/string.hpp>
13+
#include<boost/network/utils/thread_pool.hpp>
14+
#include<boost/optional.hpp>
15+
#include<boost/shared_ptr.hpp>
16+
17+
namespaceboost {namespacenetwork {namespacehttp {
18+
19+
template<classTag,classHandler>
20+
structserver_options {
21+
typedeftypename string<Tag>::type string_type;
22+
23+
explicitserver_options(Handler& handler)
24+
: io_service_()
25+
, handler_(handler)
26+
, address_("localhost")
27+
, port_("80")
28+
, reuse_address_(false)
29+
, report_aborted_(false)
30+
, non_blocking_io_(true)
31+
, linger_(true)
32+
, linger_timeout_(0)
33+
, receive_buffer_size_()
34+
, send_buffer_size_()
35+
, receive_low_watermark_()
36+
, send_low_watermark_()
37+
, thread_pool_()
38+
{}
39+
40+
server_options(const server_options &other)
41+
: io_service_(other.io_service())
42+
, handler_(other.handler_)
43+
, address_(other.address_)
44+
, port_(other.port_)
45+
, reuse_address_(other.reuse_address_)
46+
, report_aborted_(other.report_aborted_)
47+
, non_blocking_io_(other.non_blocking_io_)
48+
, linger_(other.linger_)
49+
, linger_timeout_(0)
50+
, receive_buffer_size_(other.receive_buffer_size_)
51+
, send_buffer_size_(other.send_buffer_size_)
52+
, receive_low_watermark_(other.receive_low_watermark_)
53+
, send_low_watermark_(other.send_low_watermark_)
54+
, thread_pool_(other.thread_pool_)
55+
{}
56+
57+
server_options &operator= (server_options other) {
58+
other.swap(*this);
59+
return *this;
60+
}
61+
62+
voidswap(server_options &other) {
63+
using std::swap;
64+
swap(io_service_, other.io_service_);
65+
swap(address_, other.address_);
66+
swap(port_, other.port_);
67+
swap(reuse_address_, other.reuse_address_);
68+
swap(report_aborted_, other.report_aborted_);
69+
swap(non_blocking_io_, other.non_blocking_io_);
70+
swap(linger_, other.linger_);
71+
swap(linger_timeout_, other.linger_timeout_);
72+
swap(receive_buffer_size_, other.receive_buffer_size_);
73+
swap(send_buffer_size_, other.send_buffer_size_);
74+
swap(receive_low_watermark_, other.receive_low_watermark_);
75+
swap(send_low_watermark_, other.send_low_watermark_);
76+
swap(thread_pool_, other.thread_pool_);
77+
}
78+
79+
server_options &io_service(boost::shared_ptr<boost::asio::io_service> v) { io_service_ = v;return *this; }
80+
server_options &address(string_typeconst &v) { address_ = v;return *this; }
81+
server_options &port(string_typeconst &v) { port_ = v;return *this; }
82+
server_options &reuse_address(bool v) { reuse_address_ = v;return *this; }
83+
server_options &report_aborted(bool v) { report_aborted_ = v;return *this; }
84+
server_options &non_blocking_io(bool v) { non_blocking_io_ = v;return *this; }
85+
server_options &linger(bool v) { linger_ = v;return *this; }
86+
server_options &linger_timeout(size_t v) { linger_timeout_ = v;return *this; }
87+
server_options &receive_buffer_size(boost::asio::socket_base::receive_buffer_size v) { receive_buffer_size_ = v;return *this; }
88+
server_options &send_buffer_size(boost::asio::socket_base::send_buffer_size v) { send_buffer_size_ = v;return *this; }
89+
server_options &receive_low_watermark(boost::asio::socket_base::receive_low_watermark v) { receive_low_watermark_ = v;return *this; }
90+
server_options &send_low_watermark(boost::asio::socket_base::send_low_watermark v) { send_low_watermark_ = v;return *this; }
91+
server_options &thread_pool(boost::shared_ptr<utils::thread_pool> v) { thread_pool_ = v;return *this; }
92+
93+
boost::shared_ptr<boost::asio::io_service>io_service()const {return io_service_; }
94+
string_typeaddress()const {return address_; }
95+
string_typeport()const {return port_; }
96+
Handler &handler()const {return handler_; }
97+
boolreuse_address()const {return reuse_address_; }
98+
boolreport_aborted()const {return report_aborted_; }
99+
boolnon_blocking_io()const {return non_blocking_io_; }
100+
boollinger()const {return linger_; }
101+
size_tlinger_timeout()const {return linger_timeout_; }
102+
boost::optional<boost::asio::socket_base::receive_buffer_size>receive_buffer_size()const {return receive_buffer_size_; }
103+
boost::optional<boost::asio::socket_base::send_buffer_size>send_buffer_size()const {return send_buffer_size_; }
104+
boost::optional<boost::asio::socket_base::receive_low_watermark>receive_low_watermark()const {return receive_low_watermark_; }
105+
boost::optional<boost::asio::socket_base::send_low_watermark>send_low_watermark()const {return send_low_watermark_; }
106+
boost::shared_ptr<utils::thread_pool>thread_pool()const {return thread_pool_; }
107+
108+
private:
109+
boost::shared_ptr<boost::asio::io_service> io_service_;
110+
string_type address_;
111+
string_type port_;
112+
Handler &handler_;
113+
bool reuse_address_;
114+
bool report_aborted_;
115+
bool non_blocking_io_;
116+
bool linger_;
117+
size_t linger_timeout_;
118+
boost::optional<boost::asio::socket_base::receive_buffer_size> receive_buffer_size_;
119+
boost::optional<boost::asio::socket_base::send_buffer_size> send_buffer_size_;
120+
boost::optional<boost::asio::socket_base::receive_low_watermark> receive_low_watermark_;
121+
boost::optional<boost::asio::socket_base::send_low_watermark> send_low_watermark_;
122+
boost::shared_ptr<utils::thread_pool> thread_pool_;
123+
};
124+
125+
template<classTag,classHandler>
126+
inlinevoidswap(server_options<Tag, Handler> &a, server_options<Tag, Handler> &b) {
127+
a.swap(b);
128+
}
129+
130+
}/* http*/
131+
}/* network*/
132+
}/* boost*/
133+
134+
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_SERVER_OPTIONS_20130128*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp