Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce HttpEntity [SPR-6969] #11634

Closed
spring-projects-issues opened this issue Mar 10, 2010 · 1 comment
Closed

Introduce HttpEntity [SPR-6969] #11634

spring-projects-issues opened this issue Mar 10, 2010 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Mar 10, 2010

Arjen Poutsma opened SPR-6969 and commented

Currently, it's not possible to explicitly set the Content-Type header (or any other header for that matter) for outgoing requests in the RestTemplate. It would be nice to introduce a wrapping HttpEntity type, which allows you to do this, like so:

HttpEntity<String> entity = new HttpEntity<String>(helloWorld, MediaType.TEXT_PLAIN);
URI location = template.postForLocation("http://example.com/", entity);

Additionally, it would be useful to be able to retrieve response headers as part of a GET operation. The HttpEntity can help here as well:

HttpEntity<String> entity = template.getForEntity("http://example.com", String.class);
String body = entity.getBody();
MediaType contentType = entity.getHeaders().getContentType();

Issue Links:

Referenced from: commits 63076d0

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

Complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants