@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2018 the original author or authors .
* Copyright 2002 - 2020 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 .
@ -27,6 +27,7 @@ import org.springframework.util.MultiValueMap;
@@ -27,6 +27,7 @@ import org.springframework.util.MultiValueMap;
*
* @author Arjen Poutsma
* @author Sebastien Deleuze
* @author Rossen Stoyanchev
* @since 5 . 0
* /
public interface ServerHttpResponse extends ReactiveHttpOutputMessage {
@ -34,21 +35,55 @@ public interface ServerHttpResponse extends ReactiveHttpOutputMessage {
@@ -34,21 +35,55 @@ public interface ServerHttpResponse extends ReactiveHttpOutputMessage {
/ * *
* Set the HTTP status code of the response .
* @param status the HTTP status as an { @link HttpStatus } enum value
* @return { @code false } if the status code has not been set because th e
* HTTP response is already committed , { @code true } if successfully set .
* @return { @code false } if the status code change wasn ' t processed becaus e
* the HTTP response is committed , { @code true } if successfully set .
* /
boolean setStatusCode ( @Nullable HttpStatus status ) ;
/ * *
* Return the status code set via { @link # setStatusCode } , or if the status
* has not been set , return the default status code from the underlying
* server response . The return value may be { @code null } if the status code
* value is outside the { @link HttpStatus } enum range , or if the underlying
* server response does not have a default value .
* Return the status code that has been set , or otherwise fall back on the
* status of the response from the underlying server . The return value may
* be { @code null } if the status code value is outside the
* { @link HttpStatus } enum range , or if there is no default value from the
* underlying server .
* /
@Nullable
HttpStatus getStatusCode ( ) ;
/ * *
* Set the HTTP status code to the given value ( potentially non - standard and
* not resolvable through the { @link HttpStatus } enum ) as an integer .
* @param value the status code value
* @return { @code false } if the status code change wasn ' t processed because
* the HTTP response is committed , { @code true } if successfully set .
* @since 5 . 2 . 4
* /
default boolean setRawStatusCode ( @Nullable Integer value ) {
if ( value = = null ) {
return setStatusCode ( null ) ;
}
else {
HttpStatus httpStatus = HttpStatus . resolve ( value ) ;
if ( httpStatus = = null ) {
throw new IllegalStateException (
"Unresolvable HttpStatus for general ServerHttpResponse: " + value ) ;
}
return setStatusCode ( httpStatus ) ;
}
}
/ * *
* Return the status code that has been set , or otherwise fall back on the
* status of the response from the underlying server . The return value may
* be { @code null } if there is no default value from the underlying server .
* @since 5 . 2 . 4
* /
@Nullable
default Integer getRawStatusCode ( ) {
HttpStatus httpStatus = getStatusCode ( ) ;
return ( httpStatus ! = null ? httpStatus . value ( ) : null ) ;
}
/ * *
* Return a mutable map with the cookies to send to the server .
* /