Skip to content

HEAD request with empty body but set content-length triggers panic #3794

Closed
@23doors

Description

@23doors

Version
hyper 1.5.0

Platform
MacOS

Description

With HEAD requests it seems it is often the case that content-length is set to relevant GET body response, but payload is empty.
That's what for example tower_http ServeDir does. In debug mode this triggers panic:
https://github.com/hyperium/hyper/blob/master/src/proto/h1/role.rs#L704C36-L704C89

I guess this assertion should skip HEAD method completely or maybe it's more of a tower_http bug and body should define different sizehints here?

Release version works as expected, as assertion is skipped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-http1Area: HTTP/1 specific.A-serverArea: server.C-bugCategory: bug. Something is wrong. This is bad!E-easyEffort: easy. A task that would be a great starting point for a new contributor.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions