Skip to content

Handle empty body in decompression layer #617

@ducaale

Description

@ducaale
  • I have looked for existing issues (including closed) about this

Feature Request

Ignore decompression UnexpectedEOF errors for responses with empty body

Motivation

Servers sometimes return content-encoding/content-length with empty body for HEAD requests. I was looking into refactoring reqwest's decompression to use tower-http and would like to port this functionality to tower-http::decompression.

Proposal

Add boolean flag to StreamErrorIntoIoError to track whether any data has been read. Swallow any decompression errors in WrapBody if flag is not set.

Alternatives

I have thought about having two layers before and after decompression layer. One tracks if any data has been read while the other conditionally suppresses error (inspired by ducaale/xh#411).

But before pursuing this idea any further, I wanted to see if this can be handled by tower-http instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions