We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ba65ca4 + 7b30442 commit be1c3a9Copy full SHA for be1c3a9
src/security/cors.rs
@@ -379,4 +379,20 @@ mod test {
379
380
assert_eq!(res[http_types::headers::SET_COOKIE][0], "foo=bar");
381
}
382
+
383
+ #[async_std::test]
384
+ async fn set_cors_headers_to_error_responses() {
385
+ let mut app = crate::Server::new();
386
+ app.at(ENDPOINT).get(|_| async {
387
+ Err::<&str, _>(crate::Error::from_str(
388
+ StatusCode::BadRequest,
389
+ "bad request",
390
+ ))
391
+ });
392
+ app.middleware(CorsMiddleware::new().allow_origin(Origin::from(ALLOW_ORIGIN)));
393
394
+ let res: crate::http::Response = app.respond(request()).await.unwrap();
395
+ assert_eq!(res.status(), 400);
396
+ assert_eq!(res[headers::ACCESS_CONTROL_ALLOW_ORIGIN], ALLOW_ORIGIN);
397
+ }
398
0 commit comments