Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何在浏览器上查看brotli压缩文件?_Node.js_Server_Compression_Brotli - Fatal编程技术网

Node.js 如何在浏览器上查看brotli压缩文件?

Node.js 如何在浏览器上查看brotli压缩文件?,node.js,server,compression,brotli,Node.js,Server,Compression,Brotli,我正在尝试静态服务brotli压缩文件。我能够用以下代码压缩文件: //node.js const compressStream=requireiltorb.compressStream; 常数fs=所需参数; const wrr=fs.createWriteStreamindex-b.html; fs.createReadStreamindex.html .pipecompressStream 派普勒先生; 现在index-b.html文件被压缩了。但我怎么能在浏览器上看到这个呢 当我进入该页

我正在尝试静态服务brotli压缩文件。我能够用以下代码压缩文件:

//node.js const compressStream=requireiltorb.compressStream; 常数fs=所需参数; const wrr=fs.createWriteStreamindex-b.html; fs.createReadStreamindex.html .pipecompressStream 派普勒先生; 现在index-b.html文件被压缩了。但我怎么能在浏览器上看到这个呢

当我进入该页面时,我看到的是:

我想浏览器会理解这是一个brotli编码的文件。但事实并非如此。当我查看响应标题时

HTTP/1.1 200 OK
server: ecstatic-3.3.1
cache-control: max-age=3600
last-modified: Sat, 06 Apr 2019 17:27:32 GMT
etag: W/"281474976993459-334-2019-04-06T17:27:32.047Z"
content-length: 334
content-type: text/html; charset=UTF-8
Date: Sat, 06 Apr 2019 17:36:49 GMT
Connection: keep-alive
没有编码集。如何解决这个问题?

您使用的是一个非常简单的HTTP服务器,不允许您显式设置内容编码

看起来有,但还没有完成。即使是这样,它也只用于服务静态的预压缩文件,假设它的实现方式与-gzip选项相同


要想使用dynamic brotli,必须使用普通节点代码或类似的代码。

显示Node.js代码的其余部分。没有任何剩余代码。我把那个压缩文件放在一个文件夹中,并在那个文件夹中启动了一个服务器。然后转到浏览器@巴里波拉德