1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-09-05 18:41:00 +00:00

fix: Respond with HTTP code 413, when request size is too big

This commit is contained in:
Jakub Pieńkowski 2025-07-04 08:51:15 +00:00
parent c23c15e512
commit 1b32cfe955
2 changed files with 4 additions and 2 deletions

View file

@ -152,6 +152,7 @@ tikv-jemallocator = { version = "0.6", features = [
], optional = true }
sd-notify = { version = "0.4", optional = true }
# Used for inspecting request errors
http-body-util = "0.1.3"
# Used for matrix spec type definitions and helpers

View file

@ -1,4 +1,5 @@
use std::{collections::BTreeMap, iter::FromIterator, str};
use std::error::Error as _;
use axum::{
body::Body,
@ -60,9 +61,9 @@ where
)
.await
.map_err(|err| {
if std::error::Error::source(&err)
if err.source()
.as_ref()
.and_then(|err| std::error::Error::source(err))
.and_then(|err| err.source())
.is_some_and(|err| err.is::<http_body_util::LengthLimitError>())
{
Error::BadRequest(ErrorKind::TooLarge, "Reached maximum request size")