Skip to content
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

Http range headers 0.4 #391

Merged
merged 5 commits into from
Jul 21, 2023
Merged

Conversation

MarcusGrass
Copy link
Collaborator

Motivation

Fixes #384

Solution

Updates http-range-header to 0.4, it broke a test rejecting a spec-valid header so that's fixed here as well.
Added a bunch of tests in 0.4 re-ran the fuzzing and made a few optimizations. I think the performance increase was something like 15% across the board. Set the msrv on that project to the same as this one, 1.60.0. Added msrv to the package.metadata for tower-http, so I could run cargo msrv verify on it, it checks out.

The actual fix came from @jfaust in this PR MarcusGrass/http-range-header#3

@MarcusGrass MarcusGrass requested a review from davidpdrsn July 21, 2023 14:46
tower-http/CHANGELOG.md Outdated Show resolved Hide resolved
tower-http/Cargo.toml Outdated Show resolved Hide resolved
@MarcusGrass MarcusGrass requested a review from jplatte July 21, 2023 14:57
@@ -496,11 +496,16 @@ async fn read_partial_rejects_out_of_bounds_range() {
.unwrap();
let res = svc.oneshot(req).await.unwrap();

assert_eq!(res.status(), StatusCode::RANGE_NOT_SATISFIABLE);
assert_eq!(res.status(), StatusCode::PARTIAL_CONTENT);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if all bytes get returned, does it still make sense for the status code to be 'partial content'?

Copy link
Collaborator Author

@MarcusGrass MarcusGrass Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did actualy consider that and if I understand the spec correctly, it does https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/206

The HTTP 206 Partial Content success status response code indicates that the request has succeeded and the body contains the requested ranges of data, as described in the Range header of the request.

Granted, it is kind of strange

@jplatte jplatte merged commit 0c50afe into tower-rs:master Jul 21, 2023
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.

ServeDir: requests that ask for a range that extends past the end of a document return a 416 response
2 participants