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 19, 2016
1 parent 48f7916 commit 303647d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/vibe/http/fileserver.d
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 303647d

Please sign in to comment.