Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ContentLengthLimit #1400

Merged
merged 15 commits into from Sep 24, 2022
10 changes: 10 additions & 0 deletions axum-core/src/extract/request_parts.rs
Expand Up @@ -94,6 +94,16 @@ where
.await
.map_err(FailedToBufferBody::from_err)?,
Some(DefaultBodyLimitKind::Limit(limit)) => {
let content_length: usize = req
.headers()
.get(http::header::CONTENT_LENGTH)
.and_then(|val| val.to_str().ok()?.parse().ok())
.unwrap();

if content_length > limit {
todo!()
}
nylonicious marked this conversation as resolved.
Show resolved Hide resolved

let body = http_body::Limited::new(req.into_body(), limit);
crate::body::to_bytes(body)
.await
Expand Down
274 changes: 0 additions & 274 deletions axum/src/extract/content_length_limit.rs

This file was deleted.

2 changes: 0 additions & 2 deletions axum/src/extract/mod.rs
Expand Up @@ -9,7 +9,6 @@ pub mod rejection;
#[cfg(feature = "ws")]
pub mod ws;

mod content_length_limit;
mod host;
mod raw_query;
mod request_parts;
Expand All @@ -25,7 +24,6 @@ pub use axum_macros::{FromRequest, FromRequestParts};
#[allow(deprecated)]
pub use self::{
connect_info::ConnectInfo,
content_length_limit::ContentLengthLimit,
host::Host,
path::Path,
raw_query::RawQuery,
Expand Down
2 changes: 1 addition & 1 deletion axum/src/extract/multipart.rs
Expand Up @@ -49,7 +49,7 @@ use std::{
/// ```
///
/// For security reasons it's recommended to combine this with
/// [`ContentLengthLimit`](super::ContentLengthLimit) to limit the size of the request payload.
/// [`DefaultBodyLimit`](super::DefaultBodyLimit) to limit the size of the request payload.
nylonicious marked this conversation as resolved.
Show resolved Hide resolved
#[cfg_attr(docsrs, doc(cfg(feature = "multipart")))]
#[derive(Debug)]
pub struct Multipart {
Expand Down