-
Bug
-
Resolution: Fixed
-
P4
-
11, 12, 13
-
b18
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8259642 | 11.0.11-oracle | Dukebot | P4 | Resolved | Fixed | b02 |
JDK-8257464 | 11.0.10 | Andrew Hughes | P4 | Resolved | Fixed | b05 |
A DESCRIPTION OF THE PROBLEM :
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host
HTTP/1.1 requires the Host header be sent - this includes proxies - when using apache with apache_mod_proxy, it returns 400, dutifully honoring the spec
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Watch the following java code in your favorite tcpdump on port 8080; you'll see that only the request line is sent; no Host header
var httpResponse = HttpClient.newBuilder()
.proxy(ProxySelector.of(new InetSocketAddress("localhost", 8080)))
.build()
.send(HttpRequest.newBuilder(URI.create("https://www.google.com/"))
.build(), HttpResponse.BodyHandlers.ofString());
assert httpResponse.statusCode() == HttpURLConnection.HTTP_OK;
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
CONNECT www.google.com:443 HTTP/1.1\r\n
Host: www.google.com\r\n
\r\n
ACTUAL -
CONNECT www.google.com:443 HTTP/1.1\r\n
\r\n
---------- BEGIN SOURCE ----------
var httpResponse = HttpClient.newBuilder()
.proxy(ProxySelector.of(new InetSocketAddress("localhost", 8080)))
.build()
.send(HttpRequest.newBuilder(URI.create("https://www.google.com/"))
.build(), HttpResponse.BodyHandlers.ofString());
assert httpResponse.statusCode() == HttpURLConnection.HTTP_OK;
---------- END SOURCE ----------
FREQUENCY : always
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host
HTTP/1.1 requires the Host header be sent - this includes proxies - when using apache with apache_mod_proxy, it returns 400, dutifully honoring the spec
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Watch the following java code in your favorite tcpdump on port 8080; you'll see that only the request line is sent; no Host header
var httpResponse = HttpClient.newBuilder()
.proxy(ProxySelector.of(new InetSocketAddress("localhost", 8080)))
.build()
.send(HttpRequest.newBuilder(URI.create("https://www.google.com/"))
.build(), HttpResponse.BodyHandlers.ofString());
assert httpResponse.statusCode() == HttpURLConnection.HTTP_OK;
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
CONNECT www.google.com:443 HTTP/1.1\r\n
Host: www.google.com\r\n
\r\n
ACTUAL -
CONNECT www.google.com:443 HTTP/1.1\r\n
\r\n
---------- BEGIN SOURCE ----------
var httpResponse = HttpClient.newBuilder()
.proxy(ProxySelector.of(new InetSocketAddress("localhost", 8080)))
.build()
.send(HttpRequest.newBuilder(URI.create("https://www.google.com/"))
.build(), HttpResponse.BodyHandlers.ofString());
assert httpResponse.statusCode() == HttpURLConnection.HTTP_OK;
---------- END SOURCE ----------
FREQUENCY : always
- backported by
-
JDK-8257464 HttpClient doesn't send HOST header when tunelling HTTP/1.1 through http proxy
- Resolved
-
JDK-8259642 HttpClient doesn't send HOST header when tunelling HTTP/1.1 through http proxy
- Resolved
- links to