feat(firefox): Implement header overrides in request interception (#4142)

This patch makes sure header overrides in request interception are
functioning as expected.

Drive-by: teach test server to use utf-8 charset header for text files.
This commit is contained in:
Andrey Lushnikov
2019-03-08 14:26:13 -08:00
committed by GitHub
parent 5d6535ca0c
commit 42351c7fe5
4 changed files with 17 additions and 7 deletions

View File

@@ -248,7 +248,10 @@ class TestServer {
response.end(`File not found: ${filePath}`);
return;
}
response.setHeader('Content-Type', mime.getType(filePath));
const mimeType = mime.getType(filePath);
const isTextEncoding = /^text\/|^application\/(javascript|json)/.test(mimeType);
const contentType = isTextEncoding ? `${mimeType}; charset=utf-8` : mimeType;
response.setHeader('Content-Type', contentType);
if (this._gzipRoutes.has(pathName)) {
response.setHeader('Content-Encoding', 'gzip');
const zlib = require('zlib');