mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user