improve ipv6 support, add tests

This commit is contained in:
nkzawa
2016-01-30 20:36:28 +09:00
parent a0aed87adc
commit 9363039a71
5 changed files with 148 additions and 33 deletions

View File

@@ -87,6 +87,30 @@ public class TransportTest {
assertThat(polling.uri().matches("http://localhost/engine.io\\?(j=[0-9]+&)?t=[0-9]+-[0-9]+"), is(true));
}
@Test
public void ipv6Uri() {
Transport.Options opt = new Transport.Options();
opt.path ="/engine.io";
opt.hostname = "::1";
opt.secure = false;
opt.port = 80;
opt.timestampRequests = false;
Polling polling = new Polling(opt);
assertThat(polling.uri(), containsString("http://[::1]/engine.io"));
}
@Test
public void ipv6UriWithPort() {
Transport.Options opt = new Transport.Options();
opt.path ="/engine.io";
opt.hostname = "::1";
opt.secure = false;
opt.port = 8080;
opt.timestampRequests = false;
Polling polling = new Polling(opt);
assertThat(polling.uri(), containsString("http://[::1]:8080/engine.io"));
}
@Test
public void wsUri() {
Transport.Options opt = new Transport.Options();
@@ -123,6 +147,30 @@ public class TransportTest {
assertThat(ws.uri().matches("ws://localhost/engine.io\\?woot=[0-9]+"), is(true));
}
@Test
public void wsIPv6Uri() {
Transport.Options opt = new Transport.Options();
opt.path ="/engine.io";
opt.hostname = "::1";
opt.secure = false;
opt.port = 80;
opt.timestampRequests = false;
WS ws = new WS(opt);
assertThat(ws.uri(), containsString("ws://[::1]/engine.io"));
}
@Test
public void wsIPv6UriWithPort() {
Transport.Options opt = new Transport.Options();
opt.path ="/engine.io";
opt.hostname = "::1";
opt.secure = false;
opt.port = 8080;
opt.timestampRequests = false;
WS ws = new WS(opt);
assertThat(ws.uri(), containsString("ws://[::1]:8080/engine.io"));
}
class Polling extends PollingXHR {
public Polling(Options opts) {