Skip to content

Commit 3a91628

Browse files
committed
Replace "127.0.0.1" with "localhost"
1 parent 240b7d2 commit 3a91628

36 files changed

+95
-95
lines changed

client/src/test/java/org/asynchttpclient/AbstractBasicTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ public void tearDownGlobal() throws Exception {
5959
}
6060

6161
protected String getTargetUrl() {
62-
return String.format("http://127.0.0.1:%d/foo/test", port1);
62+
return String.format("http://localhost:%d/foo/test", port1);
6363
}
6464

6565
protected String getTargetUrl2() {
66-
return String.format("https://127.0.0.1:%d/foo/test", port2);
66+
return String.format("https://localhost:%d/foo/test", port2);
6767
}
6868

6969
public AbstractHandler configureHandler() throws Exception {

client/src/test/java/org/asynchttpclient/AuthTimeoutTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private Realm realm(boolean preemptive) {
189189

190190
@Override
191191
protected String getTargetUrl() {
192-
return "http://127.0.0.1:" + port1 + "/";
192+
return "http://localhost:" + port1 + "/";
193193
}
194194

195195
@Override

client/src/test/java/org/asynchttpclient/BasicAuthTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ public void tearDownGlobal() throws Exception {
8181

8282
@Override
8383
protected String getTargetUrl() {
84-
return "http://127.0.0.1:" + port1 + "/";
84+
return "http://localhost:" + port1 + "/";
8585
}
8686

8787
@Override
8888
protected String getTargetUrl2() {
89-
return "http://127.0.0.1:" + port2 + "/uff";
89+
return "http://localhost:" + port2 + "/uff";
9090
}
9191

9292
protected String getTargetUrlNoAuth() {
93-
return "http://127.0.0.1:" + portNoAuth + "/";
93+
return "http://localhost:" + portNoAuth + "/";
9494
}
9595

9696
@Override

client/src/test/java/org/asynchttpclient/BasicHttpTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ public Response onCompleted(Response response) throws Exception {
643643

644644
@Test(groups = "standalone")
645645
public void asyncDoPostProxyTest() throws Exception {
646-
try (AsyncHttpClient client = asyncHttpClient(config().setProxyServer(proxyServer("127.0.0.1", port2).build()))) {
646+
try (AsyncHttpClient client = asyncHttpClient(config().setProxyServer(proxyServer("localhost", port2).build()))) {
647647
HttpHeaders h = new DefaultHttpHeaders();
648648
h.add(HttpHeaders.Names.CONTENT_TYPE, HttpHeaders.Values.APPLICATION_X_WWW_FORM_URLENCODED);
649649
StringBuilder sb = new StringBuilder();
@@ -686,7 +686,7 @@ public void asyncRequestVirtualServerPOSTTest() throws Exception {
686686
if (response.getHeader("X-Host").startsWith("localhost")) {
687687
assertEquals(response.getHeader("X-Host"), "localhost:" + port1);
688688
} else {
689-
assertEquals(response.getHeader("X-Host"), "127.0.0.1:" + port1);
689+
assertEquals(response.getHeader("X-Host"), "localhost:" + port1);
690690
}
691691
}
692692
}
@@ -848,7 +848,7 @@ public void asyncConnectInvalidFuture() throws Exception {
848848
final AtomicInteger count = new AtomicInteger();
849849
for (int i = 0; i < 20; i++) {
850850
try {
851-
Response response = client.preparePost(String.format("http://127.0.0.1:%d/", dummyPort)).execute(new AsyncCompletionHandlerAdapter() {
851+
Response response = client.preparePost(String.format("http://localhost:%d/", dummyPort)).execute(new AsyncCompletionHandlerAdapter() {
852852
@Override
853853
public void onThrowable(Throwable t) {
854854
count.incrementAndGet();
@@ -871,7 +871,7 @@ public void asyncConnectInvalidPortFuture() throws Exception {
871871
try (AsyncHttpClient client = asyncHttpClient()) {
872872
int dummyPort = findFreePort();
873873
try {
874-
Response response = client.preparePost(String.format("http://127.0.0.1:%d/", dummyPort)).execute(new AsyncCompletionHandlerAdapter() {
874+
Response response = client.preparePost(String.format("http://localhost:%d/", dummyPort)).execute(new AsyncCompletionHandlerAdapter() {
875875
@Override
876876
public void onThrowable(Throwable t) {
877877
t.printStackTrace();
@@ -894,7 +894,7 @@ public void asyncConnectInvalidPort() throws Exception {
894894
int port = findFreePort();
895895

896896
try {
897-
Response response = client.preparePost(String.format("http://127.0.0.1:%d/", port)).execute(new AsyncCompletionHandlerAdapter() {
897+
Response response = client.preparePost(String.format("http://localhost:%d/", port)).execute(new AsyncCompletionHandlerAdapter() {
898898
@Override
899899
public void onThrowable(Throwable t) {
900900
t.printStackTrace();
@@ -913,7 +913,7 @@ public void asyncConnectInvalidHandlerPort() throws Exception {
913913
final CountDownLatch l = new CountDownLatch(1);
914914
int port = findFreePort();
915915

916-
client.prepareGet(String.format("http://127.0.0.1:%d/", port)).execute(new AsyncCompletionHandlerAdapter() {
916+
client.prepareGet(String.format("http://localhost:%d/", port)).execute(new AsyncCompletionHandlerAdapter() {
917917
@Override
918918
public void onThrowable(Throwable t) {
919919
try {
@@ -963,7 +963,7 @@ public void asyncConnectInvalidFuturePort() throws Exception {
963963
int port = findFreePort();
964964

965965
try {
966-
Response response = client.prepareGet(String.format("http://127.0.0.1:%d/", port)).execute(new AsyncCompletionHandlerAdapter() {
966+
Response response = client.prepareGet(String.format("http://localhost:%d/", port)).execute(new AsyncCompletionHandlerAdapter() {
967967
@Override
968968
public void onThrowable(Throwable t) {
969969
called.set(true);
@@ -1363,7 +1363,7 @@ public void getShouldAllowBody() throws IOException {
13631363
@Test(groups = "standalone", expectedExceptions = NullPointerException.class)
13641364
public void invalidUri() throws Exception {
13651365
try (AsyncHttpClient client = asyncHttpClient()) {
1366-
client.prepareGet(String.format("http:127.0.0.1:%d/foo/test", port1)).build();
1366+
client.prepareGet(String.format("http:localhost:%d/foo/test", port1)).build();
13671367
}
13681368
}
13691369

@@ -1387,7 +1387,7 @@ public void mirrorByteTest() throws Exception {
13871387

13881388
@Test(groups = "standalone")
13891389
public void testNewConnectionEventsFired() throws Exception {
1390-
Request request = get("http://127.0.0.1:" + port1 + "/Test").build();
1390+
Request request = get("http://localhost:" + port1 + "/Test").build();
13911391

13921392
try (AsyncHttpClient client = asyncHttpClient()) {
13931393
EventCollectingHandler handler = new EventCollectingHandler();

client/src/test/java/org/asynchttpclient/BasicHttpsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
public class BasicHttpsTest extends AbstractBasicHttpsTest {
3939

4040
protected String getTargetUrl() {
41-
return String.format("https://127.0.0.1:%d/foo/test", port1);
41+
return String.format("https://localhost:%d/foo/test", port1);
4242
}
4343

4444
@Test(groups = "standalone")

client/src/test/java/org/asynchttpclient/ByteBufferCapacityTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ public State onBodyPartReceived(final HttpResponseBodyPart content) throws Excep
9292
}
9393

9494
public String getTargetUrl() {
95-
return String.format("http://127.0.0.1:%d/foo/test", port1);
95+
return String.format("http://localhost:%d/foo/test", port1);
9696
}
9797
}

client/src/test/java/org/asynchttpclient/ComplexClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void multipleRequestsTest() throws Exception {
4545
public void urlWithoutSlashTest() throws Exception {
4646
try (AsyncHttpClient c = asyncHttpClient()) {
4747
String body = "hello there";
48-
Response response = c.preparePost(String.format("http://127.0.0.1:%d/foo/test", port1)).setBody(body).setHeader("Content-Type", "text/html").execute().get(TIMEOUT, TimeUnit.SECONDS);
48+
Response response = c.preparePost(String.format("http://localhost:%d/foo/test", port1)).setBody(body).setHeader("Content-Type", "text/html").execute().get(TIMEOUT, TimeUnit.SECONDS);
4949
assertEquals(response.getResponseBody(), body);
5050
}
5151
}

client/src/test/java/org/asynchttpclient/DigestAuthTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public AbstractHandler configureHandler() throws Exception {
6262
@Test(groups = "standalone")
6363
public void digestAuthTest() throws IOException, ExecutionException, TimeoutException, InterruptedException {
6464
try (AsyncHttpClient client = asyncHttpClient()) {
65-
Future<Response> f = client.prepareGet("http://127.0.0.1:" + port1 + "/")//
65+
Future<Response> f = client.prepareGet("http://localhost:" + port1 + "/")//
6666
.setRealm(digestAuthRealm(USER, ADMIN).setRealmName("MyRealm").build())//
6767
.execute();
6868
Response resp = f.get(60, TimeUnit.SECONDS);
@@ -75,7 +75,7 @@ public void digestAuthTest() throws IOException, ExecutionException, TimeoutExce
7575
@Test(groups = "standalone")
7676
public void digestAuthTestWithoutScheme() throws IOException, ExecutionException, TimeoutException, InterruptedException {
7777
try (AsyncHttpClient client = asyncHttpClient()) {
78-
Future<Response> f = client.prepareGet("http://127.0.0.1:" + port1 + "/")//
78+
Future<Response> f = client.prepareGet("http://localhost:" + port1 + "/")//
7979
.setRealm(digestAuthRealm(USER, ADMIN).setRealmName("MyRealm").build())//
8080
.execute();
8181
Response resp = f.get(60, TimeUnit.SECONDS);
@@ -88,7 +88,7 @@ public void digestAuthTestWithoutScheme() throws IOException, ExecutionException
8888
@Test(groups = "standalone")
8989
public void digestAuthNegativeTest() throws IOException, ExecutionException, TimeoutException, InterruptedException {
9090
try (AsyncHttpClient client = asyncHttpClient()) {
91-
Future<Response> f = client.prepareGet("http://127.0.0.1:" + port1 + "/")//
91+
Future<Response> f = client.prepareGet("http://localhost:" + port1 + "/")//
9292
.setRealm(digestAuthRealm("fake", ADMIN).build())//
9393
.execute();
9494
Response resp = f.get(20, TimeUnit.SECONDS);

client/src/test/java/org/asynchttpclient/ErrorResponseTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public AbstractHandler configureHandler() throws Exception {
6363
@Test(groups = "standalone")
6464
public void testQueryParameters() throws Exception {
6565
try (AsyncHttpClient client = asyncHttpClient()) {
66-
Future<Response> f = client.prepareGet("http://127.0.0.1:" + port1 + "/foo").addHeader("Accepts", "*/*").execute();
66+
Future<Response> f = client.prepareGet("http://localhost:" + port1 + "/foo").addHeader("Accepts", "*/*").execute();
6767
Response resp = f.get(3, TimeUnit.SECONDS);
6868
assertNotNull(resp);
6969
assertEquals(resp.getStatusCode(), 400);

client/src/test/java/org/asynchttpclient/Expect100ContinueTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public AbstractHandler configureHandler() throws Exception {
6161
@Test(groups = "standalone")
6262
public void Expect100Continue() throws Exception {
6363
try (AsyncHttpClient client = asyncHttpClient()) {
64-
Future<Response> f = client.preparePut("http://127.0.0.1:" + port1 + "/").setHeader("Expect", "100-continue").setBody(SIMPLE_TEXT_FILE).execute();
64+
Future<Response> f = client.preparePut("http://localhost:" + port1 + "/").setHeader("Expect", "100-continue").setBody(SIMPLE_TEXT_FILE).execute();
6565
Response resp = f.get();
6666
assertNotNull(resp);
6767
assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);

client/src/test/java/org/asynchttpclient/Head302Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public AbstractHandler configureHandler() throws Exception {
6666
public void testHEAD302() throws IOException, BrokenBarrierException, InterruptedException, ExecutionException, TimeoutException {
6767
try (AsyncHttpClient client = asyncHttpClient()) {
6868
final CountDownLatch l = new CountDownLatch(1);
69-
Request request = head("http://127.0.0.1:" + port1 + "/Test").build();
69+
Request request = head("http://localhost:" + port1 + "/Test").build();
7070

7171
client.executeRequest(request, new AsyncCompletionHandlerBase() {
7272
@Override

client/src/test/java/org/asynchttpclient/ParamEncodingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void testParameters() throws IOException, ExecutionException, TimeoutExce
5858

5959
String value = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKQLMNOPQRSTUVWXYZ1234567809`~!@#$%^&*()_+-=,.<>/?;:'\"[]{}\\| ";
6060
try (AsyncHttpClient client = asyncHttpClient()) {
61-
Future<Response> f = client.preparePost("http://127.0.0.1:" + port1).addFormParam("test", value).execute();
61+
Future<Response> f = client.preparePost("http://localhost:" + port1).addFormParam("test", value).execute();
6262
Response resp = f.get(10, TimeUnit.SECONDS);
6363
assertNotNull(resp);
6464
assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);

client/src/test/java/org/asynchttpclient/PerRequestRelative302Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void redirected302InvalidTest() throws Exception {
132132
isSet.getAndSet(false);
133133
try (AsyncHttpClient c = asyncHttpClient()) {
134134
// If the test hit a proxy, no ConnectException will be thrown and instead of 404 will be returned.
135-
Response response = c.preparePost(getTargetUrl()).setFollowRedirect(true).setHeader("X-redirect", String.format("http://127.0.0.1:%d/", port2)).execute().get();
135+
Response response = c.preparePost(getTargetUrl()).setFollowRedirect(true).setHeader("X-redirect", String.format("http://localhost:%d/", port2)).execute().get();
136136

137137
assertNotNull(response);
138138
assertEquals(response.getStatusCode(), 404);

client/src/test/java/org/asynchttpclient/PerRequestTimeoutTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class PerRequestTimeoutTest extends AbstractBasicTest {
4545

4646
private void checkTimeoutMessage(String message) {
4747
assertTrue(message.startsWith("Request timed out"), "error message indicates reason of error");
48-
assertTrue(message.contains("127.0.0.1"), "error message contains remote ip address");
48+
assertTrue(message.contains("localhost"), "error message contains remote ip address");
4949
assertTrue(message.contains("of 100 ms"), "error message contains timeout configuration value");
5050
}
5151

client/src/test/java/org/asynchttpclient/PostWithQSTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void handle(String s, Request r, HttpServletRequest request, HttpServletR
7070
@Test(groups = "standalone")
7171
public void postWithQS() throws IOException, ExecutionException, TimeoutException, InterruptedException {
7272
try (AsyncHttpClient client = asyncHttpClient()) {
73-
Future<Response> f = client.preparePost("http://127.0.0.1:" + port1 + "/?a=b").setBody("abc".getBytes()).execute();
73+
Future<Response> f = client.preparePost("http://localhost:" + port1 + "/?a=b").setBody("abc".getBytes()).execute();
7474
Response resp = f.get(3, TimeUnit.SECONDS);
7575
assertNotNull(resp);
7676
assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
@@ -80,11 +80,11 @@ public void postWithQS() throws IOException, ExecutionException, TimeoutExceptio
8080
@Test(groups = "standalone")
8181
public void postWithNulParamQS() throws IOException, ExecutionException, TimeoutException, InterruptedException {
8282
try (AsyncHttpClient client = asyncHttpClient()) {
83-
Future<Response> f = client.preparePost("http://127.0.0.1:" + port1 + "/?a=").setBody("abc".getBytes()).execute(new AsyncCompletionHandlerBase() {
83+
Future<Response> f = client.preparePost("http://localhost:" + port1 + "/?a=").setBody("abc".getBytes()).execute(new AsyncCompletionHandlerBase() {
8484

8585
@Override
8686
public State onStatusReceived(final HttpResponseStatus status) throws Exception {
87-
if (!status.getUri().toUrl().equals("http://127.0.0.1:" + port1 + "/?a=")) {
87+
if (!status.getUri().toUrl().equals("http://localhost:" + port1 + "/?a=")) {
8888
throw new IOException(status.getUri().toUrl());
8989
}
9090
return super.onStatusReceived(status);
@@ -100,11 +100,11 @@ public State onStatusReceived(final HttpResponseStatus status) throws Exception
100100
@Test(groups = "standalone")
101101
public void postWithNulParamsQS() throws IOException, ExecutionException, TimeoutException, InterruptedException {
102102
try (AsyncHttpClient client = asyncHttpClient()) {
103-
Future<Response> f = client.preparePost("http://127.0.0.1:" + port1 + "/?a=b&c&d=e").setBody("abc".getBytes()).execute(new AsyncCompletionHandlerBase() {
103+
Future<Response> f = client.preparePost("http://localhost:" + port1 + "/?a=b&c&d=e").setBody("abc".getBytes()).execute(new AsyncCompletionHandlerBase() {
104104

105105
@Override
106106
public State onStatusReceived(final HttpResponseStatus status) throws Exception {
107-
if (!status.getUri().toUrl().equals("http://127.0.0.1:" + port1 + "/?a=b&c&d=e")) {
107+
if (!status.getUri().toUrl().equals("http://localhost:" + port1 + "/?a=b&c&d=e")) {
108108
throw new IOException("failed to parse the query properly");
109109
}
110110
return super.onStatusReceived(status);
@@ -120,11 +120,11 @@ public State onStatusReceived(final HttpResponseStatus status) throws Exception
120120
@Test(groups = "standalone")
121121
public void postWithEmptyParamsQS() throws IOException, ExecutionException, TimeoutException, InterruptedException {
122122
try (AsyncHttpClient client = asyncHttpClient()) {
123-
Future<Response> f = client.preparePost("http://127.0.0.1:" + port1 + "/?a=b&c=&d=e").setBody("abc".getBytes()).execute(new AsyncCompletionHandlerBase() {
123+
Future<Response> f = client.preparePost("http://localhost:" + port1 + "/?a=b&c=&d=e").setBody("abc".getBytes()).execute(new AsyncCompletionHandlerBase() {
124124

125125
@Override
126126
public State onStatusReceived(final HttpResponseStatus status) throws Exception {
127-
if (!status.getUri().toUrl().equals("http://127.0.0.1:" + port1 + "/?a=b&c=&d=e")) {
127+
if (!status.getUri().toUrl().equals("http://localhost:" + port1 + "/?a=b&c=&d=e")) {
128128
throw new IOException("failed to parse the query properly");
129129
}
130130
return super.onStatusReceived(status);

client/src/test/java/org/asynchttpclient/QueryParametersTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public AbstractHandler configureHandler() throws Exception {
7070
@Test(groups = "standalone")
7171
public void testQueryParameters() throws IOException, ExecutionException, TimeoutException, InterruptedException {
7272
try (AsyncHttpClient client = asyncHttpClient()) {
73-
Future<Response> f = client.prepareGet("http://127.0.0.1:" + port1).addQueryParam("a", "1").addQueryParam("b", "2").execute();
73+
Future<Response> f = client.prepareGet("http://localhost:" + port1).addQueryParam("a", "1").addQueryParam("b", "2").execute();
7474
Response resp = f.get(3, TimeUnit.SECONDS);
7575
assertNotNull(resp);
7676
assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
@@ -97,7 +97,7 @@ public void testUrlRequestParametersEncoding() throws IOException, ExecutionExce
9797
public void urlWithColonTest() throws Exception {
9898
try (AsyncHttpClient c = asyncHttpClient()) {
9999
String query = "test:colon:";
100-
Response response = c.prepareGet(String.format("http://127.0.0.1:%d/foo/test/colon?q=%s", port1, query)).setHeader("Content-Type", "text/html").execute().get(TIMEOUT, TimeUnit.SECONDS);
100+
Response response = c.prepareGet(String.format("http://localhost:%d/foo/test/colon?q=%s", port1, query)).setHeader("Content-Type", "text/html").execute().get(TIMEOUT, TimeUnit.SECONDS);
101101

102102
assertEquals(response.getHeader("q"), query);
103103
}

client/src/test/java/org/asynchttpclient/RC10KTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void rc10kProblem() throws IOException, ExecutionException, TimeoutExcept
9696
List<Future<Integer>> resps = new ArrayList<>(C10K);
9797
int i = 0;
9898
while (i < C10K) {
99-
resps.add(ahc.prepareGet(String.format("http://127.0.0.1:%d/%d", ports[i % SRV_COUNT], i)).execute(new MyAsyncHandler(i++)));
99+
resps.add(ahc.prepareGet(String.format("http://localhost:%d/%d", ports[i % SRV_COUNT], i)).execute(new MyAsyncHandler(i++)));
100100
}
101101
i = 0;
102102
for (Future<Integer> fResp : resps) {

0 commit comments

Comments
 (0)