Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Content-Length for optimal read to byte[]
If content-length is available, pass it to readNBytes in ByteArrayHttpMessageConverter. When the content length is less than the internal buffer size in InputStream (8192), this avoids a copy, as readNBytes will return the buffer directly. When the content length is greater than the buffer size used in InputStream, passing the content-length at least avoids over-allocating the final buffer (e.g., if the content length were 8193 bytes, 1 byte more than the default buffer size). If the content length isn't present or is too large to represent as an integer, fall back to the default behavior of readAllBytes by passing in Integer.MAX_VALUE. See gh-30010
- Loading branch information