Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

addHeader and getHeaders

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to know how a new value is added to a header of a response.

For example:



Is it added after coma like:

//case1:
Content-Encoding: gzip, deflate

or

//case2:
Content-Encoding: gzip
Content-Encoding: deflate

Is getHeaders() [from HttpServletRequest] used to get values from case 1 or case 2?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody help?
 
Ankit Garg
Sheriff
Posts: 9579
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read somewhere that for HTTP headers, that support multiple values, the values are added as comma separated values. And for headers that don't support multiple values, multiple headers are added i.e. case 2. Still I'll have to verify it by making a sample program and monitoring the headers...
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, thanks for an effort!
 
Vaib Gupta
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Request.getHeaders(String) returns an Enumeration. So I think it should return the values as individual strings. However I have one basic doubt. Suppose I define a custom header say 'demoHeader' and set it in response like this:

response.addHeader('demoHeader', 'demoValue')

Now from where can I read this header value? The header will remain till the response has been sent to the browser. The subsequent request will not contain this header. This scenario might not have any significance in real life but I'm just curious...
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot get a header from response. You and the container set them so you should know them
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic