Skip to content

StaticFileHandler: allow non-zero suffix Range on zero-length files - #3930

Open
Burakceliks wants to merge 1 commit into
tornadoweb:masterfrom
Burakceliks:fix/static-file-range-zero-length
Open

Burakceliks wants to merge 1 commit into
tornadoweb:masterfrom
Burakceliks:fix/static-file-range-zero-length

Conversation

@Burakceliks

Copy link
Copy Markdown

Fixes #3926

Per RFC 9110 section 14.1.1, a non-zero suffix-byte-range-spec (e.g. Range: bytes=-5) on a zero-length representation is satisfiable and should return 200 OK with an empty body rather than 416 Range Not Satisfiable.

  • Track is_suffix = start is not None and start < 0 before clamping start.
  • Skip start >= size in the 416 check when is_suffix is True.
  • Add est_static_range_zero_length_file in ornado/test/web_test.py.

@bdarnell

Copy link
Copy Markdown
Member

This change fails type checking in CI

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StaticFileHandler answers 416 to a non-zero suffix Range on a zero-length file

2 participants