RestTemplate with InputStreamResource does not work if Content-Length is not set [SPR-12017] #16633
Labels
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Milestone
John Mark opened SPR-12017 and commented
When using an InputStreamResource to upload a file for example
This causes a strange exception to be thrown: IllegalStateException: InputStream has already been read....
Looking through the code it appears that what is occurring is when AbstractResource.contentLength() is called, it actually reads the entire InputStream. This makes it impossible to use InputStreamResource without defining the Content-Length header. It would be nice if this were not the case. Or if this is required for some reason, at least it should be documented so other people don't have to waste time debugging like I had to.
Affects: 3.2.10, 4.0.6
Issue Links:
Referenced from: commits e14aad8, 5342d92, f0bcb77
Backported to: 3.2.11
The text was updated successfully, but these errors were encountered: