mirror of https://github.com/fafhrd91/actix-web
fix test
This commit is contained in:
parent
d121432b3a
commit
09d7f7361e
|
@ -6,10 +6,11 @@
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- `HttpRequest::req_data[_mut]()`; request-local data is still available through `.extensions()`. [#2585]
|
- `HttpRequest::req_data[_mut]()`; request-local data is still available through `.extensions()`. [#2585]
|
||||||
- `HttpRequestBuilder::del_cookie
|
- `HttpRequestBuilder::del_cookie`. [#2591]
|
||||||
|
|
||||||
[#2585]: https://github.com/actix/actix-web/pull/2585
|
[#2585]: https://github.com/actix/actix-web/pull/2585
|
||||||
[#2586]: https://github.com/actix/actix-web/pull/2586
|
[#2586]: https://github.com/actix/actix-web/pull/2586
|
||||||
|
[#2591]: https://github.com/actix/actix-web/pull/2591
|
||||||
|
|
||||||
|
|
||||||
## 4.0.0-beta.20 - 2022-01-14
|
## 4.0.0-beta.20 - 2022-01-14
|
||||||
|
|
|
@ -282,6 +282,9 @@ impl HttpResponseBuilder {
|
||||||
|
|
||||||
/// Set a body and build the `HttpResponse`.
|
/// Set a body and build the `HttpResponse`.
|
||||||
///
|
///
|
||||||
|
/// Unlike [`message_body`](Self::message_body), errors are converted into error
|
||||||
|
/// responses immediately.
|
||||||
|
///
|
||||||
/// `HttpResponseBuilder` can not be used after this call.
|
/// `HttpResponseBuilder` can not be used after this call.
|
||||||
pub fn body<B>(&mut self, body: B) -> HttpResponse<BoxBody>
|
pub fn body<B>(&mut self, body: B) -> HttpResponse<BoxBody>
|
||||||
where
|
where
|
||||||
|
@ -307,10 +310,7 @@ impl HttpResponseBuilder {
|
||||||
.expect("cannot reuse response builder")
|
.expect("cannot reuse response builder")
|
||||||
.set_body(body);
|
.set_body(body);
|
||||||
|
|
||||||
#[allow(unused_mut)] // mut is only unused when cookies are disabled
|
Ok(HttpResponse::from(res))
|
||||||
let mut res = HttpResponse::from(res);
|
|
||||||
|
|
||||||
Ok(res)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set a streaming body and build the `HttpResponse`.
|
/// Set a streaming body and build the `HttpResponse`.
|
||||||
|
|
|
@ -11,7 +11,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
cookie::{Cookie, CookieBuilder},
|
cookie::Cookie,
|
||||||
http::{header, StatusCode},
|
http::{header, StatusCode},
|
||||||
middleware::{Compress, NormalizePath, TrailingSlash},
|
middleware::{Compress, NormalizePath, TrailingSlash},
|
||||||
web, App, Error, HttpResponse,
|
web, App, Error, HttpResponse,
|
||||||
|
@ -773,7 +773,7 @@ async fn test_server_cookies() {
|
||||||
App::new().default_service(web::to(|| {
|
App::new().default_service(web::to(|| {
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
.cookie(
|
.cookie(
|
||||||
CookieBuilder::new("first", "first_value")
|
Cookie::build("first", "first_value")
|
||||||
.http_only(true)
|
.http_only(true)
|
||||||
.finish(),
|
.finish(),
|
||||||
)
|
)
|
||||||
|
@ -787,13 +787,13 @@ async fn test_server_cookies() {
|
||||||
let res = req.send().await.unwrap();
|
let res = req.send().await.unwrap();
|
||||||
assert!(res.status().is_success());
|
assert!(res.status().is_success());
|
||||||
|
|
||||||
let first_cookie = CookieBuilder::new("first", "first_value")
|
let first_cookie = Cookie::build("first", "first_value")
|
||||||
.http_only(true)
|
.http_only(true)
|
||||||
.finish();
|
.finish();
|
||||||
let second_cookie = Cookie::new("second", "second_value");
|
let second_cookie = Cookie::new("second", "first_value");
|
||||||
|
|
||||||
let cookies = res.cookies().expect("To have cookies");
|
let cookies = res.cookies().expect("To have cookies");
|
||||||
assert_eq!(cookies.len(), 2);
|
assert_eq!(cookies.len(), 3);
|
||||||
if cookies[0] == first_cookie {
|
if cookies[0] == first_cookie {
|
||||||
assert_eq!(cookies[1], second_cookie);
|
assert_eq!(cookies[1], second_cookie);
|
||||||
} else {
|
} else {
|
||||||
|
@ -809,7 +809,7 @@ async fn test_server_cookies() {
|
||||||
.get_all(http::header::SET_COOKIE)
|
.get_all(http::header::SET_COOKIE)
|
||||||
.map(|header| header.to_str().expect("To str").to_string())
|
.map(|header| header.to_str().expect("To str").to_string())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
assert_eq!(cookies.len(), 2);
|
assert_eq!(cookies.len(), 3);
|
||||||
if cookies[0] == first_cookie {
|
if cookies[0] == first_cookie {
|
||||||
assert_eq!(cookies[1], second_cookie);
|
assert_eq!(cookies[1], second_cookie);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue