Skip to content

Commit 3b28e1e

Browse files
committed
Fixed http::async_connection::write_first_line()
Use persistent buffer for boost::asio::async_write
1 parent 5253bac commit 3b28e1e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ namespace boost { namespace network { namespace http {
289289
Handler & handler;
290290
utils::thread_pool & thread_pool_;
291291
volatile bool headers_already_sent, first_line_already_sent, headers_in_progress, first_line_in_progress;
292-
asio::streambuf headers_buffer;
292+
asio::streambuf headers_buffer, first_line_buffer;
293293

294294
boost::recursive_mutex headers_mutex;
295295
buffer_type read_buffer_;
@@ -525,19 +525,18 @@ namespace boost { namespace network { namespace http {
525525
if (first_line_in_progress) return;
526526
first_line_in_progress = true;
527527

528-
std::vector<asio::const_buffer> buffers;
529528
typedef constants<Tag> consts;
530-
typename ostringstream<Tag>::type first_line_stream;
531-
first_line_stream
529+
first_line_buffer.consume(first_line_buffer.size());
530+
std::ostream first_line_stream(&first_line_buffer);
531+
first_line_stream
532532
<< consts::http_slash() << 1<< consts::dot() << 1 << consts::space()
533533
<< status << consts::space() << status_message(status)
534534
<< consts::crlf()
535+
<< std::flush
535536
;
536-
std::string first_line = first_line_stream.str();
537-
buffers.push_back(asio::buffer(first_line));
538537
asio::async_write(
539538
socket()
540-
, buffers
539+
, first_line_buffer
541540
, callback);
542541
}
543542

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy