@@ -29,7 +29,7 @@ might work, but they are subject to the minimum that Rocket sets.
29
29
Add the following to Cargo.toml:
30
30
31
31
```toml
32
- rocket_cors = "0.5.0-beta-2 "
32
+ rocket_cors = "0.5.1 "
33
33
```
34
34
35
35
To use the latest `master` branch, for example:
@@ -45,7 +45,7 @@ the [`CorsOptions`] struct that is described below. If you would like to disable
45
45
change your `Cargo.toml` to:
46
46
47
47
```toml
48
- rocket_cors = { version = "0.5.0 ", default-features = false }
48
+ rocket_cors = { version = "0.5.1 ", default-features = false }
49
49
```
50
50
51
51
## Usage
@@ -258,7 +258,6 @@ See the [example](https://github.com/lawliet89/rocket_cors/blob/master/examples/
258
258
while_true
259
259
) ]
260
260
#![ allow(
261
- legacy_directory_ownership,
262
261
missing_copy_implementations,
263
262
missing_debug_implementations,
264
263
unknown_lints,
@@ -812,12 +811,12 @@ impl ParsedAllowedOrigins {
812
811
exact. into_iter ( ) . partition ( |( _, url) | url. is_tuple ( ) ) ;
813
812
814
813
if !opaque. is_empty ( ) {
815
- Err ( Error :: OpaqueAllowedOrigin (
814
+ return Err ( Error :: OpaqueAllowedOrigin (
816
815
opaque
817
816
. into_iter ( )
818
817
. map ( |( original, _) | original. to_string ( ) )
819
818
. collect ( ) ,
820
- ) ) ?
819
+ ) ) ;
821
820
}
822
821
823
822
let exact = tuple. into_iter ( ) . map ( |( _, url) | url) . collect ( ) ;
@@ -907,7 +906,7 @@ pub type AllowedHeaders = AllOrSome<HashSet<HeaderFieldName>>;
907
906
impl AllowedHeaders {
908
907
/// Allow some headers
909
908
pub fn some ( headers : & [ & str ] ) -> Self {
910
- AllOrSome :: Some ( headers. iter ( ) . map ( |s| s . to_string ( ) . into ( ) ) . collect ( ) )
909
+ AllOrSome :: Some ( headers. iter ( ) . map ( |s| ( * s ) . to_string ( ) . into ( ) ) . collect ( ) )
911
910
}
912
911
913
912
/// Allows all headers
@@ -1143,7 +1142,7 @@ impl CorsOptions {
1143
1142
/// Validates if any of the settings are disallowed, incorrect, or illegal
1144
1143
pub fn validate ( & self ) -> Result < ( ) , Error > {
1145
1144
if self . allowed_origins . is_all ( ) && self . send_wildcard && self . allow_credentials {
1146
- Err ( Error :: CredentialsWithWildcardOrigin ) ? ;
1145
+ return Err ( Error :: CredentialsWithWildcardOrigin ) ;
1147
1146
}
1148
1147
1149
1148
Ok ( ( ) )
@@ -1296,7 +1295,7 @@ impl Response {
1296
1295
/// Consumes the CORS, set expose_headers to
1297
1296
/// passed headers and returns changed CORS
1298
1297
fn exposed_headers ( mut self , headers : & [ & str ] ) -> Self {
1299
- self . expose_headers = headers. iter ( ) . map ( |s| s . to_string ( ) . into ( ) ) . collect ( ) ;
1298
+ self . expose_headers = headers. iter ( ) . map ( |s| ( * s ) . to_string ( ) . into ( ) ) . collect ( ) ;
1300
1299
self
1301
1300
}
1302
1301
@@ -1317,7 +1316,7 @@ impl Response {
1317
1316
/// Consumes the CORS, set allow_headers to
1318
1317
/// passed headers and returns changed CORS
1319
1318
fn headers ( mut self , headers : & [ & str ] ) -> Self {
1320
- self . allow_headers = headers. iter ( ) . map ( |s| s . to_string ( ) . into ( ) ) . collect ( ) ;
1319
+ self . allow_headers = headers. iter ( ) . map ( |s| ( * s ) . to_string ( ) . into ( ) ) . collect ( ) ;
1321
1320
self
1322
1321
}
1323
1322
@@ -1680,7 +1679,7 @@ fn validate_allowed_method(
1680
1679
) -> Result < ( ) , Error > {
1681
1680
let & AccessControlRequestMethod ( ref request_method) = method;
1682
1681
if !allowed_methods. iter ( ) . any ( |m| m == request_method) {
1683
- Err ( Error :: MethodNotAllowed ( method. 0 . to_string ( ) ) ) ?
1682
+ return Err ( Error :: MethodNotAllowed ( method. 0 . to_string ( ) ) ) ;
1684
1683
}
1685
1684
1686
1685
// TODO: Subset to route? Or just the method requested for?
@@ -1698,7 +1697,7 @@ fn validate_allowed_headers(
1698
1697
AllOrSome :: All => Ok ( ( ) ) ,
1699
1698
AllOrSome :: Some ( ref allowed_headers) => {
1700
1699
if !headers. is_empty ( ) && !headers. is_subset ( allowed_headers) {
1701
- Err ( Error :: HeadersNotAllowed ) ?
1700
+ return Err ( Error :: HeadersNotAllowed ) ;
1702
1701
}
1703
1702
Ok ( ( ) )
1704
1703
}
@@ -1991,7 +1990,7 @@ mod tests {
1991
1990
allow_credentials : true ,
1992
1991
expose_headers : [ "Content-Type" , "X-Custom" ]
1993
1992
. iter ( )
1994
- . map ( |s| s . to_string ( ) )
1993
+ . map ( |s| ( * s ) . to_string ( ) )
1995
1994
. collect ( ) ,
1996
1995
..Default :: default ( )
1997
1996
}
0 commit comments