summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-12-28 23:39:12 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2010-12-28 23:39:12 +0100
commit6d8bfa8360165097a2a5ddd22084e04fc048607b (patch)
tree0efe42e59dc7367d245f48e9e1627a0da07aad17
parent91f9d4130b41cff714354ccc93bfe20f31e80a62 (diff)
Don't send original file's content-length when transcoding.
-rw-r--r--music.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/music.cpp b/music.cpp
index 8321b38..c1ce8f4 100644
--- a/music.cpp
+++ b/music.cpp
@@ -85,9 +85,6 @@ void MusicTrack::render(HTTPRequest& req, HTTPResponse& res) {
res.add_header("content-type", "application/octet-stream");
fs::ifstream is(path, std::ios::binary | std::ios::in);
- is.seekg(0, std::ios::end);
- res.add_header("content-length", boost::str(boost::format("%d") % is.tellg()));
- is.seekg(0, std::ios::beg);
if(req.query.find("decoder") != req.query.end() && req.query.find("encoder") != req.query.end()) {
DecoderBase *d = decoder::get_decoder(req.query["decoder"]);
@@ -97,6 +94,10 @@ void MusicTrack::render(HTTPRequest& req, HTTPResponse& res) {
delete d;
delete e;
} else {
+ is.seekg(0, std::ios::end);
+ res.add_header("content-length", boost::str(boost::format("%d") % is.tellg()));
+ is.seekg(0, std::ios::beg);
+
char data[0x1000];
while(is.good()) {
is.read(data, 0x1000);