5
5
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6
6
//
7
7
8
- #ifndef BOOST_NETWORK_HTTP_CONNECTION_HPP_
9
- #define BOOST_NETWORK_HTTP_CONNECTION_HPP_
8
+ #ifndef BOOST_NETWORK_HTTP_SERVER_SYNC_CONNECTION_HPP_
9
+ #define BOOST_NETWORK_HTTP_SERVER_SYNC_CONNECTION_HPP_
10
10
11
- #ifndef BOOST_HTTP_SERVER_BUFFER_SIZE
12
- #define BOOST_HTTP_SERVER_BUFFER_SIZE 1024
11
+ #ifndef BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE
12
+ #define BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE 1024
13
13
#endif
14
14
15
15
#include < boost/enable_shared_from_this.hpp>
31
31
namespace boost { namespace network { namespace http {
32
32
33
33
template <class Tag , class Handler >
34
- struct connection : boost::enable_shared_from_this<connection <Tag,Handler> > {
34
+ struct sync_connection : boost::enable_shared_from_this<sync_connection <Tag,Handler> > {
35
35
36
- connection (boost::asio::io_service & service, Handler & handler)
36
+ sync_connection (boost::asio::io_service & service, Handler & handler)
37
37
: service_(service)
38
38
, handler_(handler)
39
39
, socket_(service_)
@@ -59,8 +59,8 @@ namespace boost { namespace network { namespace http {
59
59
boost::asio::buffer (buffer_),
60
60
wrapper_.wrap (
61
61
boost::bind (
62
- &connection <Tag,Handler>::handle_read_headers,
63
- connection <Tag,Handler>::shared_from_this (),
62
+ &sync_connection <Tag,Handler>::handle_read_headers,
63
+ sync_connection <Tag,Handler>::shared_from_this (),
64
64
boost::asio::placeholders::error,
65
65
boost::asio::placeholders::bytes_transferred
66
66
)
@@ -81,7 +81,7 @@ namespace boost { namespace network { namespace http {
81
81
if (!ec) {
82
82
request_.source = socket_.remote_endpoint ().address ().to_string ();
83
83
boost::tribool done;
84
- boost::array< char , BOOST_HTTP_SERVER_BUFFER_SIZE> ::iterator new_start;
84
+ buffer_type ::iterator new_start;
85
85
tie (done,new_start) = parser_.parse_headers (request_, buffer_.data (), buffer_.data () + bytes_transferred);
86
86
if (done) {
87
87
if (request_.method [0 ] == ' P' ) {
@@ -99,8 +99,8 @@ namespace boost { namespace network { namespace http {
99
99
response_.to_buffers (),
100
100
wrapper_.wrap (
101
101
boost::bind (
102
- &connection <Tag,Handler>::handle_write,
103
- connection <Tag,Handler>::shared_from_this (),
102
+ &sync_connection <Tag,Handler>::handle_write,
103
+ sync_connection <Tag,Handler>::shared_from_this (),
104
104
boost::asio::placeholders::error
105
105
)
106
106
)
@@ -119,8 +119,8 @@ namespace boost { namespace network { namespace http {
119
119
response_.to_buffers (),
120
120
wrapper_.wrap (
121
121
boost::bind (
122
- &connection <Tag,Handler>::handle_write,
123
- connection <Tag,Handler>::shared_from_this (),
122
+ &sync_connection <Tag,Handler>::handle_write,
123
+ sync_connection <Tag,Handler>::shared_from_this (),
124
124
boost::asio::placeholders::error
125
125
)
126
126
)
@@ -138,8 +138,8 @@ namespace boost { namespace network { namespace http {
138
138
boost::asio::buffer (buffer_),
139
139
wrapper_.wrap (
140
140
boost::bind (
141
- &connection <Tag,Handler>::handle_read_body_contents,
142
- connection <Tag,Handler>::shared_from_this (),
141
+ &sync_connection <Tag,Handler>::handle_read_body_contents,
142
+ sync_connection <Tag,Handler>::shared_from_this (),
143
143
boost::asio::placeholders::error,
144
144
content_length,
145
145
boost::asio::placeholders::bytes_transferred
@@ -156,8 +156,8 @@ namespace boost { namespace network { namespace http {
156
156
response_.to_buffers (),
157
157
wrapper_.wrap (
158
158
boost::bind (
159
- &connection <Tag,Handler>::handle_write,
160
- connection <Tag,Handler>::shared_from_this (),
159
+ &sync_connection <Tag,Handler>::handle_write,
160
+ sync_connection <Tag,Handler>::shared_from_this (),
161
161
boost::asio::placeholders::error
162
162
)
163
163
)
@@ -169,8 +169,8 @@ namespace boost { namespace network { namespace http {
169
169
response_.to_buffers (),
170
170
wrapper_.wrap (
171
171
boost::bind (
172
- &connection <Tag,Handler>::handle_write,
173
- connection <Tag,Handler>::shared_from_this (),
172
+ &sync_connection <Tag,Handler>::handle_write,
173
+ sync_connection <Tag,Handler>::shared_from_this (),
174
174
boost::asio::placeholders::error
175
175
)
176
176
)
@@ -183,8 +183,8 @@ namespace boost { namespace network { namespace http {
183
183
response_.to_buffers (),
184
184
wrapper_.wrap (
185
185
boost::bind (
186
- &connection <Tag,Handler>::handle_write,
187
- connection <Tag,Handler>::shared_from_this (),
186
+ &sync_connection <Tag,Handler>::handle_write,
187
+ sync_connection <Tag,Handler>::shared_from_this (),
188
188
boost::asio::placeholders::error
189
189
)
190
190
)
@@ -194,8 +194,8 @@ namespace boost { namespace network { namespace http {
194
194
boost::asio::buffer (buffer_),
195
195
wrapper_.wrap (
196
196
boost::bind (
197
- &connection <Tag,Handler>::handle_read_headers,
198
- connection <Tag,Handler>::shared_from_this (),
197
+ &sync_connection <Tag,Handler>::handle_read_headers,
198
+ sync_connection <Tag,Handler>::shared_from_this (),
199
199
boost::asio::placeholders::error,
200
200
boost::asio::placeholders::bytes_transferred
201
201
)
@@ -209,7 +209,7 @@ namespace boost { namespace network { namespace http {
209
209
void handle_read_body_contents (boost::system::error_code const & ec, size_t bytes_to_read, size_t bytes_transferred) {
210
210
if (!ec) {
211
211
size_t difference = bytes_to_read - bytes_transferred;
212
- boost::array< char ,BOOST_HTTP_SERVER_BUFFER_SIZE> ::iterator start = buffer_.begin (),
212
+ buffer_type ::iterator start = buffer_.begin (),
213
213
past_end = start;
214
214
std::advance (past_end, (std::min)(bytes_to_read,bytes_transferred));
215
215
request_.body .append (buffer_.begin (), past_end);
@@ -220,8 +220,8 @@ namespace boost { namespace network { namespace http {
220
220
response_.to_buffers (),
221
221
wrapper_.wrap (
222
222
boost::bind (
223
- &connection <Tag,Handler>::handle_write,
224
- connection <Tag,Handler>::shared_from_this (),
223
+ &sync_connection <Tag,Handler>::handle_write,
224
+ sync_connection <Tag,Handler>::shared_from_this (),
225
225
boost::asio::placeholders::error
226
226
)
227
227
)
@@ -231,8 +231,8 @@ namespace boost { namespace network { namespace http {
231
231
boost::asio::buffer (buffer_),
232
232
wrapper_.wrap (
233
233
boost::bind (
234
- &connection <Tag,Handler>::handle_read_body_contents,
235
- connection <Tag,Handler>::shared_from_this (),
234
+ &sync_connection <Tag,Handler>::handle_read_body_contents,
235
+ sync_connection <Tag,Handler>::shared_from_this (),
236
236
boost::asio::placeholders::error,
237
237
difference,
238
238
boost::asio::placeholders::bytes_transferred
@@ -257,7 +257,9 @@ namespace boost { namespace network { namespace http {
257
257
Handler & handler_;
258
258
boost::asio::ip::tcp::socket socket_;
259
259
boost::asio::io_service::strand wrapper_;
260
- boost::array<char ,BOOST_HTTP_SERVER_BUFFER_SIZE> buffer_;
260
+
261
+ typedef boost::array<char ,BOOST_NETWORK_HTTP_SERVER_CONNECTION_BUFFER_SIZE> buffer_type;
262
+ buffer_type buffer_;
261
263
request_parser parser_;
262
264
basic_request<Tag> request_;
263
265
basic_response<Tag> response_;
@@ -270,5 +272,5 @@ namespace boost { namespace network { namespace http {
270
272
271
273
} // namespace boost
272
274
273
- #endif // BOOST_NETWORK_HTTP_CONNECTION_HPP_
275
+ #endif // BOOST_NETWORK_HTTP_SERVER_SYNC_CONNECTION_HPP_
274
276
0 commit comments