Expose localAddress in WebFlux server
Closes gh-24174
This commit is contained in:
@@ -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.
|
||||
@@ -181,9 +181,6 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
|
||||
|
||||
private final MultiValueMap<String, HttpCookie> cookies;
|
||||
|
||||
@Nullable
|
||||
private final InetSocketAddress remoteAddress;
|
||||
|
||||
@Nullable
|
||||
private final SslInfo sslInfo;
|
||||
|
||||
@@ -199,7 +196,6 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
|
||||
super(uri, contextPath, headers);
|
||||
this.methodValue = methodValue;
|
||||
this.cookies = cookies;
|
||||
this.remoteAddress = originalRequest.getRemoteAddress();
|
||||
this.sslInfo = sslInfo != null ? sslInfo : originalRequest.getSslInfo();
|
||||
this.body = body;
|
||||
this.originalRequest = originalRequest;
|
||||
@@ -218,7 +214,13 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder {
|
||||
@Nullable
|
||||
@Override
|
||||
public InetSocketAddress getRemoteAddress() {
|
||||
return this.remoteAddress;
|
||||
return this.originalRequest.getRemoteAddress();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return this.originalRequest.getLocalAddress();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -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.
|
||||
@@ -151,6 +151,11 @@ class ReactorServerHttpRequest extends AbstractServerHttpRequest {
|
||||
return this.request.remoteAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return this.request.hostAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected SslInfo initSslInfo() {
|
||||
|
||||
@@ -72,6 +72,15 @@ public interface ServerHttpRequest extends HttpRequest, ReactiveHttpInputMessage
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the local address the request was accepted on, if available.
|
||||
* 5.2.3
|
||||
*/
|
||||
@Nullable
|
||||
default InetSocketAddress getLocalAddress() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the SSL session information if the request has been transmitted
|
||||
* over a secure protocol including SSL certificates, if available.
|
||||
|
||||
@@ -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.
|
||||
@@ -101,6 +101,11 @@ public class ServerHttpRequestDecorator implements ServerHttpRequest {
|
||||
return getDelegate().getRemoteAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return getDelegate().getLocalAddress();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public SslInfo getSslInfo() {
|
||||
|
||||
@@ -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.
|
||||
@@ -178,6 +178,11 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
|
||||
return new InetSocketAddress(this.request.getRemoteHost(), this.request.getRemotePort());
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return new InetSocketAddress(this.request.getLocalAddr(), this.request.getLocalPort());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected SslInfo initSslInfo() {
|
||||
|
||||
@@ -102,6 +102,11 @@ class UndertowServerHttpRequest extends AbstractServerHttpRequest {
|
||||
return this.exchange.getSourceAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getLocalAddress() {
|
||||
return this.exchange.getDestinationAddress();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected SslInfo initSslInfo() {
|
||||
|
||||
Reference in New Issue
Block a user