Skip to content

Wrong range size in LFS response #35276

@LePau

Description

@LePau

Description

According to RFC 7233 §4.2, the Content-Range response header must follow this format:

Content-Range: bytes <first-byte-pos>-<last-byte-pos>/<complete-length>

However, gitea is responding with the length of the remaining range from the first-byte-pos, instead of the complete-length of the object. This can cause seeking to fail when playing videos from the browser (direct from LFS storage), among other issues.

To demonstrate, I've uploaded a 56 byte LFS text file and ran the following commands:

> gitea -v
Gitea version 1.24.3 built with GNU Make 4.4.1, go1.24.5 : bindata, timetzdata, sqlite, sqlite_unlock_notify

> curl -v  http://localhost/owner/repo/info/lfs/objects/a2323ab55f9a6dbaecd5a8284c0391166e260f6d8e129ac973733e5765a8e7c8
...
< content-length: 56
...

> curl -H "Range: bytes=10-"  -v  http://localhost/owner/repo/info/lfs/objects/a2323ab55f9a6dbaecd5a8284c0391166e260f6d8e129ac973733e5765a8e7c8
...
< content-range: bytes 10-55/46
...

To be RFC compliant, the last output should read content-range: bytes 10-55/56.

Gitea Version

1.24.3

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

1.24.3

Operating System

No response

How are you running Gitea?

Inside a kubernetes pod container.

Database

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions