PDA

View Full Version : HTTP Header



Marc.L
Jan 7th, 2011, 03:44 AM
Hi @all,

is there a possibilty to add http header informations to a get request?

Thanks for any advice!

dutchman_mn
Jan 10th, 2011, 08:47 AM
Yes, but not easily. As I understand it, RestTemplate won't have access to the HTTP headers until Spring 3.1

In the meantime, I would point you at Christian Tzolov's workaround that is found here: http://tzolov.blogspot.com/2010/03/spring-3-resttemplate-access-to-request.html

Perry Hoekstra

Marc.L
Jan 10th, 2011, 03:01 PM
thanks for the advice. I found out another solution that seems to work:


RestTemplate template = new RestTemplateWrapper(requestFactory);
URI url = new URI("URI");
HttpEntity<Object> entity = new HttpEntity<Object>(MultiValueMap headerinfo);
ResponseEntity<String> result = template.exchange(url, HttpMethod.GET, entity, String.class);