diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-12-28 23:39:12 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-12-28 23:39:12 +0100 |
commit | 6d8bfa8360165097a2a5ddd22084e04fc048607b (patch) | |
tree | 0efe42e59dc7367d245f48e9e1627a0da07aad17 | |
parent | 91f9d4130b41cff714354ccc93bfe20f31e80a62 (diff) |
Don't send original file's content-length when transcoding.
-rw-r--r-- | music.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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); |