summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--http_connection.cpp11
-rw-r--r--http_connection.h2
-rw-r--r--transcode.cpp11
3 files changed, 15 insertions, 9 deletions
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;
}
diff --git a/http_connection.h b/http_connection.h
index 446f0af..e3a3721 100644
--- a/http_connection.h
+++ b/http_connection.h
@@ -5,6 +5,7 @@
#include <vector>
#include <list>
#include <map>
+#include <istream>
#include <boost/asio.hpp>
#include <boost/enable_shared_from_this.hpp>
@@ -51,6 +52,7 @@ namespace HTTP {
//! Send data.
void send_data(const std::string& data);
void send_data(const void* data, std::size_t size);
+ void send_data(std::istream& stream);
private:
typedef std::vector<std::pair<std::string, std::string> > HeaderList;
diff --git a/transcode.cpp b/transcode.cpp
index 81d5274..f3698a3 100644
--- a/transcode.cpp
+++ b/transcode.cpp
@@ -13,13 +13,6 @@ void Transcoder::run() {
s.push(EncoderFilter(encoder), buffer_size);
s.push(DecoderFilter(decoder), buffer_size);
s.push(is, buffer_size);
-
- char data[0x1000];
- std::streamsize size = 1;
- while(size) {
- s.read(data, 0x1000);
- size = s.gcount();
- if(size > 0)
- res->send_data(data, size);
- }
+
+ res->send_data(s);
}