summaryrefslogtreecommitdiff
path: root/music.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'music.cpp')
-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);