-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing interface for uncompressed Content-Length when compression is used #1358
Comments
We do keep track of this in "decoded body size" (which is only exposed through Resource Timing at the moment) but that's incremented whenever we decode a chunk. I don't think we actually know the full size upfront as you would need for a progress indicator. |
Would it be reasonable to expose the total number of pre-decompression bytes received so far? Something like As far as I know, it is not always possible to compute the expected total uncompressed payload size. With Content-Encoding: gzip it might be possible after receiving the gzip header, but it is not possible with Content-Encoding: deflate. |
It seems reasonable in the abstract, but we'd need to figure out where to put that information. We cannot just stuff it on cc @domenic |
Sadly the gzip header doesn't contain size information. The gzip footer does, but that's not useful for calculating progress. |
Putting the information on ReadableStream means it's not possible to use the convenience methods (e.g. |
it could be handy to get ahold of the resource timing when making a request. if we could get an incomplete one then we could figure this out by ourself and it would be easier to know which one belongs to the actual request that you have made. fetch(url, {
onTiming (resourceTiming) {
// do things with it.
}
})
you could always clone the response. var clone = response.clone()
response.json().then(console.log)
clone.body.pipeTo(progressStream) |
FWIW, I still think #607 is the way to go for exposing this and other information about an ongoing fetch. |
In order to track progress of a fetch GET request(in a similar way to
onprogress
events ofXMLHttpRequest
) it is possible to read the body of a request with aReadableStream
and retrieve the total size of the request body fromContent-Length
header.However, if the request is compressed using the
Content-Enconding
header theContent-Length
does not give the total uncompressed size of the request body but the size of the compressed request body.It would be nice to have an interface to get the total size of the uncompressed body in order to properly track the progress of a request. There is the
FetchObserver
(#607) proposal but it doesn't seem to have gained any traction.The text was updated successfully, but these errors were encountered: