List of usage examples for com.squareup.okhttp Address getUriHost
@Deprecated
public String getUriHost()
From source file:co.paralleluniverse.fibers.okhttp.InterceptorTest.java
License:Open Source License
@Ignore @Test/*from ww w .j ava 2s . c o m*/ public void networkInterceptorsCannotChangeServerAddress() throws Exception { server.enqueue(new MockResponse().setResponseCode(500)); Interceptor interceptor = new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Address address = chain.connection().getRoute().getAddress(); String sameHost = address.getUriHost(); int differentPort = address.getUriPort() + 1; return chain.proceed(chain.request().newBuilder() .url(new URL("http://" + sameHost + ":" + differentPort + "/")).build()); } }; client.networkInterceptors().add(interceptor); Request request = new Request.Builder().url(server.getUrl("/")).build(); try { FiberOkHttpUtil.executeInFiber(client, request); fail(); } catch (IllegalStateException expected) { assertEquals("network interceptor " + interceptor + " must retain the same host and port", expected.getMessage()); } }
From source file:co.paralleluniverse.fibers.okhttp.test.InterceptorTest.java
License:Apache License
@Ignore @Test// w w w . j ava 2 s . c om public void networkInterceptorsCannotChangeServerAddress() throws Exception { server.enqueue(new MockResponse().setResponseCode(500)); Interceptor interceptor = new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Address address = chain.connection().getRoute().getAddress(); String sameHost = address.getUriHost(); int differentPort = address.getUriPort() + 1; return chain.proceed(chain.request().newBuilder() .url(HttpUrl.parse("http://" + sameHost + ":" + differentPort + "/")).build()); } }; client.networkInterceptors().add(interceptor); Request request = new Request.Builder().url(server.url("/")).build(); try { client.newCall(request).execute(); fail(); } catch (IllegalStateException expected) { assertEquals("network interceptor " + interceptor + " must retain the same host and port", expected.getMessage()); } }
From source file:com.navercorp.pinpoint.plugin.okhttp.v2.interceptor.HttpEngineConnectMethodInterceptor.java
License:Apache License
private String getHostAndPort(Connection connection) { final Address address = connection.getRoute().getAddress(); return HostAndPort.toHostAndPortString(address.getUriHost(), address.getUriPort()); }