Skip to content

Commit 98bad32

Browse files
authored
Merge pull request #210 from splunk/ipv6-support
IPv6 support
2 parents 8367148 + 37d1e69 commit 98bad32

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

splunk/src/main/java/com/splunk/HttpService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ public class HttpService {
5252
private static String HTTP_SCHEME = "http";
5353
private static String HOSTNAME = "localhost";
5454
private static String HOSTIP = "127.0.0.1";
55+
private static String HOSTIPv6 = "::1";
5556

5657
private static final HostnameVerifier HOSTNAME_VERIFIER = new HostnameVerifier() {
5758
public boolean verify(String s, SSLSession sslSession) {
58-
if (s.equals(HOSTNAME) || s.equals(HOSTIP)) {
59+
if (s.equals(HOSTNAME) || s.equals(HOSTIP) || s.equals(HOSTIPv6)) {
5960
return true;
6061
} else {
6162
HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();

splunk/src/test/java/com/splunk/HttpServiceTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@ public void setUp() throws Exception {
4141
);
4242
}
4343

44+
@Test
45+
public void testHttpServiceWithHostIP(){
46+
HttpService service = new HttpService("127.0.0.1");
47+
ResponseMessage response = service.get("/");
48+
Assert.assertEquals(200, response.getStatus());
49+
Assert.assertTrue(firstLineIsXmlDtd(response.getContent()));
50+
}
51+
52+
@Test
53+
public void testHttpServiceWithHostIPv6(){
54+
// IPv6 Host without the [] brackets
55+
HttpService service = new HttpService("::1");
56+
ResponseMessage response = service.get("/");
57+
Assert.assertEquals(200, response.getStatus());
58+
Assert.assertTrue(firstLineIsXmlDtd(response.getContent()));
59+
60+
// IPv6 Host with the [] brackets
61+
HttpService newService = new HttpService("[::1]");
62+
ResponseMessage resp = newService.get("/");
63+
Assert.assertEquals(200, resp.getStatus());
64+
Assert.assertTrue(firstLineIsXmlDtd(resp.getContent()));
65+
}
66+
4467
@Test
4568
public void testGet() {
4669
ResponseMessage response = httpService.get("/");

0 commit comments

Comments
 (0)