Package private request and response implementations
Concrete server and client, reactive request and response implementations should not have to be accessed outside their package. They could be seen as private to their HttpHandler adapters and ClientHttpConnector's respectively. The one exception, WebSocket upgrades in spring-webflux, is an internal framework use case, accommodated via downcast + accessors in the abstract base classes.
This commit is contained in:
@@ -43,7 +43,7 @@ import org.springframework.util.MultiValueMap;
|
||||
* @author Stephane Maldini
|
||||
* @since 5.0
|
||||
*/
|
||||
public class RxNettyServerHttpRequest extends AbstractServerHttpRequest {
|
||||
class RxNettyServerHttpRequest extends AbstractServerHttpRequest {
|
||||
|
||||
private final HttpServerRequest<ByteBuf> request;
|
||||
|
||||
@@ -88,10 +88,6 @@ public class RxNettyServerHttpRequest extends AbstractServerHttpRequest {
|
||||
}
|
||||
|
||||
|
||||
public HttpServerRequest<ByteBuf> getRxNettyRequest() {
|
||||
return this.request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodValue() {
|
||||
return this.request.getHttpMethod().name();
|
||||
@@ -120,4 +116,9 @@ public class RxNettyServerHttpRequest extends AbstractServerHttpRequest {
|
||||
return Flux.from(RxReactiveStreams.toPublisher(content));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getNativeRequest() {
|
||||
return (T) this.request;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.springframework.util.Assert;
|
||||
* @author Sebastien Deleuze
|
||||
* @since 5.0
|
||||
*/
|
||||
public class RxNettyServerHttpResponse extends AbstractServerHttpResponse {
|
||||
class RxNettyServerHttpResponse extends AbstractServerHttpResponse {
|
||||
|
||||
private static final ByteBuf FLUSH_SIGNAL = Unpooled.buffer(0, 0);
|
||||
|
||||
@@ -63,8 +63,10 @@ public class RxNettyServerHttpResponse extends AbstractServerHttpResponse {
|
||||
}
|
||||
|
||||
|
||||
public HttpServerResponse<?> getRxNettyResponse() {
|
||||
return this.response;
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getNativeResponse() {
|
||||
return (T) this.response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,7 +32,9 @@ import org.springframework.core.io.buffer.DefaultDataBufferFactory;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
/**
|
||||
* @author Rossen Stoyanchev
|
||||
@@ -152,6 +154,11 @@ public class ServerHttpResponseTests {
|
||||
super(new DefaultDataBufferFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getNativeResponse() {
|
||||
throw new IllegalStateException("This is a mock. No running server, no native response.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyStatusCode() {
|
||||
assertFalse(this.statusCodeWritten);
|
||||
|
||||
@@ -102,6 +102,11 @@ public class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
return this.cookies;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getNativeRequest() {
|
||||
throw new IllegalStateException("This is a mock. No running server, no native request.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shortcut to wrap the request with a {@code MockServerWebExchange}.
|
||||
|
||||
@@ -76,6 +76,11 @@ public class MockServerHttpResponse extends AbstractServerHttpResponse {
|
||||
this.writeHandler = writeHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getNativeResponse() {
|
||||
throw new IllegalStateException("This is a mock. No running server, no native response.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void applyStatusCode() {
|
||||
|
||||
Reference in New Issue
Block a user