|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -21,6 +21,7 @@ import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.core.NestedExceptionUtils; |
|
|
|
import org.springframework.core.NestedExceptionUtils; |
|
|
|
import org.springframework.core.NestedRuntimeException; |
|
|
|
import org.springframework.core.NestedRuntimeException; |
|
|
|
|
|
|
|
import org.springframework.http.HttpHeaders; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
@ -82,14 +83,33 @@ public class ResponseStatusException extends NestedRuntimeException { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return response headers associated with the exception, possibly required |
|
|
|
* Return headers associated with the exception that should be added to the |
|
|
|
* for the given status code (e.g. "Allow", "Accept"). |
|
|
|
* error response, e.g. "Allow", "Accept", etc. |
|
|
|
|
|
|
|
* <p>The default implementation in this class returns an empty map. |
|
|
|
* @since 5.1.11 |
|
|
|
* @since 5.1.11 |
|
|
|
|
|
|
|
* @deprecated as of 5.1.13 in favor of {@link #getResponseHeaders()} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
public Map<String, String> getHeaders() { |
|
|
|
public Map<String, String> getHeaders() { |
|
|
|
return Collections.emptyMap(); |
|
|
|
return Collections.emptyMap(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Return headers associated with the exception that should be added to the |
|
|
|
|
|
|
|
* error response, e.g. "Allow", "Accept", etc. |
|
|
|
|
|
|
|
* <p>The default implementation in this class returns empty headers. |
|
|
|
|
|
|
|
* @since 5.1.13 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public HttpHeaders getResponseHeaders() { |
|
|
|
|
|
|
|
Map<String, String> headers = getHeaders(); |
|
|
|
|
|
|
|
if (headers.isEmpty()) { |
|
|
|
|
|
|
|
return HttpHeaders.EMPTY; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
HttpHeaders result = new HttpHeaders(); |
|
|
|
|
|
|
|
getHeaders().forEach(result::add); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The reason explaining the exception (potentially {@code null} or empty). |
|
|
|
* The reason explaining the exception (potentially {@code null} or empty). |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|