Skip to content

Data not cached when gzip content-encoding is combined with chunked transfer-encoding. #33

Description

@DanielLukic

See line 68 in ChunkedInputStream:

    if (bytesRemainingInChunk == 0 && in.available() >= MIN_LAST_CHUNK_LENGTH) {

Using available() on an InputStream is generally a bad idea, I guess. In many cases this will return 0.

In case of a server returning gzipped data (content-encoding: gzip) of more than a few KB, it will probably turn on chunked encoding (transfer-encoding: chunked). Most probably to support non-buffered streaming mode.

In this case the ChunkedInputStream will never commit the response data to the cache.

The easy fix is probably to reduce the if statement in line 68 to:

    if (bytesRemainingInChunk == 0) {

Does that make sense to anyone? ^^

Cheers,

dl

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions