Skip to content

Commit

Permalink
Merge pull request #1642 from rexso/master
Browse files Browse the repository at this point in the history
Respect explicitly set Content-Type in sendFile
  • Loading branch information
s-ludwig committed Dec 16, 2016
2 parents 1a082c5 + 2ab8620 commit e580c1b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions http/vibe/http/fileserver.d
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,15 @@ private void sendFileImpl(scope HTTPServerRequest req, scope HTTPServerResponse
}
}

auto mimetype = getMimeTypeForFile(pathstr);
auto mimetype = res.headers.get("Content-Type", getMimeTypeForFile(pathstr));

// avoid double-compression
if ("Content-Encoding" in res.headers && isCompressedFormat(mimetype))
res.headers.remove("Content-Encoding");
res.headers["Content-Type"] = mimetype;

if (!("Content-Type" in res.headers))
res.headers["Content-Type"] = mimetype;

res.headers.addField("Accept-Ranges", "bytes");
ulong rangeStart = 0;
ulong rangeEnd = 0;
Expand Down

0 comments on commit e580c1b

Please sign in to comment.