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

Commita2fb9fe

Browse files
committed
Fixed async_connection::read()
First read() returns remainder of the data that is in read_buffer_after handle_read_data() and is not the part of HTTP message header.Subsequent reads do actual read from socket.
1 parent2b1870e commita2fb9fe

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

‎boost/network/protocol/http/server/async_connection.hpp‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,23 @@ namespace boost { namespace network { namespace http {
227227

228228
voidread(read_callback_function callback) {
229229
if (error_encountered)boost::throw_exception(boost::system::system_error(*error_encountered));
230+
if (new_start != read_buffer_.begin())
231+
{
232+
input_range input =boost::make_iterator_range(new_start, read_buffer_.end());
233+
thread_pool().post(
234+
strand.wrap(
235+
boost::bind(
236+
callback
237+
, input
238+
,boost::system::error_code()
239+
, data_end - new_start
240+
, async_connection<Tag,Handler>::shared_from_this())
241+
)
242+
);
243+
new_start = read_buffer_.begin();
244+
return;
245+
}
246+
230247
socket().async_read_some(
231248
asio::buffer(read_buffer_)
232249
, strand.wrap(
@@ -250,6 +267,8 @@ namespace boost { namespace network { namespace http {
250267
thread_pool().post(
251268
boost::bind(
252269
callback
270+
,boost::make_iterator_range(read_buffer_.begin()
271+
,read_buffer_.begin() + bytes_transferred)
253272
, ec
254273
, bytes_transferred
255274
, async_connection<Tag,Handler>::shared_from_this()));
@@ -279,7 +298,7 @@ namespace boost { namespace network { namespace http {
279298
status_t status;
280299
request_parser_type parser;
281300
request request_;
282-
buffer_type::iterator new_start;
301+
buffer_type::iterator new_start, data_end;
283302
string_type partial_parsed;
284303
optional<boost::system::system_error> error_encountered;
285304
pending_actions_list pending_actions;
@@ -317,10 +336,11 @@ namespace boost { namespace network { namespace http {
317336
if (!ec) {
318337
logic::tribool parsed_ok;
319338
iterator_range<buffer_type::iterator> result_range, input_range;
339+
data_end = new_start + bytes_transferred;
320340
switch (state) {
321341
case method:
322342
input_range =boost::make_iterator_range(
323-
new_start,read_buffer_.end());
343+
new_start,data_end);
324344
fusion::tie(parsed_ok, result_range) = parser.parse_until(
325345
request_parser_type::method_done, input_range);
326346
if (!parsed_ok) {
@@ -343,7 +363,7 @@ namespace boost { namespace network { namespace http {
343363
}
344364
case uri:
345365
input_range =boost::make_iterator_range(
346-
new_start,read_buffer_.end());
366+
new_start,data_end);
347367
fusion::tie(parsed_ok, result_range) = parser.parse_until(
348368
request_parser_type::uri_done,
349369
input_range);
@@ -367,7 +387,7 @@ namespace boost { namespace network { namespace http {
367387
}
368388
case version:
369389
input_range =boost::make_iterator_range(
370-
new_start,read_buffer_.end());
390+
new_start,data_end);
371391
fusion::tie(parsed_ok, result_range) = parser.parse_until(
372392
request_parser_type::version_done,
373393
input_range);
@@ -391,7 +411,7 @@ namespace boost { namespace network { namespace http {
391411
}
392412
case headers:
393413
input_range =boost::make_iterator_range(
394-
new_start,read_buffer_.end());
414+
new_start,data_end);
395415
fusion::tie(parsed_ok, result_range) = parser.parse_until(
396416
request_parser_type::headers_done,
397417
input_range);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp