le.com", entity); or
HttpEntity<String> entity = template.getForEntity("http://example.com", String.class); String body = entity.getBody(); MediaType contentType = entity.getHeaders().getContentType();
Can also be used in Spring MVC, as a return value from a @Controller method:
@RequestMapping("/handle") public HttpEntity<String> handle() { HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.set("MyResponseHeader", "MyValue"); return new HttpEntity<String>("Hello World", responseHeaders); }
@author Arjen Poutsma
@since 3.0.2
@see org.springframework.web.client.RestTemplate
@see #getBody()
@see #getHeaders()