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

Commit08c04cc

Browse files
committed
Fixes bug with PUT/POST handling.
The problem is that the remainder data after the headers may not be read right away. This commit fixes that problem.
1 parent0c062a8 commit08c04cc

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

‎boost/network/protocol/http/connection.hpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ namespace boost { namespace network { namespace http {
8585
voidhandle_read_headers(system::error_codeconst &ec,size_t bytes_transferred) {
8686
if (!ec) {
8787
tribool done;
88-
tie(done,tuples::ignore) = parser_.parse_headers(request_, buffer_.data(), buffer_.data() + bytes_transferred);
88+
array<char, BOOST_HTTP_SERVER_BUFFER_SIZE>::iterator new_start;
89+
tie(done,new_start) = parser_.parse_headers(request_, buffer_.data(), buffer_.data() + bytes_transferred);
8990
if (done) {
9091
if (request_.method[0] =='P') {
9192
// look for the content-length header
@@ -132,19 +133,25 @@ namespace boost { namespace network { namespace http {
132133
}
133134

134135
if (content_length !=0) {
135-
socket_.async_read_some(
136-
boost::asio::buffer(buffer_),
137-
wrapper_.wrap(
138-
bind(
139-
&connection<Tag,Handler>::handle_read_body_contents,
140-
connection<Tag,Handler>::shared_from_this(),
141-
boost::asio::placeholders::error,
142-
content_length,
143-
boost::asio::placeholders::bytes_transferred
136+
if (new_start != (buffer_.begin() + bytes_transferred)) {
137+
request_.body.append(new_start, buffer_.begin() + bytes_transferred);
138+
content_length -=std::distance(new_start, buffer_.begin() + bytes_transferred);
139+
}
140+
if (content_length >0) {
141+
socket_.async_read_some(
142+
boost::asio::buffer(buffer_),
143+
wrapper_.wrap(
144+
bind(
145+
&connection<Tag,Handler>::handle_read_body_contents,
146+
connection<Tag,Handler>::shared_from_this(),
147+
boost::asio::placeholders::error,
148+
content_length,
149+
boost::asio::placeholders::bytes_transferred
150+
)
144151
)
145-
)
146-
);
147-
return;
152+
);
153+
return;
154+
}
148155
}
149156

150157
handler_(request_, response_);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp