@@ -85,7 +85,8 @@ namespace boost { namespace network { namespace http {
85
85
void handle_read_headers (system::error_code const &ec, size_t bytes_transferred) {
86
86
if (!ec) {
87
87
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);
89
90
if (done) {
90
91
if (request_.method [0 ] == ' P' ) {
91
92
// look for the content-length header
@@ -132,19 +133,25 @@ namespace boost { namespace network { namespace http {
132
133
}
133
134
134
135
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
+ )
144
151
)
145
- )
146
- ) ;
147
- return ;
152
+ );
153
+ return ;
154
+ }
148
155
}
149
156
150
157
handler_ (request_, response_);
0 commit comments