如何让Chrome显示字节或剩余时间用于内容编码的下载
我正在编写一个提供大文件的HTTP应用程序,我希望Web浏览器显示剩余时间和/或字节的估计。但是,由于文件非常可压缩,因此我也想使用GZPICTIGHON的内容编码,但也希望浏览器自动解压缩下载,以便用户没有额外的步骤来手动执行此操作。
但是,似乎Chrome(101.0.4951.64)不会显示出剩余的GZENTECTENT下载时间的时间。 ”
from http.server import HTTPServer, BaseHTTPRequestHandler
import time
import zlib
class SlowHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('content-disposition', 'attachment; filename="my.file"')
self.send_header('content-length', '1000000000')
self.send_header('content-encoding', 'gzip') # If commented out, Chrome shows time remaining
self.end_headers()
obj = zlib.compressobj(wbits=31)
compressed = obj.compress(b'Some data to compress. Some more' * 10000)
self.wfile.write(compressed)
self.wfile.write(obj.flush()[:-1])
self.wfile.flush()
time.sleep(10)
httpd = HTTPServer(("0.0.0.0", 8006), SlowHandler)
httpd.serve_forever()
如果我访问http:// localhost:8006
但是如果我不通过评论该行,然后,它确实显示了剩余时间的估计:
即使在safari进行测试时,即使使用内容编码的标头,它似乎总是显示出剩下的内容:
有没有办法让Chrome显示有关内容编码的下载的估计值?
编辑:如果这是一个错误,请在 https:/ /bugs.chromium.org/p/chromium/issues/detail?id=1329738
I'm writing an HTTP application that serves large files, and I would like web browser to show an estimate of time and/or bytes remaining. However, I would also like to use gzipped content-encoding, since the files are quite compressible, but would also like the browser to automatically decompress the download so the user doesn't have an extra step to do this manually.
However, it seems as though Chrome (101.0.4951.64) won't show an estimate of time remaining for gzipped content-encoded downloads. The below simple HTTP server
from http.server import HTTPServer, BaseHTTPRequestHandler
import time
import zlib
class SlowHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('content-disposition', 'attachment; filename="my.file"')
self.send_header('content-length', '1000000000')
self.send_header('content-encoding', 'gzip') # If commented out, Chrome shows time remaining
self.end_headers()
obj = zlib.compressobj(wbits=31)
compressed = obj.compress(b'Some data to compress. Some more' * 10000)
self.wfile.write(compressed)
self.wfile.write(obj.flush()[:-1])
self.wfile.flush()
time.sleep(10)
httpd = HTTPServer(("0.0.0.0", 8006), SlowHandler)
httpd.serve_forever()
results in this if I go to http://localhost:8006
But if I don't send the content-encoding header by commenting out that line, then it does show an estimate of time remaining:
When testing in Safari, even with the content-encoding header, it seems to always show an estimate of what's remaining:
Is there a way to get Chrome to show such estimates even for content-encoded downloads?
Edit: in case this is a bug, have reported it at https://bugs.chromium.org/p/chromium/issues/detail?id=1329738
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论