Support multiple proxy port values. Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
74e560fb7a
commit
894f31e612
|
@ -630,16 +630,16 @@ public class ForwardedRequestCustomizer implements Customizer
|
||||||
if (!getForwardedPortAsAuthority())
|
if (!getForwardedPortAsAuthority())
|
||||||
{
|
{
|
||||||
if (_for == null)
|
if (_for == null)
|
||||||
_for = new PortSetHostPort(_request.getRemoteHost(), field.getIntValue());
|
_for = new PortSetHostPort(_request.getRemoteHost(), Integer.parseInt(getLeftMost(field.getValue())));
|
||||||
else if (_for instanceof PossiblyPartialHostPort && _for.getPort() <= 0)
|
else if (_for instanceof PossiblyPartialHostPort && _for.getPort() <= 0)
|
||||||
_for = new HostPort(HostPort.normalizeHost(_for.getHost()), field.getIntValue());
|
_for = new HostPort(HostPort.normalizeHost(_for.getHost()), Integer.parseInt(getLeftMost(field.getValue())));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_host == null)
|
if (_host == null)
|
||||||
_host = new PortSetHostPort(_request.getServerName(), field.getIntValue());
|
_host = new PortSetHostPort(_request.getServerName(), Integer.parseInt(getLeftMost(field.getValue())));
|
||||||
else if (_host instanceof PossiblyPartialHostPort && _host.getPort() <= 0)
|
else if (_host instanceof PossiblyPartialHostPort && _host.getPort() <= 0)
|
||||||
_host = new HostPort(HostPort.normalizeHost(_host.getHost()), field.getIntValue());
|
_host = new HostPort(HostPort.normalizeHost(_host.getHost()), Integer.parseInt(getLeftMost(field.getValue())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -348,6 +348,18 @@ public class ForwardedRequestCustomizerTest
|
||||||
.requestURL("http://myhost:2222/")
|
.requestURL("http://myhost:2222/")
|
||||||
.remoteAddr("[1:2:3:4:5:6:7:8]").remotePort(0)
|
.remoteAddr("[1:2:3:4:5:6:7:8]").remotePort(0)
|
||||||
),
|
),
|
||||||
|
Arguments.of(new Request("X-Forwarded-For and X-Forwarded-Port (multiple times combined)")
|
||||||
|
.headers(
|
||||||
|
"GET / HTTP/1.1",
|
||||||
|
"Host: myhost",
|
||||||
|
"X-Forwarded-Port: 2222, 3333",
|
||||||
|
"X-Forwarded-For: 1:2:3:4:5:6:7:8, 7:7:7:7:7:7:7:7"
|
||||||
|
),
|
||||||
|
new Expectations()
|
||||||
|
.scheme("http").serverName("myhost").serverPort(2222)
|
||||||
|
.requestURL("http://myhost:2222/")
|
||||||
|
.remoteAddr("[1:2:3:4:5:6:7:8]").remotePort(0)
|
||||||
|
),
|
||||||
Arguments.of(new Request("X-Forwarded-Port")
|
Arguments.of(new Request("X-Forwarded-Port")
|
||||||
.headers(
|
.headers(
|
||||||
"GET / HTTP/1.1",
|
"GET / HTTP/1.1",
|
||||||
|
|
Loading…
Reference in New Issue