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

Update to latest master Rocket version (#89) #114

Merged
merged 3 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ serialization = ["serde", "serde_derive", "unicase_serde"]

[dependencies]
regex = "1.7.2"
rocket = { version = "0.5.0-rc.3", default-features = false }
rocket = { version = "0.5.0-rc.4", default-features = false }
log = "0.4"
unicase = "2.6"
url = "2.3.1"
Expand Down
2 changes: 1 addition & 1 deletion src/fairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl rocket::route::Handler for FairingErrorRoute {
500
});
let status = Status::from_code(status).unwrap_or(Status::InternalServerError);
Outcome::Failure(status)
Outcome::Error(status)
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ impl Origin {
match request.headers().get_one("Origin") {
Some(origin) => match Self::from_str(origin) {
Ok(origin) => Outcome::Success(origin),
Err(e) => Outcome::Failure((Status::BadRequest, e)),
Err(e) => Outcome::Error((Status::BadRequest, e)),
},
None => Outcome::Forward(()),
None => Outcome::Forward(Status::default()),
}
}
}
Expand Down Expand Up @@ -164,9 +164,9 @@ impl AccessControlRequestMethod {
match request.headers().get_one("Access-Control-Request-Method") {
Some(request_method) => match Self::from_str(request_method) {
Ok(request_method) => Outcome::Success(request_method),
Err(_) => Outcome::Failure((Status::BadRequest, crate::Error::BadRequestMethod)),
Err(_) => Outcome::Error((Status::BadRequest, crate::Error::BadRequestMethod)),
},
None => Outcome::Forward(()),
None => Outcome::Forward(Status::default()),
}
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@ impl AccessControlRequestHeaders {
unreachable!("`AccessControlRequestHeaders::from_str` should never fail")
}
},
None => Outcome::Forward(()),
None => Outcome::Forward(Status::default()),
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1515,13 +1515,13 @@
Outcome::Success(options) => options,
_ => {
let error = Error::MissingCorsInRocketState;
return Outcome::Failure((error.status(), error));
return Outcome::Error((error.status(), error));
}
};

match Response::validate_and_build(options, request) {
Ok(response) => Outcome::Success(Self::new(response)),
Err(error) => Outcome::Failure((error.status(), error)),
Err(error) => Outcome::Error((error.status(), error)),
}
}
}
Expand Down Expand Up @@ -1757,27 +1757,27 @@
/// Gets the `Origin` request header from the request
fn origin(request: &Request<'_>) -> Result<Option<Origin>, Error> {
match Origin::from_request_sync(request) {
Outcome::Forward(()) => Ok(None),
Outcome::Forward(_) => Ok(None),
Outcome::Success(origin) => Ok(Some(origin)),
Outcome::Failure((_, err)) => Err(err),
Outcome::Error((_, err)) => Err(err),
}
}

/// Gets the `Access-Control-Request-Method` request header from the request
fn request_method(request: &Request<'_>) -> Result<Option<AccessControlRequestMethod>, Error> {
match AccessControlRequestMethod::from_request_sync(request) {
Outcome::Forward(()) => Ok(None),
Outcome::Forward(_) => Ok(None),
Outcome::Success(method) => Ok(Some(method)),
Outcome::Failure((_, err)) => Err(err),
Outcome::Error((_, err)) => Err(err),
}
}

/// Gets the `Access-Control-Request-Headers` request header from the request
fn request_headers(request: &Request<'_>) -> Result<Option<AccessControlRequestHeaders>, Error> {
match AccessControlRequestHeaders::from_request_sync(request) {
Outcome::Forward(()) => Ok(None),
Outcome::Forward(_) => Ok(None),
Outcome::Success(geaders) => Ok(Some(geaders)),
Outcome::Failure((_, err)) => Err(err),
Outcome::Error((_, err)) => Err(err),
}
}

Expand Down Expand Up @@ -1997,8 +1997,8 @@
) -> rocket::route::Outcome<'r> {
let guard: Guard<'_> = match request.guard().await {
Outcome::Success(guard) => guard,
Outcome::Failure((status, _)) => return rocket::route::Outcome::failure(status),
Outcome::Forward(()) => unreachable!("Should not be reachable"),
Outcome::Error((status, _)) => return rocket::route::Outcome::Error(status),
Outcome::Forward(_) => unreachable!("Should not be reachable"),
};

