oh, oops, _do_ send Content-Type with proxied JS

right, _length_ only works if we're streaming unencoded content, but type is still good no matter what!
This commit is contained in:
Emi Matchu 2020-09-21 11:42:24 -07:00
parent a0c7b6076f
commit c430ae8dd6

View file

@ -36,6 +36,7 @@ export default async (req, res) => {
res.status(proxyRes.status); res.status(proxyRes.status);
res.setHeader("Content-Type", proxyRes.headers.get("Content-Type"));
res.setHeader("Cache-Control", proxyRes.headers.get("Cache-Control")); res.setHeader("Cache-Control", proxyRes.headers.get("Cache-Control"));
res.setHeader("ETag", proxyRes.headers.get("ETag")); res.setHeader("ETag", proxyRes.headers.get("ETag"));
res.setHeader("Last-Modified", proxyRes.headers.get("Last-Modified")); res.setHeader("Last-Modified", proxyRes.headers.get("Last-Modified"));
@ -44,7 +45,6 @@ export default async (req, res) => {
// If the content is not encoded (I think their images generally aren't?), // If the content is not encoded (I think their images generally aren't?),
// stream the body directly, to speed things up a bit. // stream the body directly, to speed things up a bit.
res.setHeader("Content-Length", proxyRes.headers.get("Content-Length")); res.setHeader("Content-Length", proxyRes.headers.get("Content-Length"));
res.setHeader("Content-Type", proxyRes.headers.get("Content-Type"));
await streamPipeline(proxyRes.body, res); await streamPipeline(proxyRes.body, res);
} else { } else {
// Otherwise, I don't immediately know how to stream encoded content, so, // Otherwise, I don't immediately know how to stream encoded content, so,