1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-16 21:26:34 +00:00

update changelog

This commit is contained in:
Rob Ede 2021-12-07 21:26:28 +00:00
parent d5ad250193
commit d7a1b434cb
No known key found for this signature in database
GPG key ID: 97C636207D3EF933
6 changed files with 23 additions and 15 deletions

View file

@ -8,7 +8,7 @@
* `HttpResponse::map_into_{left,right}_body` and `HttpResponse::map_into_boxed_body`. [#2468]
* `ServiceResponse::map_into_{left,right}_body` and `HttpResponse::map_into_boxed_body`. [#2468]
* Connection data set through the `HttpServer::on_connect` callback is now accessible only from the new `HttpRequest::conn_data()` and `ServiceRequest::conn_data()` methods. [#2491]
* `impl Clone` for `RequestHead`. [#2487]
* `HttpRequest::{req_data,req_data_mut}`. [#2487]
### Changed
* Rename `Accept::{mime_precedence => ranked}`. [#2480]
@ -24,6 +24,9 @@
* Re-exports `dev::{BodySize, MessageBody, SizedStream}`. They are exposed through the `body` module. [#2468]
* Typed headers containing lists that require one or more items now enforce this minimum. [#2482]
### Removed
* `ConnectionInfo::get`. [#2487]
[#2430]: https://github.com/actix/actix-web/pull/2430
[#2468]: https://github.com/actix/actix-web/pull/2468
[#2480]: https://github.com/actix/actix-web/pull/2480

View file

@ -16,6 +16,8 @@
* `impl Display` for `header::Quality`. [#2486]
* Connection data set through the `on_connect_ext` callbacks is now accessible only from the new `Request::conn_data()` method. [#2491]
* `Request::take_conn_data()`. [#2491]
* `Request::take_req_data()`. [#2487]
* `impl Clone` for `RequestHead`. [#2487]
### Changed
* Rename `body::BoxBody::{from_body => new}`. [#2468]
@ -40,6 +42,7 @@
[#2468]: https://github.com/actix/actix-web/pull/2468
[#1920]: https://github.com/actix/actix-web/pull/1920
[#2486]: https://github.com/actix/actix-web/pull/2486
[#2487]: https://github.com/actix/actix-web/pull/2487
[#2488]: https://github.com/actix/actix-web/pull/2488
[#2491]: https://github.com/actix/actix-web/pull/2491

View file

@ -19,8 +19,7 @@ impl Extensions {
#[inline]
pub fn new() -> Extensions {
Extensions {
map: AHashMap::with_capacity(2),
// map: AHashMap::new(),
map: AHashMap::new(),
}
}

View file

@ -2,7 +2,7 @@
use std::{
cell::{Ref, RefCell, RefMut},
fmt, net,
fmt, mem, net,
rc::Rc,
str,
};
@ -22,7 +22,7 @@ pub struct Request<P = PayloadStream> {
pub(crate) payload: Payload<P>,
pub(crate) head: Message<RequestHead>,
pub(crate) conn_data: Option<Rc<Extensions>>,
pub req_data: RefCell<Extensions>,
pub(crate) req_data: RefCell<Extensions>,
}
impl<P> HttpMessage for Request<P> {
@ -34,7 +34,7 @@ impl<P> HttpMessage for Request<P> {
}
fn take_payload(&mut self) -> Payload<P> {
std::mem::replace(&mut self.payload, Payload::None)
mem::replace(&mut self.payload, Payload::None)
}
/// Request extensions
@ -55,7 +55,7 @@ impl From<Message<RequestHead>> for Request<PayloadStream> {
Request {
head,
payload: Payload::None,
req_data: RefCell::new(Extensions::new()),
req_data: RefCell::new(Extensions::default()),
conn_data: None,
}
}
@ -67,7 +67,7 @@ impl Request<PayloadStream> {
Request {
head: Message::new(),
payload: Payload::None,
req_data: RefCell::new(Extensions::new()),
req_data: RefCell::new(Extensions::default()),
conn_data: None,
}
}
@ -79,7 +79,7 @@ impl<P> Request<P> {
Request {
payload,
head: Message::new(),
req_data: RefCell::new(Extensions::new()),
req_data: RefCell::new(Extensions::default()),
conn_data: None,
}
}
@ -106,7 +106,7 @@ impl<P> Request<P> {
/// Get request's payload
pub fn take_payload(&mut self) -> Payload<P> {
std::mem::replace(&mut self.payload, Payload::None)
mem::replace(&mut self.payload, Payload::None)
}
/// Split request into request head and payload
@ -203,6 +203,11 @@ impl<P> Request<P> {
pub fn take_conn_data(&mut self) -> Option<Rc<Extensions>> {
self.conn_data.take()
}
/// Returns the request data container, leaving an empty one in it's place.
pub fn take_req_data(&mut self) -> Extensions {
mem::take(&mut self.req_data.get_mut())
}
}
impl<P> fmt::Debug for Request<P> {

View file

@ -198,7 +198,7 @@ where
actix_service::forward_ready!(service);
fn call(&self, mut req: Request) -> Self::Future {
let req_data = Rc::new(RefCell::new(req.req_data.take()));
let req_data = Rc::new(RefCell::new(req.take_req_data()));
let conn_data = req.take_conn_data();
let (head, payload) = req.into_parts();

View file

@ -325,18 +325,15 @@ impl HttpMessage for HttpRequest {
type Stream = ();
#[inline]
/// Returns Request's headers.
fn headers(&self) -> &HeaderMap {
&self.head().headers
}
/// Request extensions
#[inline]
fn extensions(&self) -> Ref<'_, Extensions> {
self.req_data()
}
/// Mutable reference to a the request's extensions
#[inline]
fn extensions_mut(&self) -> RefMut<'_, Extensions> {
self.req_data_mut()
@ -358,7 +355,8 @@ impl Drop for HttpRequest {
// clear additional app_data and keep the root one for reuse.
inner.app_data.truncate(1);
// inner is borrowed mut here; get req data mutably to reduce borrow check
// Inner is borrowed mut here and; get req data mutably to reduce borrow check. Also
// we know the req_data Rc will not have any cloned at this point to unwrap is okay.
Rc::get_mut(&mut inner.req_data).unwrap().get_mut().clear();
// a re-borrow of pool is necessary here.