@@ -170,21 +170,21 @@ public void testProxyProperties() throws IOException, ExecutionException, Timeou
170
170
// FIXME not threadsafe!
171
171
Properties originalProps = new Properties ();
172
172
originalProps .putAll (System .getProperties ());
173
- System .setProperty (ProxyUtils .PROXY_HOST , "localhost " );
173
+ System .setProperty (ProxyUtils .PROXY_HOST , "127.0.0.1 " );
174
174
System .setProperty (ProxyUtils .PROXY_PORT , String .valueOf (port1 ));
175
175
System .setProperty (ProxyUtils .PROXY_NONPROXYHOSTS , "localhost" );
176
176
AsyncHttpClientConfigHelper .reloadProperties ();
177
177
178
178
try (AsyncHttpClient client = asyncHttpClient (config ().setUseProxyProperties (true ))) {
179
- String target = "http://localhost :1234/" ;
180
- Future <Response > f = client .prepareGet (target ).execute ();
179
+ String proxifiedtarget = "http://127.0.0.1 :1234/" ;
180
+ Future <Response > f = client .prepareGet (proxifiedtarget ).execute ();
181
181
Response resp = f .get (3 , TimeUnit .SECONDS );
182
182
assertNotNull (resp );
183
183
assertEquals (resp .getStatusCode (), HttpServletResponse .SC_OK );
184
184
assertEquals (resp .getHeader ("target" ), "/" );
185
185
186
- target = "http://localhost:1234/" ;
187
- f = client .prepareGet (target ).execute ();
186
+ String nonProxifiedtarget = "http://localhost:1234/" ;
187
+ f = client .prepareGet (nonProxifiedtarget ).execute ();
188
188
try {
189
189
resp = f .get (3 , TimeUnit .SECONDS );
190
190
fail ("should not be able to connect" );
@@ -220,27 +220,27 @@ public void testIgnoreProxyPropertiesByDefault() throws IOException, ExecutionEx
220
220
}
221
221
}
222
222
223
- @ Test (groups = "standalone" , enabled = false )
223
+ @ Test (groups = "standalone" , enabled = false )
224
224
public void testProxyActivationProperty () throws IOException , ExecutionException , TimeoutException , InterruptedException {
225
225
// FIXME not threadsafe!
226
226
Properties originalProps = new Properties ();
227
227
originalProps .putAll (System .getProperties ());
228
- System .setProperty (ProxyUtils .PROXY_HOST , "localhost " );
228
+ System .setProperty (ProxyUtils .PROXY_HOST , "127.0.0.1 " );
229
229
System .setProperty (ProxyUtils .PROXY_PORT , String .valueOf (port1 ));
230
230
System .setProperty (ProxyUtils .PROXY_NONPROXYHOSTS , "localhost" );
231
231
System .setProperty (AsyncHttpClientConfigDefaults .ASYNC_CLIENT_CONFIG_ROOT + "useProxyProperties" , "true" );
232
232
AsyncHttpClientConfigHelper .reloadProperties ();
233
233
234
234
try (AsyncHttpClient client = asyncHttpClient ()) {
235
- String target = "http://localhost :1234/" ;
236
- Future <Response > f = client .prepareGet (target ).execute ();
235
+ String proxifiedTarget = "http://127.0.0.1 :1234/" ;
236
+ Future <Response > f = client .prepareGet (proxifiedTarget ).execute ();
237
237
Response resp = f .get (3 , TimeUnit .SECONDS );
238
238
assertNotNull (resp );
239
239
assertEquals (resp .getStatusCode (), HttpServletResponse .SC_OK );
240
240
assertEquals (resp .getHeader ("target" ), "/" );
241
241
242
- target = "http://localhost:1234/" ;
243
- f = client .prepareGet (target ).execute ();
242
+ String nonProxifiedTarget = "http://localhost:1234/" ;
243
+ f = client .prepareGet (nonProxifiedTarget ).execute ();
244
244
try {
245
245
resp = f .get (3 , TimeUnit .SECONDS );
246
246
fail ("should not be able to connect" );
@@ -257,14 +257,14 @@ public void testWildcardNonProxyHosts() throws IOException, ExecutionException,
257
257
// FIXME not threadsafe!
258
258
Properties originalProps = new Properties ();
259
259
originalProps .putAll (System .getProperties ());
260
- System .setProperty (ProxyUtils .PROXY_HOST , "localhost " );
260
+ System .setProperty (ProxyUtils .PROXY_HOST , "127.0.0.1 " );
261
261
System .setProperty (ProxyUtils .PROXY_PORT , String .valueOf (port1 ));
262
262
System .setProperty (ProxyUtils .PROXY_NONPROXYHOSTS , "127.*" );
263
263
AsyncHttpClientConfigHelper .reloadProperties ();
264
264
265
265
try (AsyncHttpClient client = asyncHttpClient (config ().setUseProxyProperties (true ))) {
266
- String target = "http://localhost :1234/" ;
267
- Future <Response > f = client .prepareGet (target ).execute ();
266
+ String nonProxifiedTarget = "http://127.0.0.1 :1234/" ;
267
+ Future <Response > f = client .prepareGet (nonProxifiedTarget ).execute ();
268
268
try {
269
269
f .get (3 , TimeUnit .SECONDS );
270
270
fail ("should not be able to connect" );
@@ -281,8 +281,8 @@ public void testUseProxySelector() throws IOException, ExecutionException, Timeo
281
281
ProxySelector originalProxySelector = ProxySelector .getDefault ();
282
282
ProxySelector .setDefault (new ProxySelector () {
283
283
public List <Proxy > select (URI uri ) {
284
- if (uri .getHost ().equals ("localhost " )) {
285
- return Arrays .asList (new Proxy (Proxy .Type .HTTP , new InetSocketAddress ("localhost " , port1 )));
284
+ if (uri .getHost ().equals ("127.0.0.1 " )) {
285
+ return Arrays .asList (new Proxy (Proxy .Type .HTTP , new InetSocketAddress ("127.0.0.1 " , port1 )));
286
286
} else {
287
287
return Arrays .asList (Proxy .NO_PROXY );
288
288
}
@@ -293,15 +293,15 @@ public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
293
293
});
294
294
295
295
try (AsyncHttpClient client = asyncHttpClient (config ().setUseProxySelector (true ))) {
296
- String target = "http://localhost :1234/" ;
297
- Future <Response > f = client .prepareGet (target ).execute ();
296
+ String proxifiedTarget = "http://127.0.0.1 :1234/" ;
297
+ Future <Response > f = client .prepareGet (proxifiedTarget ).execute ();
298
298
Response resp = f .get (3 , TimeUnit .SECONDS );
299
299
assertNotNull (resp );
300
300
assertEquals (resp .getStatusCode (), HttpServletResponse .SC_OK );
301
301
assertEquals (resp .getHeader ("target" ), "/" );
302
302
303
- target = "http://localhost:1234/" ;
304
- f = client .prepareGet (target ).execute ();
303
+ String nonProxifiedTarget = "http://localhost:1234/" ;
304
+ f = client .prepareGet (nonProxifiedTarget ).execute ();
305
305
try {
306
306
f .get (3 , TimeUnit .SECONDS );
307
307
fail ("should not be able to connect" );
0 commit comments