You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide a way to read an InputStream with RestTemplate [SPR-7357] #12015
You can already read an InputStream by using the execute() method on the RestTemplate in combination with a ResponseExtractor implementation, see here.
Note that you cannot simply return the InputStream from the extractor, because by the time the execute method returns, the underlying connection and stream are already closed.
But I'm using an exchange() call in order to set an HTTP header with HttpEntity before sending a request.
Seems like I can't get to InputStream in this case, is that correct?
Yes, it worked! I now use RestTemplate for all requests.
Note that you cannot simply return the InputStream from the extractor, because by the time the execute method returns, the underlying connection and stream are already closed
That was important. Indeed, I could only read an InputStream inside ResponseExtractor.extractData ( ClientHttpResponse )
Evgeny Goldin I also wonder why? Could you explain, please? Or send a link where it is already explained. It is very important not to fully read it in memory.
Activity
spring-projects-issues commentedon Jul 6, 2010
Arjen Poutsma commented
You can already read an InputStream by using the execute() method on the RestTemplate in combination with a ResponseExtractor implementation, see here.
Note that you cannot simply return the InputStream from the extractor, because by the time the execute method returns, the underlying connection and stream are already closed.
spring-projects-issues commentedon Jul 7, 2010
Evgeny Goldin commented
Oh, that's good, thank you.
But I'm using an exchange() call in order to set an HTTP header with HttpEntity before sending a request.
Seems like I can't get to InputStream in this case, is that correct?
spring-projects-issues commentedon Jul 7, 2010
Arjen Poutsma commented
That is correct, but you can, however, get to the HTTP headers from the execute method.
spring-projects-issues commentedon Jul 18, 2010
Evgeny Goldin commented
Yes, it worked! I now use RestTemplate for all requests.
Note that you cannot simply return the InputStream from the extractor, because by the time the execute method returns, the underlying connection and stream are already closed
That was important. Indeed, I could only read an
InputStreaminsideResponseExtractor.extractData ( ClientHttpResponse )Many thanks for your help, Arjen.
spring-projects-issues commentedon Aug 5, 2016
Daniel Dacar commented
Why is the InputStream closed? This forces the client to store the stream in memory or in I/O instead of passing it to other layers for processing.
spring-projects-issues commentedon Oct 26, 2018
Andrey Beletsky commented
Evgeny Goldin I also wonder why? Could you explain, please? Or send a link where it is already explained. It is very important not to fully read it in memory.