@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2018 the original author or authors .
* Copyright 2002 - 2019 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 .
@ -20,6 +20,7 @@ import java.net.URI;
@@ -20,6 +20,7 @@ import java.net.URI;
import java.time.Instant ;
import java.time.ZonedDateTime ;
import java.util.Arrays ;
import java.util.Collections ;
import java.util.EnumSet ;
import java.util.HashMap ;
import java.util.LinkedHashSet ;
@ -73,9 +74,16 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
@@ -73,9 +74,16 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
public DefaultServerResponseBuilder ( ServerResponse other ) {
Assert . notNull ( other , "ServerResponse must not be null" ) ;
this . statusCode = ( other instanceof AbstractServerResponse ?
( ( AbstractServerResponse ) other ) . statusCode : other . statusCode ( ) . value ( ) ) ;
this . headers . addAll ( other . headers ( ) ) ;
this . cookies . addAll ( other . cookies ( ) ) ;
if ( other instanceof AbstractServerResponse ) {
AbstractServerResponse abstractOther = ( AbstractServerResponse ) other ;
this . statusCode = abstractOther . statusCode ;
this . hints . putAll ( abstractOther . hints ) ;
}
else {
this . statusCode = other . statusCode ( ) . value ( ) ;
}
}
public DefaultServerResponseBuilder ( HttpStatus status ) {
@ -289,12 +297,17 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
@@ -289,12 +297,17 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
private final MultiValueMap < String , ResponseCookie > cookies ;
final Map < String , Object > hints ;
protected AbstractServerResponse (
int statusCode , HttpHeaders headers , MultiValueMap < String , ResponseCookie > cookies ) {
int statusCode , HttpHeaders headers , MultiValueMap < String , ResponseCookie > cookies ,
Map < String , Object > hints ) {
this . statusCode = statusCode ;
this . headers = HttpHeaders . readOnlyHttpHeaders ( headers ) ;
this . cookies = CollectionUtils . unmodifiableMultiValueMap ( new LinkedMultiValueMap < > ( cookies ) ) ;
this . hints = hints ;
}
@Override
@ -361,7 +374,7 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
@@ -361,7 +374,7 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
MultiValueMap < String , ResponseCookie > cookies ,
BiFunction < ServerWebExchange , Context , Mono < Void > > writeFunction ) {
super ( statusCode , headers , cookies ) ;
super ( statusCode , headers , cookies , Collections . emptyMap ( ) ) ;
Assert . notNull ( writeFunction , "BiFunction must not be null" ) ;
this . writeFunction = writeFunction ;
}
@ -377,16 +390,14 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
@@ -377,16 +390,14 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
private final BodyInserter < T , ? super ServerHttpResponse > inserter ;
private final Map < String , Object > hints ;
public BodyInserterResponse ( int statusCode , HttpHeaders headers ,
MultiValueMap < String , ResponseCookie > cookies ,
BodyInserter < T , ? super ServerHttpResponse > body , Map < String , Object > hints ) {
super ( statusCode , headers , cookies ) ;
super ( statusCode , headers , cookies , hints ) ;
Assert . notNull ( body , "BodyInserter must not be null" ) ;
this . inserter = body ;
this . hints = hints ;
}
@Override