|
|
|
|
@ -31,8 +31,8 @@ import org.springframework.util.MultiValueMap;
@@ -31,8 +31,8 @@ import org.springframework.util.MultiValueMap;
|
|
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Extension of {@link HttpEntity} that adds a {@link HttpStatus} status code. |
|
|
|
|
* Used in {@code RestTemplate} as well as {@code @Controller} methods. |
|
|
|
|
* Extension of {@link HttpEntity} that adds an {@link HttpStatus} status code. |
|
|
|
|
* Used in {@code RestTemplate} as well as in {@code @Controller} methods. |
|
|
|
|
* |
|
|
|
|
* <p>In {@code RestTemplate}, this class is returned by |
|
|
|
|
* {@link org.springframework.web.client.RestTemplate#getForEntity getForEntity()} and |
|
|
|
|
@ -44,7 +44,8 @@ import org.springframework.util.ObjectUtils;
@@ -44,7 +44,8 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
|
* HttpStatus statusCode = entity.getStatusCode(); |
|
|
|
|
* </pre> |
|
|
|
|
* |
|
|
|
|
* <p>This can also be used in Spring MVC as the return value from a @Controller method: |
|
|
|
|
* <p>This can also be used in Spring MVC as the return value from an |
|
|
|
|
* {@code @Controller} method: |
|
|
|
|
* <pre class="code"> |
|
|
|
|
* @RequestMapping("/handle") |
|
|
|
|
* public ResponseEntity<String> handle() { |
|
|
|
|
@ -81,7 +82,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
@@ -81,7 +82,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new {@code ResponseEntity} with the given status code, but no body or headers. |
|
|
|
|
* Create an {@code ResponseEntity} with a status code only. |
|
|
|
|
* @param status the status code |
|
|
|
|
*/ |
|
|
|
|
public ResponseEntity(HttpStatus status) { |
|
|
|
|
@ -89,7 +90,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
@@ -89,7 +90,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new {@code ResponseEntity} with the given body and status code, but no headers. |
|
|
|
|
* Create an {@code ResponseEntity} with a body and status code. |
|
|
|
|
* @param body the entity body |
|
|
|
|
* @param status the status code |
|
|
|
|
*/ |
|
|
|
|
@ -98,7 +99,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
@@ -98,7 +99,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new {@code HttpEntity} with the given headers and status code, but no body. |
|
|
|
|
* Create an {@code HttpEntity} with headers and a status code. |
|
|
|
|
* @param headers the entity headers |
|
|
|
|
* @param status the status code |
|
|
|
|
*/ |
|
|
|
|
@ -107,7 +108,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
@@ -107,7 +108,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new {@code HttpEntity} with the given body, headers, and status code. |
|
|
|
|
* Create an {@code HttpEntity} with a body, headers, and a status code. |
|
|
|
|
* @param body the entity body |
|
|
|
|
* @param headers the entity headers |
|
|
|
|
* @param status the status code |
|
|
|
|
@ -117,7 +118,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
@@ -117,7 +118,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new {@code HttpEntity} with the given body, headers, and status code. |
|
|
|
|
* Create an {@code HttpEntity} with a body, headers, and a raw status code. |
|
|
|
|
* @param body the entity body |
|
|
|
|
* @param headers the entity headers |
|
|
|
|
* @param rawStatus the status code value |
|
|
|
|
@ -128,11 +129,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
@@ -128,11 +129,7 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Create a new {@code HttpEntity} with the given body, headers, and status code. |
|
|
|
|
* Just used behind the nested builder API. |
|
|
|
|
* @param body the entity body |
|
|
|
|
* @param headers the entity headers |
|
|
|
|
* @param status the status code (as {@code HttpStatus} or as {@code Integer} value) |
|
|
|
|
* Private constructor. |
|
|
|
|
*/ |
|
|
|
|
private ResponseEntity(@Nullable T body, @Nullable MultiValueMap<String, String> headers, Object status) { |
|
|
|
|
super(body, headers); |
|
|
|
|
|