info_!(
Expand Down Expand Up @@ -2461,7 +2461,7 @@
#[test]
fn all_allowed_headers_are_validated_correctly() {
let allowed_headers = AllOrSome::All;
let requested_headers = vec!["Bar", "Foo"];

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, ubuntu-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, ubuntu-latest, --all-features)

useless use of `vec!`

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, ubuntu-latest, --all-features)

useless use of `vec!`

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, ubuntu-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, macOS-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, macOS-latest, --all-features)

useless use of `vec!`

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, macOS-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, windows-latest, --all-features)

useless use of `vec!`

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, windows-latest, --all-features)

useless use of `vec!`

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, macOS-latest, --all-features)

useless use of `vec!`

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, windows-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2464 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, windows-latest, --no-default-features)

useless use of `vec!`

not_err!(validate_allowed_headers(
&FromStr::from_str(&requested_headers.join(",")).unwrap(),
Expand All @@ -2473,8 +2473,8 @@
/// echoes back the list that is actually requested for and not the whole list
#[test]
fn allowed_headers_are_validated_correctly() {
let allowed_headers = vec!["Bar", "Baz", "Foo"];

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, ubuntu-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, ubuntu-latest, --all-features)

useless use of `vec!`

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, ubuntu-latest, --all-features)

useless use of `vec!`

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, ubuntu-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, macOS-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, macOS-latest, --all-features)

useless use of `vec!`

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, macOS-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, windows-latest, --all-features)

useless use of `vec!`

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, windows-latest, --all-features)

useless use of `vec!`

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, macOS-latest, --all-features)

useless use of `vec!`

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, windows-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2476 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, windows-latest, --no-default-features)

useless use of `vec!`
let requested_headers = vec!["Bar", "Foo"];

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, ubuntu-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, ubuntu-latest, --all-features)

useless use of `vec!`

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, ubuntu-latest, --all-features)

useless use of `vec!`

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, ubuntu-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, macOS-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, macOS-latest, --all-features)

useless use of `vec!`

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, macOS-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, windows-latest, --all-features)

useless use of `vec!`

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, windows-latest, --all-features)

useless use of `vec!`

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, macOS-latest, --all-features)

useless use of `vec!`

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, windows-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2477 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, windows-latest, --no-default-features)

useless use of `vec!`

not_err!(validate_allowed_headers(
&FromStr::from_str(&requested_headers.join(",")).unwrap(),
Expand All @@ -2490,8 +2490,8 @@
#[test]
#[should_panic(expected = "HeadersNotAllowed")]
fn allowed_headers_errors_on_non_subset() {
let allowed_headers = vec!["Bar", "Baz", "Foo"];

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, ubuntu-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, ubuntu-latest, --all-features)

useless use of `vec!`

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, ubuntu-latest, --all-features)

useless use of `vec!`

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, ubuntu-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, macOS-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, macOS-latest, --all-features)

useless use of `vec!`

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, macOS-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, windows-latest, --all-features)

useless use of `vec!`

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, windows-latest, --all-features)

useless use of `vec!`

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, macOS-latest, --all-features)

useless use of `vec!`

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, windows-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2493 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, windows-latest, --no-default-features)

useless use of `vec!`
let requested_headers = vec!["Bar", "Foo", "Unknown"];

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, ubuntu-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, ubuntu-latest, --all-features)

useless use of `vec!`

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, ubuntu-latest, --all-features)

useless use of `vec!`

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, ubuntu-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, macOS-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, macOS-latest, --all-features)

useless use of `vec!`

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, macOS-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, windows-latest, --all-features)

useless use of `vec!`

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, windows-latest, --all-features)

useless use of `vec!`

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, macOS-latest, --all-features)

useless use of `vec!`

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (nightly, windows-latest, --no-default-features)

useless use of `vec!`

Check failure on line 2494 in src/lib.rs

View workflow job for this annotation

GitHub Actions / ci (stable, windows-latest, --no-default-features)

useless use of `vec!`

validate_allowed_headers(
&FromStr::from_str(&requested_headers.join(",")).unwrap(),
Expand Down
Loading