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

This commit is contained in:
Jan
2025-12-22 20:24:59 +01:00
committed by GitHub
parent fd57d871aa
commit e1ed2f189c
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_core::{stream::BoxStream, Stream, TryStream};
@@ -109,7 +109,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);