Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x
This commit is contained in:
commit
02ec06ead9
|
@ -628,16 +628,16 @@ public class ForwardedRequestCustomizer implements Customizer
|
|||
if (!getForwardedPortAsAuthority())
|
||||
{
|
||||
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)
|
||||
_for = new HostPort(HostPort.normalizeHost(_for.getHost()), field.getIntValue());
|
||||
_for = new HostPort(HostPort.normalizeHost(_for.getHost()), Integer.parseInt(getLeftMost(field.getValue())));
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
_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/")
|
||||
.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")
|
||||
.headers(
|
||||
"GET / HTTP/1.1",
|
||||
|
|
Loading…
Reference in New Issue