mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-26 02:19:22 +02:00
fix limit usage for Request/Response Body future
This commit is contained in:
@ -25,9 +25,12 @@ use server::IoStream;
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
/// `Connect` type represents message that can be send to `ClientConnector`
|
||||
/// with connection request.
|
||||
pub struct Connect(pub Uri);
|
||||
|
||||
impl Connect {
|
||||
/// Create `Connect` message for specified `Uri`
|
||||
pub fn new<U>(uri: U) -> Result<Connect, HttpError> where Uri: HttpTryFrom<U> {
|
||||
Ok(Connect(Uri::try_from(uri).map_err(|e| e.into())?))
|
||||
}
|
||||
@ -38,6 +41,7 @@ impl ResponseType for Connect {
|
||||
type Error = ClientConnectorError;
|
||||
}
|
||||
|
||||
/// A set of errors that can occur during connecting to a http host
|
||||
#[derive(Fail, Debug)]
|
||||
pub enum ClientConnectorError {
|
||||
/// Invalid url
|
||||
|
@ -6,6 +6,6 @@ mod writer;
|
||||
|
||||
pub(crate) use self::writer::HttpClientWriter;
|
||||
pub use self::request::{ClientRequest, ClientRequestBuilder};
|
||||
pub use self::response::ClientResponse;
|
||||
pub use self::parser::{HttpResponseParser, HttpResponseParserError};
|
||||
pub use self::response::{ClientResponse, JsonResponse};
|
||||
pub(crate) use self::parser::{HttpResponseParser, HttpResponseParserError};
|
||||
pub use self::connect::{Connect, Connection, ClientConnector, ClientConnectorError};
|
||||
|
@ -170,7 +170,7 @@ impl fmt::Debug for ClientRequest {
|
||||
}
|
||||
|
||||
|
||||
/// An HTTP client request builder
|
||||
/// An HTTP Client request builder
|
||||
///
|
||||
/// This type can be used to construct an instance of `ClientRequest` through a
|
||||
/// builder-like pattern.
|
||||
|
@ -39,6 +39,7 @@ impl Default for ClientMessage {
|
||||
}
|
||||
}
|
||||
|
||||
/// An HTTP Client response
|
||||
pub struct ClientResponse(Rc<UnsafeCell<ClientMessage>>);
|
||||
|
||||
impl ClientResponse {
|
||||
@ -288,8 +289,8 @@ impl Future for ResponseBody {
|
||||
if let Some(resp) = self.resp.take() {
|
||||
if let Some(len) = resp.headers().get(header::CONTENT_LENGTH) {
|
||||
if let Ok(s) = len.to_str() {
|
||||
if let Ok(len) = s.parse::<u64>() {
|
||||
if len > 262_144 {
|
||||
if let Ok(len) = s.parse::<usize>() {
|
||||
if len > self.limit {
|
||||
return Err(PayloadError::Overflow);
|
||||
}
|
||||
} else {
|
||||
@ -321,7 +322,7 @@ impl Future for ResponseBody {
|
||||
}
|
||||
}
|
||||
|
||||
/// Client response payload json parser that resolves to a deserialized `T` value.
|
||||
/// Client response json parser that resolves to a deserialized `T` value.
|
||||
///
|
||||
/// Returns error:
|
||||
///
|
||||
|
Reference in New Issue
Block a user