gzip + chunked:在解压缩之前必须等待整个文件的下载? [英] gzip + chunked : must wait the whole file to be downloaded before unzipping?

查看:202
本文介绍了gzip + chunked:在解压缩之前必须等待整个文件的下载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常肯定答案,但我希望有人确认一下。

I am pretty sure of the answer but I would like someone to confirm it please.

当gzip是gzip时,无法解压缩文件的一部分在HTTP标头中使用。
我必须先下载整个文件才能解压缩以获取数据。

There is no way to unzip only a part of a file when gzip is used in the HTTP headers. I gotta download the whole file before to be able to unzip it to get the data.

对吗?

例如,如果我得到前100个字节,其代码如下:

For example, if I get the first 100 bytes with some code like that:

myfile.read(100)

此时我将无法解压缩。

谢谢。

推荐答案

您可以立即开始解压缩gzip流,无论您有多少数据至今。您将能够提取到目前为止可用的压缩数据中表示的所有未压缩字节。

You can start decompressing a gzip stream immediately, for whatever amount of data you have so far. You will be able to extract all of the uncompressed bytes represented in the compressed data you have available so far.

您必须始终从头开始解压缩。所以你不能做的是在gzip流中间开始解压缩。如果要访问中间的数据,则需要将所有数据解压缩到该点。

You must always decompress from the beginning. So what you can't do is start decompressing in the middle of a gzip stream. If you want to access data in the middle, you need to decompress all of the data up to that point.

这篇关于gzip + chunked:在解压缩之前必须等待整个文件的下载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