From 6d8bfa8360165097a2a5ddd22084e04fc048607b Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 28 Dec 2010 23:39:12 +0100 Subject: Don't send original file's content-length when transcoding. --- music.cpp | 7 ++++--- 1 file 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); -- cgit v1.2.3