diff options
-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); |