1

I'm sending a request ro a service that set a cookie in the response :

HttpEntity<String> response = restTemplate.exchange
                (myUrl,
                        HttpMethod.GET,
                        new HttpEntity<>(headers),
                        String.class);

I found that I can extract the cookie using this line of code :

String set_cookie = response.getHeaders().getFirst(HttpHeaders.SET_COOKIE);

However this returns: name_of_cookie=value_of_cookie

I know that I can make a String processing to extract the value of the cookie by name, but I want to find a better solution in the manner of :

response.getHeaders().getCookieValueByName(cookie_name)

The getCookieValueByName function do not exsist. Is there a function that does what I want to do ?

Mohamed Taboubi
  • 6,663
  • 11
  • 55
  • 87

0 Answers0