Skip to content

Range requests send an invalid response header #578

@the-sun-will-rise-tomorrow

Description

$ curl -v -H 'Range: bytes=0-1023' 'https://nix-cache.internal.host:5000/nar/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.nar?hash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
[...]
> GET /nar/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.nar?hash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx HTTP/2
> Host: nix-cache.internal.host:5000
> User-Agent: curl/8.14.1
> Accept: */*
> Range: bytes=0-1023
> 
* Request completely sent off
< HTTP/2 200 
< content-length: 1024
< accept-ranges: bytes
< content-encoding: identity
< content-type: application/x-nix-archive
< cache-control: max-age=31536000
< content-range: bytes 0-1023/2826744
< date: Mon, 04 Aug 2025 16:38:58 GMT

content-encoding: identity is not a valid header.

Though identity is a valid value for the Accept-Encoding request header, it is not a valid value for the Content-Encoding response header.

Setting this header to this value causes Nix to fail the download when it attempts to resume after a disconnect:

warning: error: unable to download 'https://nix-cache.internal.host:5000/nar/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.nar?hash=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': HTTP error 200 (curl error: Failure when receiving data from the peer); retrying from offset 222286391 in 342 ms
error: failed to get libarchive filter by name: No such filter 'identity'
error: some substitutes for the outputs of derivation '/nix/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-my-derivation.drv' failed (usually happens due to networking issues); try '--fallback' to build derivation from source
error: Cannot build '/nix/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-nix-shell-env.drv'.

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