Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-7498

ResponseEntity headers do not show cookie

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 3.0.2
    • Fix Version/s: None
    • Component/s: Test
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      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 
      

        Attachments

          Activity

            People

            • Assignee:
              arjen.poutsma Arjen Poutsma
              Reporter:
              praveenkg praveenkumar kg
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                7 years, 34 weeks, 1 day ago