Skip to content

NamedFile: send Content-Length on 206 Partial Content - #40

Merged
fafhrd91 merged 1 commit into
ntex-rs:mainfrom
AlexeyMatskevich:files-206-content-length
Oct 25, 2026
Merged

fafhrd91 merged 1 commit into
ntex-rs:mainfrom
AlexeyMatskevich:files-206-content-length

Conversation

@AlexeyMatskevich

Copy link
Copy Markdown
Contributor

When a client asks ntex-files for part of a file with a Range header, the 206 Partial Content response has no Content-Length.

What changes

  • A 206 response to a GET with Range carries Content-Length equal to the length of the selected range (11 for bytes=10-20, 21 for bytes=0-20) and no Transfer-Encoding (test: test_named_file_content_length_headers).
  • A 206 response to a HEAD with Range carries Content-Length equal to the length of the selected range (11 for bytes=10-20) and no Transfer-Encoding (test: test_head_content_length_headers).

Reference

actix-files fixed the same in actix/actix-web#1496.

This PR can be merged independently of the others.

A 206 response to a Range request had no Content-Length. It now
carries the length of the selected range, for GET and HEAD.
@fafhrd91
fafhrd91 merged commit bcede23 into ntex-rs:main Oct 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants