Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion splunk/src/main/java/com/splunk/HttpService.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ public class HttpService {
private static String HTTP_SCHEME = "http";
private static String HOSTNAME = "localhost";
private static String HOSTIP = "127.0.0.1";
private static String HOSTIPv6 = "::1";

private static final HostnameVerifier HOSTNAME_VERIFIER = new HostnameVerifier() {
public boolean verify(String s, SSLSession sslSession) {
if (s.equals(HOSTNAME) || s.equals(HOSTIP)) {
if (s.equals(HOSTNAME) || s.equals(HOSTIP) || s.equals(HOSTIPv6)) {
return true;
} else {
HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
Expand Down
23 changes: 23 additions & 0 deletions splunk/src/test/java/com/splunk/HttpServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,29 @@ public void setUp() throws Exception {
);
}

@Test
public void testHttpServiceWithHostIP(){
HttpService service = new HttpService("127.0.0.1");
ResponseMessage response = service.get("/");
Assert.assertEquals(200, response.getStatus());
Assert.assertTrue(firstLineIsXmlDtd(response.getContent()));
}

@Test
public void testHttpServiceWithHostIPv6(){
// IPv6 Host without the [] brackets
HttpService service = new HttpService("::1");
ResponseMessage response = service.get("/");
Assert.assertEquals(200, response.getStatus());
Assert.assertTrue(firstLineIsXmlDtd(response.getContent()));

// IPv6 Host with the [] brackets
HttpService newService = new HttpService("[::1]");
ResponseMessage resp = newService.get("/");
Assert.assertEquals(200, resp.getStatus());
Assert.assertTrue(firstLineIsXmlDtd(resp.getContent()));
}

@Test
public void testGet() {
ResponseMessage response = httpService.get("/");
Expand Down