I recently ran into a problem when I needed to make a GET request to a remote service (using the simple servlet that I assume), and RestTemplate returned Too many redirects! .
After some investigation, it seems that the first request made to the specified remote service is actually a 302 redirect (for itself) with some Set-Cookie headers. If I used a "normal" browser, it would confirm the header, set the cookies correctly and redirect where it should correspond to the normal 200 response.
I found that RestTemplate does not accept the Set-Cookie header, so the redirect is done over and over again.
Is there a way to get RestTemplate to accept the Set-Cookie header for the current request only? I prefer that it does not support state, since RestTemplate is also used from other parts of the system.
Hi
source share