55// or copy at http://www.boost.org/LICENSE_1_0.txt)
66//
77
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_
1010
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
1313#endif
1414
1515#include < boost/enable_shared_from_this.hpp>
3131namespace boost {namespace network {namespace http {
3232
3333template <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> > {
3535
36- connection (boost::asio::io_service & service, Handler & handler)
36+ sync_connection (boost::asio::io_service & service, Handler & handler)
3737 : service_(service)
3838 , handler_(handler)
3939 , socket_(service_)
@@ -59,8 +59,8 @@ namespace boost { namespace network { namespace http {
5959boost::asio::buffer (buffer_),
6060 wrapper_.wrap (
6161boost::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 (),
6464 boost::asio::placeholders::error,
6565 boost::asio::placeholders::bytes_transferred
6666 )
@@ -81,7 +81,7 @@ namespace boost { namespace network { namespace http {
8181if (!ec) {
8282 request_.source = socket_.remote_endpoint ().address ().to_string ();
8383 boost::tribool done;
84- boost::array< char , BOOST_HTTP_SERVER_BUFFER_SIZE> ::iterator new_start;
84+ buffer_type ::iterator new_start;
8585tie (done,new_start) = parser_.parse_headers (request_, buffer_.data (), buffer_.data () + bytes_transferred);
8686if (done) {
8787if (request_.method [0 ] ==' P' ) {
@@ -99,8 +99,8 @@ namespace boost { namespace network { namespace http {
9999 response_.to_buffers (),
100100 wrapper_.wrap (
101101boost::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 (),
104104 boost::asio::placeholders::error
105105 )
106106 )
@@ -119,8 +119,8 @@ namespace boost { namespace network { namespace http {
119119 response_.to_buffers (),
120120 wrapper_.wrap (
121121boost::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 (),
124124 boost::asio::placeholders::error
125125 )
126126 )
@@ -138,8 +138,8 @@ namespace boost { namespace network { namespace http {
138138boost::asio::buffer (buffer_),
139139 wrapper_.wrap (
140140boost::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 (),
143143 boost::asio::placeholders::error,
144144 content_length,
145145 boost::asio::placeholders::bytes_transferred
@@ -156,8 +156,8 @@ namespace boost { namespace network { namespace http {
156156 response_.to_buffers (),
157157 wrapper_.wrap (
158158boost::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 (),
161161 boost::asio::placeholders::error
162162 )
163163 )
@@ -169,8 +169,8 @@ namespace boost { namespace network { namespace http {
169169 response_.to_buffers (),
170170 wrapper_.wrap (
171171boost::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 (),
174174 boost::asio::placeholders::error
175175 )
176176 )
@@ -183,8 +183,8 @@ namespace boost { namespace network { namespace http {
183183 response_.to_buffers (),
184184 wrapper_.wrap (
185185boost::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 (),
188188 boost::asio::placeholders::error
189189 )
190190 )
@@ -194,8 +194,8 @@ namespace boost { namespace network { namespace http {
194194boost::asio::buffer (buffer_),
195195 wrapper_.wrap (
196196boost::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 (),
199199 boost::asio::placeholders::error,
200200 boost::asio::placeholders::bytes_transferred
201201 )
@@ -209,7 +209,7 @@ namespace boost { namespace network { namespace http {
209209void handle_read_body_contents (boost::system::error_codeconst & ec,size_t bytes_to_read,size_t bytes_transferred) {
210210if (!ec) {
211211size_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 (),
213213 past_end = start;
214214std::advance (past_end, (std::min)(bytes_to_read,bytes_transferred));
215215 request_.body .append (buffer_.begin (), past_end);
@@ -220,8 +220,8 @@ namespace boost { namespace network { namespace http {
220220 response_.to_buffers (),
221221 wrapper_.wrap (
222222boost::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 (),
225225 boost::asio::placeholders::error
226226 )
227227 )
@@ -231,8 +231,8 @@ namespace boost { namespace network { namespace http {
231231boost::asio::buffer (buffer_),
232232 wrapper_.wrap (
233233boost::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 (),
236236 boost::asio::placeholders::error,
237237 difference,
238238 boost::asio::placeholders::bytes_transferred
@@ -257,7 +257,9 @@ namespace boost { namespace network { namespace http {
257257 Handler & handler_;
258258 boost::asio::ip::tcp::socket socket_;
259259 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_;
261263 request_parser parser_;
262264 basic_request<Tag> request_;
263265 basic_response<Tag> response_;
@@ -270,5 +272,5 @@ namespace boost { namespace network { namespace http {
270272
271273}// namespace boost
272274
273- #endif // BOOST_NETWORK_HTTP_CONNECTION_HPP_
275+ #endif // BOOST_NETWORK_HTTP_SERVER_SYNC_CONNECTION_HPP_
274276