Skip to content

Commit

Permalink
Issue #5417 - Cleanup of PR from Review
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed Oct 12, 2020
1 parent 149f389 commit c2266fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
Expand Up @@ -512,7 +512,7 @@ public void customize(Connector connector, HttpConfiguration config, Request req
{
port = requestURI.getPort();
}
// if (port == MutableHostPort.IMPLIED) // is implied, no port change needed
// Don't change port if port == IMPLIED.

// Update authority if different from metadata
if (!host.equalsIgnoreCase(requestURI.getHost()) ||
Expand Down
Expand Up @@ -74,10 +74,6 @@ public void init() throws Exception

// Default behavior Connector
HttpConnectionFactory http = new HttpConnectionFactory();
http.setInputBufferSize(1024);
http.getHttpConfiguration().setRequestHeaderSize(512);
http.getHttpConfiguration().setResponseHeaderSize(512);
http.getHttpConfiguration().setOutputBufferSize(2048);
http.getHttpConfiguration().setSecurePort(443);
customizer = new ForwardedRequestCustomizer();
http.getHttpConfiguration().addCustomizer(customizer);
Expand All @@ -86,7 +82,6 @@ public void init() throws Exception

// Alternate behavior Connector
HttpConnectionFactory httpAlt = new HttpConnectionFactory();
httpAlt.setInputBufferSize(1024);
httpAlt.getHttpConfiguration().setSecurePort(8443);
customizerAlt = new ForwardedRequestCustomizer();
httpAlt.getHttpConfiguration().addCustomizer(customizerAlt);
Expand All @@ -95,10 +90,6 @@ public void init() throws Exception

// Configured behavior Connector
http = new HttpConnectionFactory();
http.setInputBufferSize(1024);
http.getHttpConfiguration().setRequestHeaderSize(512);
http.getHttpConfiguration().setResponseHeaderSize(512);
http.getHttpConfiguration().setOutputBufferSize(2048);
customizerConfigured = new ForwardedRequestCustomizer();
customizerConfigured.setForwardedHeader("Jetty-Forwarded");
customizerConfigured.setForwardedHostHeader("Jetty-Forwarded-Host");
Expand Down Expand Up @@ -801,40 +792,38 @@ public static Stream<Arguments> nonStandardPortCases()
Arguments.of(new Request("RFC7239 with https and h2")
.headers(
"GET /test/forwarded.jsp HTTP/1.1",
"Host: web.euro.de",
"Forwarded: for=192.168.2.6;host=web.euro.de;proto=https;proto-version=h2"
// Client: https://web.euro.de/test/forwarded.jsp
"Host: web.example.net",
"Forwarded: for=192.168.2.6;host=web.example.net;proto=https;proto-version=h2"
),
new Expectations()
.scheme("https").serverName("web.euro.de").serverPort(443)
.requestURL("https://web.euro.de/test/forwarded.jsp")
.scheme("https").serverName("web.example.net").serverPort(443)
.requestURL("https://web.example.net/test/forwarded.jsp")
.remoteAddr("192.168.2.6").remotePort(0)
),
// RFC7239 Tests with https and proxy provided port
Arguments.of(new Request("RFC7239 with proxy provided port on https and h2")
.headers(
"GET /test/forwarded.jsp HTTP/1.1",
"Host: web.euro.de:9443",
"Forwarded: for=192.168.2.6;host=web.euro.de:9443;proto=https;proto-version=h2"
// Client: https://web.euro.de:9443/test/forwarded.jsp
"Host: web.example.net:9443",
"Forwarded: for=192.168.2.6;host=web.example.net:9443;proto=https;proto-version=h2"
),
new Expectations()
.scheme("https").serverName("web.euro.de").serverPort(9443)
.requestURL("https://web.euro.de:9443/test/forwarded.jsp")
.scheme("https").serverName("web.example.net").serverPort(9443)
.requestURL("https://web.example.net:9443/test/forwarded.jsp")
.remoteAddr("192.168.2.6").remotePort(0)
),
// RFC7239 Tests with https, no port in Host, but proxy provided port
Arguments.of(new Request("RFC7239 with client provided host and different proxy provided port on https and h2")
.headers(
"GET /test/forwarded.jsp HTTP/1.1",
"Host: web.euro.de",
"Forwarded: for=192.168.2.6;host=new.euro.de:7443;proto=https;proto-version=h2"
// Client: https://web.euro.de/test/forwarded.jsp
// Proxy Requests: https://new.euro.de/test/forwarded.jsp
"Host: web.example.net",
"Forwarded: for=192.168.2.6;host=new.example.net:7443;proto=https;proto-version=h2"
// Client: https://web.example.net/test/forwarded.jsp
// Proxy Requests: https://new.example.net/test/forwarded.jsp
),
new Expectations()
.scheme("https").serverName("new.euro.de").serverPort(7443)
.requestURL("https://new.euro.de:7443/test/forwarded.jsp")
.scheme("https").serverName("new.example.net").serverPort(7443)
.requestURL("https://new.example.net:7443/test/forwarded.jsp")
.remoteAddr("192.168.2.6").remotePort(0)
)
);
Expand Down

0 comments on commit c2266fd

Please sign in to comment.