Skip to content

Commit

Permalink
OkHttpClientTransportTest's proxy to use localhost
Browse files Browse the repository at this point in the history
Fixes #8080. The address 0.0.0.0 (that comes from new Socket(0).
.getLocalSocketAddress()) is for listening with a server, but it
is not meant to be used as the destination address as per
"3.2.1.3 Addressing" in RFC 1122
  • Loading branch information
suztomo authored and ejona86 committed Apr 15, 2021
1 parent d25ebaf commit 4ad4926
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1866,7 +1866,8 @@ public void proxy_200() throws Exception {
INITIAL_WINDOW_SIZE,
HttpConnectProxiedSocketAddress.newBuilder()
.setTargetAddress(targetAddress)
.setProxyAddress(serverSocket.getLocalSocketAddress()).build(),
.setProxyAddress(new InetSocketAddress("localhost", serverSocket.getLocalPort()))
.build(),
tooManyPingsRunnable,
DEFAULT_MAX_INBOUND_METADATA_SIZE,
transportTracer,
Expand Down Expand Up @@ -1923,7 +1924,8 @@ public void proxy_500() throws Exception {
INITIAL_WINDOW_SIZE,
HttpConnectProxiedSocketAddress.newBuilder()
.setTargetAddress(targetAddress)
.setProxyAddress(serverSocket.getLocalSocketAddress()).build(),
.setProxyAddress(new InetSocketAddress("localhost", serverSocket.getLocalPort()))
.build(),
tooManyPingsRunnable,
DEFAULT_MAX_INBOUND_METADATA_SIZE,
transportTracer,
Expand Down Expand Up @@ -1979,7 +1981,8 @@ public void proxy_immediateServerClose() throws Exception {
INITIAL_WINDOW_SIZE,
HttpConnectProxiedSocketAddress.newBuilder()
.setTargetAddress(targetAddress)
.setProxyAddress(serverSocket.getLocalSocketAddress()).build(),
.setProxyAddress(new InetSocketAddress("localhost", serverSocket.getLocalPort()))
.build(),
tooManyPingsRunnable,
DEFAULT_MAX_INBOUND_METADATA_SIZE,
transportTracer,
Expand Down

0 comments on commit 4ad4926

Please sign in to comment.