This commit is contained in:
Rob Ede 2022-01-19 22:58:48 +00:00
parent d121432b3a
commit 09d7f7361e
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
3 changed files with 12 additions and 11 deletions

View File

@ -6,10 +6,11 @@
### Removed
- `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
[#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

View File

@ -282,6 +282,9 @@ impl HttpResponseBuilder {
/// 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.
pub fn body<B>(&mut self, body: B) -> HttpResponse<BoxBody>
where
@ -307,10 +310,7 @@ impl HttpResponseBuilder {
.expect("cannot reuse response builder")
.set_body(body);
#[allow(unused_mut)] // mut is only unused when cookies are disabled
let mut res = HttpResponse::from(res);
Ok(res)
Ok(HttpResponse::from(res))
}
/// Set a streaming body and build the `HttpResponse`.

View File

@ -11,7 +11,7 @@ use std::{
};
use actix_web::{
cookie::{Cookie, CookieBuilder},
cookie::Cookie,
http::{header, StatusCode},
middleware::{Compress, NormalizePath, TrailingSlash},
web, App, Error, HttpResponse,
@ -773,7 +773,7 @@ async fn test_server_cookies() {
App::new().default_service(web::to(|| {
HttpResponse::Ok()
.cookie(
CookieBuilder::new("first", "first_value")
Cookie::build("first", "first_value")
.http_only(true)
.finish(),
)
@ -787,13 +787,13 @@ async fn test_server_cookies() {
let res = req.send().await.unwrap();
assert!(res.status().is_success());
let first_cookie = CookieBuilder::new("first", "first_value")
let first_cookie = Cookie::build("first", "first_value")
.http_only(true)
.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");
assert_eq!(cookies.len(), 2);
assert_eq!(cookies.len(), 3);
if cookies[0] == first_cookie {
assert_eq!(cookies[1], second_cookie);
} else {
@ -809,7 +809,7 @@ async fn test_server_cookies() {
.get_all(http::header::SET_COOKIE)
.map(|header| header.to_str().expect("To str").to_string())
.collect::<Vec<_>>();
assert_eq!(cookies.len(), 2);
assert_eq!(cookies.len(), 3);
if cookies[0] == first_cookie {
assert_eq!(cookies[1], second_cookie);
} else {