diff --git a/src/api/ruma_wrapper/axum.rs b/src/api/ruma_wrapper/axum.rs index 2eb2c7f8..04456543 100644 --- a/src/api/ruma_wrapper/axum.rs +++ b/src/api/ruma_wrapper/axum.rs @@ -1,11 +1,10 @@ -use std::{collections::BTreeMap, iter::FromIterator, str}; -use std::error::Error as _; +use std::{collections::BTreeMap, error::Error as _, iter::FromIterator, str}; use axum::{ body::Body, extract::{FromRequest, Path}, response::{IntoResponse, Response}, - RequestExt, RequestPartsExt, + RequestPartsExt, }; use axum_extra::{ headers::{authorization::Bearer, Authorization}, @@ -49,8 +48,7 @@ where } let (mut parts, mut body) = { - let limited_req = req.with_limited_body(); - let (parts, body) = limited_req.into_parts(); + let (parts, body) = req.into_parts(); let body = axum::body::to_bytes( body, services() @@ -61,13 +59,13 @@ where ) .await .map_err(|err| { - if err.source() - .as_ref() - .and_then(|err| err.source()) + if err + .source() .is_some_and(|err| err.is::()) { Error::BadRequest(ErrorKind::TooLarge, "Reached maximum request size") } else { + error!("An unknown error has occurred: {err}"); Error::BadRequest(ErrorKind::Unknown, "An unknown error has occurred") } })?; diff --git a/src/main.rs b/src/main.rs index 4af1162c..b9e34765 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use std::{future::Future, io, net::SocketAddr, sync::atomic, time::Duration}; use axum::{ body::Body, - extract::{DefaultBodyLimit, FromRequestParts, MatchedPath}, + extract::{FromRequestParts, MatchedPath}, middleware::map_response, response::{IntoResponse, Response}, routing::{any, get, on, MethodFilter}, @@ -240,13 +240,7 @@ async fn run_server() -> io::Result<()> { ]) .max_age(Duration::from_secs(86400)), ) - .layer(map_response(set_csp_header)) - .layer(DefaultBodyLimit::max( - config - .max_request_size - .try_into() - .expect("failed to convert max request size"), - )); + .layer(map_response(set_csp_header)); let app = routes(config).layer(middlewares).into_make_service(); let handle = ServerHandle::new();