mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-30 10:42:55 +01:00
remove payload unwindsafe impl assert
This commit is contained in:
parent
de9e41484a
commit
56b9c0d08e
@ -263,10 +263,8 @@ mod tests {
|
|||||||
assert_not_impl_any!(Payload: Send, Sync, UnwindSafe, RefUnwindSafe);
|
assert_not_impl_any!(Payload: Send, Sync, UnwindSafe, RefUnwindSafe);
|
||||||
|
|
||||||
assert_impl_all!(Inner: Unpin, Send, Sync);
|
assert_impl_all!(Inner: Unpin, Send, Sync);
|
||||||
#[rustversion::before(1.60)]
|
// assertion not stable wrt rustc versions yet
|
||||||
assert_not_impl_any!(Inner: UnwindSafe, RefUnwindSafe);
|
// assert_impl_all!(Inner: UnwindSafe, RefUnwindSafe);
|
||||||
#[rustversion::since(1.60)]
|
|
||||||
assert_impl_all!(Inner: UnwindSafe, RefUnwindSafe);
|
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_unread_data() {
|
async fn test_unread_data() {
|
||||||
|
@ -20,7 +20,7 @@ use crate::{
|
|||||||
/// Stream that reads request line by line.
|
/// Stream that reads request line by line.
|
||||||
pub struct Readlines<T: HttpMessage> {
|
pub struct Readlines<T: HttpMessage> {
|
||||||
stream: Payload<T::Stream>,
|
stream: Payload<T::Stream>,
|
||||||
buff: BytesMut,
|
buf: BytesMut,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
checked_buff: bool,
|
checked_buff: bool,
|
||||||
encoding: &'static Encoding,
|
encoding: &'static Encoding,
|
||||||
@ -41,7 +41,7 @@ where
|
|||||||
|
|
||||||
Readlines {
|
Readlines {
|
||||||
stream: req.take_payload(),
|
stream: req.take_payload(),
|
||||||
buff: BytesMut::with_capacity(262_144),
|
buf: BytesMut::with_capacity(262_144),
|
||||||
limit: 262_144,
|
limit: 262_144,
|
||||||
checked_buff: true,
|
checked_buff: true,
|
||||||
err: None,
|
err: None,
|
||||||
@ -58,7 +58,7 @@ where
|
|||||||
fn err(err: ReadlinesError) -> Self {
|
fn err(err: ReadlinesError) -> Self {
|
||||||
Readlines {
|
Readlines {
|
||||||
stream: Payload::None,
|
stream: Payload::None,
|
||||||
buff: BytesMut::new(),
|
buf: BytesMut::new(),
|
||||||
limit: 262_144,
|
limit: 262_144,
|
||||||
checked_buff: true,
|
checked_buff: true,
|
||||||
encoding: UTF_8,
|
encoding: UTF_8,
|
||||||
@ -84,7 +84,7 @@ where
|
|||||||
// check if there is a newline in the buffer
|
// check if there is a newline in the buffer
|
||||||
if !this.checked_buff {
|
if !this.checked_buff {
|
||||||
let mut found: Option<usize> = None;
|
let mut found: Option<usize> = None;
|
||||||
for (ind, b) in this.buff.iter().enumerate() {
|
for (ind, b) in this.buf.iter().enumerate() {
|
||||||
if *b == b'\n' {
|
if *b == b'\n' {
|
||||||
found = Some(ind);
|
found = Some(ind);
|
||||||
break;
|
break;
|
||||||
@ -96,13 +96,13 @@ where
|
|||||||
return Poll::Ready(Some(Err(ReadlinesError::LimitOverflow)));
|
return Poll::Ready(Some(Err(ReadlinesError::LimitOverflow)));
|
||||||
}
|
}
|
||||||
let line = if this.encoding == UTF_8 {
|
let line = if this.encoding == UTF_8 {
|
||||||
str::from_utf8(&this.buff.split_to(ind + 1))
|
str::from_utf8(&this.buf.split_to(ind + 1))
|
||||||
.map_err(|_| ReadlinesError::EncodingError)?
|
.map_err(|_| ReadlinesError::EncodingError)?
|
||||||
.to_owned()
|
.to_owned()
|
||||||
} else {
|
} else {
|
||||||
this.encoding
|
this.encoding
|
||||||
.decode_without_bom_handling_and_without_replacement(
|
.decode_without_bom_handling_and_without_replacement(
|
||||||
&this.buff.split_to(ind + 1),
|
&this.buf.split_to(ind + 1),
|
||||||
)
|
)
|
||||||
.map(Cow::into_owned)
|
.map(Cow::into_owned)
|
||||||
.ok_or(ReadlinesError::EncodingError)?
|
.ok_or(ReadlinesError::EncodingError)?
|
||||||
@ -141,32 +141,32 @@ where
|
|||||||
.ok_or(ReadlinesError::EncodingError)?
|
.ok_or(ReadlinesError::EncodingError)?
|
||||||
};
|
};
|
||||||
// extend buffer with rest of the bytes;
|
// extend buffer with rest of the bytes;
|
||||||
this.buff.extend_from_slice(&bytes);
|
this.buf.extend_from_slice(&bytes);
|
||||||
this.checked_buff = false;
|
this.checked_buff = false;
|
||||||
return Poll::Ready(Some(Ok(line)));
|
return Poll::Ready(Some(Ok(line)));
|
||||||
}
|
}
|
||||||
this.buff.extend_from_slice(&bytes);
|
this.buf.extend_from_slice(&bytes);
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
|
|
||||||
None => {
|
None => {
|
||||||
if this.buff.is_empty() {
|
if this.buf.is_empty() {
|
||||||
return Poll::Ready(None);
|
return Poll::Ready(None);
|
||||||
}
|
}
|
||||||
if this.buff.len() > this.limit {
|
if this.buf.len() > this.limit {
|
||||||
return Poll::Ready(Some(Err(ReadlinesError::LimitOverflow)));
|
return Poll::Ready(Some(Err(ReadlinesError::LimitOverflow)));
|
||||||
}
|
}
|
||||||
let line = if this.encoding == UTF_8 {
|
let line = if this.encoding == UTF_8 {
|
||||||
str::from_utf8(&this.buff)
|
str::from_utf8(&this.buf)
|
||||||
.map_err(|_| ReadlinesError::EncodingError)?
|
.map_err(|_| ReadlinesError::EncodingError)?
|
||||||
.to_owned()
|
.to_owned()
|
||||||
} else {
|
} else {
|
||||||
this.encoding
|
this.encoding
|
||||||
.decode_without_bom_handling_and_without_replacement(&this.buff)
|
.decode_without_bom_handling_and_without_replacement(&this.buf)
|
||||||
.map(Cow::into_owned)
|
.map(Cow::into_owned)
|
||||||
.ok_or(ReadlinesError::EncodingError)?
|
.ok_or(ReadlinesError::EncodingError)?
|
||||||
};
|
};
|
||||||
this.buff.clear();
|
this.buf.clear();
|
||||||
Poll::Ready(Some(Ok(line)))
|
Poll::Ready(Some(Ok(line)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user