From ea754365e607c7c36d00909ea7605daeaa64243c Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 2 Jan 2011 23:10:13 +0100 Subject: Added send_data(istream). --- http_connection.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'http_connection.cpp') diff --git a/http_connection.cpp b/http_connection.cpp index 128abf5..6e970b2 100644 --- a/http_connection.cpp +++ b/http_connection.cpp @@ -25,6 +25,17 @@ void HTTP::Connection::send_data(const void* data, std::size_t size) { boost::asio::write(socket, boost::asio::buffer(data, size)); } +void HTTP::Connection::send_data(std::istream& stream) { + char data[0x1000]; + std::streamsize size = 1; + while(size) { + stream.read(data, 0x1000); + size = stream.gcount(); + if(size > 0) + send_data(data, size); + } +} + HTTP::Connection::Connection(boost::asio::io_service& io_service) : socket(io_service) { headers_written = false; } -- cgit v1.2.3