Skip to content

ResponseEntity headers do not show cookie [SPR-7498] #12156

@spring-projects-issues

Description

@spring-projects-issues

praveenkumar kg opened SPR-7498 and commented

I am using RestTemplate to test my API. Headers from ResponseEntity seems to show only 'Set-Cookie' but for further requests it does not pull up the cookie in the header. Any particular reason why? I verified that response from the server do contain header cookie.

ResponseEntity<String> response = restTemplate.exchange(uri.toString(), HttpMethod.PUT, requestEntity, String.class, new HashMap<String,String>());
			
HttpHeaders headers = response.getHeaders();
Set<String> keys = headers.keySet();
for (String header : keys) 
{
	System.out.println("Header: "+header);
	List<String> values = headers.get(header);
	for (String value : values) 
	{
		System.out.println("Header Value: "+ value);
	}
}

Output showing 'Set-Cookie'

Header: Server
Header Value: Apache-Coyote/1.1
Header: X-Powered-By
Header Value: 
Header: Set-Cookie
Header Value: JSESSIONID=0B66BF319B5D6E236A5F9679F72459F5.dev37; Path=/; Secure
Header: Content-Type
Header Value: application/xml;charset=ISO-8859-1
Header: Content-Language
Header Value: en-US
Header: Content-Length
Header Value: 130
Header: Date
Header Value: Wed, 25 Aug 2010 22:55:16 GMT

Output not showing Cookie in the header:

Header: Server
Header Value: Apache-Coyote/1.1
Header: X-Powered-By
Header Value: 
Header: Content-Type
Header Value: application/xml;charset=ISO-8859-1
Header: Content-Language
Header Value: en-US
Header: Content-Length
Header Value: 655
Header: Date
Header Value: Wed, 25 Aug 2010 23:00:19 GMT 

Affects: 3.0.2

Metadata

Metadata

Assignees

Labels

in: testIssues in the test modulestatus: declinedA suggestion or change that we don't feel we should currently apply

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions