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

Commit5999ff5

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 parent20fded1 commit5999ff5

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
@@ -225,6 +225,23 @@ namespace boost { namespace network { namespace http {
225225

226226
voidread(read_callback_function callback) {
227227
if (error_encountered)boost::throw_exception(boost::system::system_error(*error_encountered));
228+
if (new_start != read_buffer_.begin())
229+
{
230+
input_range input =boost::make_iterator_range(new_start, read_buffer_.end());
231+
thread_pool().post(
232+
strand.wrap(
233+
boost::bind(
234+
callback
235+
, input
236+
,boost::system::error_code()
237+
, data_end - new_start
238+
, async_connection<Tag,Handler>::shared_from_this())
239+
)
240+
);
241+
new_start = read_buffer_.begin();
242+
return;
243+
}
244+
228245
socket().async_read_some(
229246
asio::buffer(read_buffer_)
230247
, strand.wrap(
@@ -248,6 +265,8 @@ namespace boost { namespace network { namespace http {
248265
thread_pool().post(
249266
boost::bind(
250267
callback
268+
,boost::make_iterator_range(read_buffer_.begin()
269+
,read_buffer_.begin() + bytes_transferred)
251270
, ec
252271
, bytes_transferred
253272
, async_connection<Tag,Handler>::shared_from_this()));
@@ -277,7 +296,7 @@ namespace boost { namespace network { namespace http {
277296
status_t status;
278297
request_parser_type parser;
279298
request request_;
280-
buffer_type::iterator new_start;
299+
buffer_type::iterator new_start, data_end;
281300
string_type partial_parsed;
282301
optional<boost::system::system_error> error_encountered;
283302
pending_actions_list pending_actions;
@@ -315,10 +334,11 @@ namespace boost { namespace network { namespace http {
315334
if (!ec) {
316335
logic::tribool parsed_ok;
317336
iterator_range<buffer_type::iterator> result_range, input_range;
337+
data_end = new_start + bytes_transferred;
318338
switch (state) {
319339
case method:
320340
input_range =boost::make_iterator_range(
321-
new_start,read_buffer_.end());
341+
new_start,data_end);
322342
fusion::tie(parsed_ok, result_range) = parser.parse_until(
323343
request_parser_type::method_done, input_range);
324344
if (!parsed_ok) {
@@ -341,7 +361,7 @@ namespace boost { namespace network { namespace http {
341361
}
342362
case uri:
343363
input_range =boost::make_iterator_range(
344-
new_start,read_buffer_.end());
364+
new_start,data_end);
345365
fusion::tie(parsed_ok, result_range) = parser.parse_until(
346366
request_parser_type::uri_done,
347367
input_range);
@@ -365,7 +385,7 @@ namespace boost { namespace network { namespace http {
365385
}
366386
case version:
367387
input_range =boost::make_iterator_range(
368-
new_start,read_buffer_.end());
388+
new_start,data_end);
369389
fusion::tie(parsed_ok, result_range) = parser.parse_until(
370390
request_parser_type::version_done,
371391
input_range);
@@ -399,7 +419,7 @@ namespace boost { namespace network { namespace http {
399419
}
400420
case headers:
401421
input_range =boost::make_iterator_range(
402-
new_start,read_buffer_.end());
422+
new_start,data_end);
403423
fusion::tie(parsed_ok, result_range) = parser.parse_until(
404424
request_parser_type::headers_done,
405425
input_range);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp