|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -23,12 +23,12 @@ import org.springframework.util.ObjectUtils;
@@ -23,12 +23,12 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
|
/** |
|
|
|
|
* Represents an HTTP request or response entity, consisting of headers and body. |
|
|
|
|
* |
|
|
|
|
* <p>Typically used in combination with the {@link org.springframework.web.client.RestTemplate}, |
|
|
|
|
* <p>Often used in combination with the {@link org.springframework.web.client.RestTemplate}, |
|
|
|
|
* like so: |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* HttpHeaders headers = new HttpHeaders(); |
|
|
|
|
* headers.setContentType(MediaType.TEXT_PLAIN); |
|
|
|
|
* HttpEntity<String> entity = new HttpEntity<String>(helloWorld, headers); |
|
|
|
|
* HttpEntity<String> entity = new HttpEntity<>("Hello World", headers); |
|
|
|
|
* URI location = template.postForLocation("https://example.com", entity); |
|
|
|
|
* </pre> |
|
|
|
|
* or |
|
|
|
@ -39,11 +39,11 @@ import org.springframework.util.ObjectUtils;
@@ -39,11 +39,11 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
|
* </pre> |
|
|
|
|
* Can also be used in Spring MVC, as a return value from a @Controller method: |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* @RequestMapping("/handle") |
|
|
|
|
* @GetMapping("/handle") |
|
|
|
|
* public HttpEntity<String> handle() { |
|
|
|
|
* HttpHeaders responseHeaders = new HttpHeaders(); |
|
|
|
|
* responseHeaders.set("MyResponseHeader", "MyValue"); |
|
|
|
|
* return new HttpEntity<String>("Hello World", responseHeaders); |
|
|
|
|
* return new HttpEntity<>("Hello World", responseHeaders); |
|
|
|
|
* } |
|
|
|
|
* </pre> |
|
|
|
|
* |
|
|
|
|