fix(json-lines): Respect default body limit (#3591)

This commit is contained in:
Jan
2025-12-27 15:31:50 +01:00
committed by Jonas Platte
parent 4e2bc8c92a
commit 6b0089190c
2 changed files with 8 additions and 2 deletions
+6
View File
@@ -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.
+2 -2
View File
@@ -4,7 +4,7 @@ use axum_core::{
body::Body,
extract::{FromRequest, Request},
response::{IntoResponse, Response},
BoxError,
BoxError, RequestExt,
};
use bytes::{BufMut, BytesMut};
use futures_util::stream::{BoxStream, Stream, TryStream, TryStreamExt};
@@ -108,7 +108,7 @@ where
async fn from_request(req: Request, _state: &S) -> Result<Self, Self::Rejection> {
// `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);