From e1ed2f189cf98a937f823ee2cac89a69faacf40f Mon Sep 17 00:00:00 2001 From: Jan <59206115+Threated@users.noreply.github.com> Date: Mon, 22 Dec 2025 20:24:59 +0100 Subject: [PATCH] fix(json-lines): Respect default body limit (#3591) --- axum-extra/CHANGELOG.md | 6 ++++++ axum-extra/src/json_lines.rs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/axum-extra/CHANGELOG.md b/axum-extra/CHANGELOG.md index 3c30c566..394ccd00 100644 --- a/axum-extra/CHANGELOG.md +++ b/axum-extra/CHANGELOG.md @@ -1,3 +1,9 @@ +# Unreleased + +- **fixed:** `JsonLines` now correctly respects the default body limit ([#3591]) + +[#3591]: https://github.com/tokio-rs/axum/pull/3591 + # Changelog All notable changes to this project will be documented in this file. diff --git a/axum-extra/src/json_lines.rs b/axum-extra/src/json_lines.rs index 20d1e449..5cb76e33 100644 --- a/axum-extra/src/json_lines.rs +++ b/axum-extra/src/json_lines.rs @@ -4,7 +4,7 @@ use axum_core::{ body::Body, extract::{FromRequest, Request}, response::{IntoResponse, Response}, - BoxError, + BoxError, RequestExt, }; use bytes::{BufMut, BytesMut}; use futures_core::{stream::BoxStream, Stream, TryStream}; @@ -109,7 +109,7 @@ where async fn from_request(req: Request, _state: &S) -> Result { // `Stream::lines` isn't a thing so we have to convert it into an `AsyncRead` // so we can call `AsyncRead::lines` and then convert it back to a `Stream` - let body = req.into_body(); + let body = req.into_limited_body(); let stream = body.into_data_stream(); let stream = stream.map_err(io::Error::other); let read = StreamReader::new(stream);