|
|
@ -18,6 +18,7 @@ package org.springframework.mock.http.server.reactive; |
|
|
|
|
|
|
|
|
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.function.Supplier; |
|
|
|
import java.util.function.Supplier; |
|
|
|
|
|
|
|
|
|
|
|
import org.reactivestreams.Publisher; |
|
|
|
import org.reactivestreams.Publisher; |
|
|
@ -56,6 +57,8 @@ public class MockServerHttpResponse implements ServerHttpResponse { |
|
|
|
|
|
|
|
|
|
|
|
private DataBufferFactory bufferFactory = new DefaultDataBufferFactory(); |
|
|
|
private DataBufferFactory bufferFactory = new DefaultDataBufferFactory(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Function<String, String> urlEncoder = url -> url; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean setStatusCode(HttpStatus status) { |
|
|
|
public boolean setStatusCode(HttpStatus status) { |
|
|
@ -111,6 +114,16 @@ public class MockServerHttpResponse implements ServerHttpResponse { |
|
|
|
return this.bufferFactory; |
|
|
|
return this.bufferFactory; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String encodeUrl(String url) { |
|
|
|
|
|
|
|
return (this.urlEncoder != null ? this.urlEncoder.apply(url) : url); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void registerUrlEncoder(Function<String, String> encoder) { |
|
|
|
|
|
|
|
this.urlEncoder = (this.urlEncoder != null ? this.urlEncoder.andThen(encoder) : encoder); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the body of the response aggregated and converted to a String |
|
|
|
* Return the body of the response aggregated and converted to a String |
|
|
|
* using the charset of the Content-Type response or otherwise defaulting |
|
|
|
* using the charset of the Content-Type response or otherwise defaulting |
|
|
|