Wrong range size in LFS response #14866

Closed
opened 2025-11-02 11:24:44 -06:00 by GiteaMirror · 0 comments
Owner

Originally created by @LePau on GitHub (Aug 14, 2025).

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

Originally created by @LePau on GitHub (Aug 14, 2025). ### Description According to [RFC 7233 §4.2](https://www.rfc-editor.org/rfc/rfc7233.html#section-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: ```sh > 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
GiteaMirror added the type/bug label 2025-11-02 11:24:44 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14866