这是indexloc提供的服务,不要输入任何密码
Skip to content

Range eof #3323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Range eof #3323

wants to merge 8 commits into from

Conversation

keniwhat
Copy link

Content range requests past EOF will fail witth the current version of vapor. It is common practice to just return the remaining bytes rather than throw a bad request error. This helps existing imperfect clients, still out there in the wild to continue to function.

This change captures an attempt to read past EOF (eg a range request of 10-200, when there are only 180 bytes in the file), and returns a response of "partial content" and the remaining bytes. It replaces code that returned a "bad request" error.

The existing tests have been updated to reflect this change and test for a response of type "partial content".
In addition two new asserts have been added to a test:

  • The response header content range meets expectation
  • The response body byte count meets expectation

As well as passing all tests, the code has been tested with a real life test case.

NOTE: The test 'AsyncRouteTests.testGH2716()' does not not pass. However, it does not pass on the vapor/main branch from which this has been forked.

@keniwhat keniwhat requested review from 0xTim and gwynne as code owners April 14, 2025 11:26
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.

2 participants