Skip to content

Commit

Permalink
Merge pull request #57 from dandi/err-undec-depth
Browse files Browse the repository at this point in the history
Better handling of undecodable Depth headers
  • Loading branch information
jwodder authored Feb 8, 2024
2 parents a8319cd + 76e120a commit a561bfa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
In Development
--------------
- Respond to undecodable "Depth" header values with a 400 response instead of
acting like no value was specified

v0.2.0 (2024-02-07)
-------------------
- Serve Zarr entries via manifests from
Expand Down
8 changes: 4 additions & 4 deletions src/dav/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ impl<S: Send + Sync> FromRequestParts<S> for FiniteDepth {
type Rejection = Response<Body>;

async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result<Self, Self::Rejection> {
match parts.headers.get("Depth").and_then(|v| v.to_str().ok()) {
Some("0") => Ok(FiniteDepth::Zero),
Some("1") => Ok(FiniteDepth::One),
Some("infinity") | None => Err((
match parts.headers.get("Depth").map(|v| v.to_str()) {
Some(Ok("0")) => Ok(FiniteDepth::Zero),
Some(Ok("1")) => Ok(FiniteDepth::One),
Some(Ok("infinity")) | None => Err((
StatusCode::FORBIDDEN,
[(CONTENT_TYPE, DAV_XML_CONTENT_TYPE)],
INFINITE_DEPTH_RESPONSE,
Expand Down

0 comments on commit a561bfa

Please sign in to comment.