Merge pull request #3970 from eclipse/jetty-9.4.x-3969-xforwarded-host

Issue #3969 - adding testcase to verify Host & X-Forwarded behavior
This commit is contained in:
Joakim Erdfelt 2019-08-13 09:16:08 -05:00 committed by GitHub
commit d10fea9b7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 0 deletions

View File

@ -627,6 +627,29 @@ public class ForwardedRequestCustomizerTest
assertThat("requestURL", _requestURL.get(), is("http://example.com/"));
}
@Test
public void testAllXForwarded() throws Exception
{
HttpTester.Response response = HttpTester.parseResponse(
_connector.getResponse(
"GET / HTTP/1.1\n" +
"Host: myhost\n" +
"X-Forwarded-Proto: https\n" +
"X-Forwarded-Host: www.example.com\n" +
"X-Forwarded-Port: 4333\n" +
"X-Forwarded-For: 8.5.4.3:2222\n" +
"X-Forwarded-Server: fw.example.com\n" +
"\n"));
assertThat("status", response.getStatus(), is(200));
assertThat("scheme", _scheme.get(), is("https"));
assertThat("serverName", _serverName.get(), is("www.example.com"));
assertThat("serverPort", _serverPort.get(), is(4333));
assertThat("remoteAddr", _remoteAddr.get(), is("8.5.4.3"));
assertThat("remotePort", _remotePort.get(), is(2222));
assertThat("requestURL", _requestURL.get(), is("https://www.example.com:4333/"));
}
interface RequestTester
{
boolean check(HttpServletRequest request, HttpServletResponse response) throws IOException;