@Override public Timeout timeout() { return source.timeout(); }
@Override public Timeout timeout() { return source.timeout(); }
@Override public Timeout timeout() { return source.timeout(); }
@Override public Timeout timeout() { return source.timeout(); }
public HttpCodec newCodec(OkHttpClient client, Interceptor.Chain chain, StreamAllocation streamAllocation) throws SocketException { if (http2Connection != null) { return new Http2Codec(client, chain, streamAllocation, http2Connection); } else { socket.setSoTimeout(chain.readTimeoutMillis()); source.timeout().timeout(chain.readTimeoutMillis(), MILLISECONDS); sink.timeout().timeout(chain.writeTimeoutMillis(), MILLISECONDS); return new Http1Codec(client, streamAllocation, source, sink); } }
public HttpCodec newCodec(OkHttpClient client, Interceptor.Chain chain, StreamAllocation streamAllocation) throws SocketException { if (http2Connection != null) { return new Http2Codec(client, chain, streamAllocation, http2Connection); } else { socket.setSoTimeout(chain.readTimeoutMillis()); source.timeout().timeout(chain.readTimeoutMillis(), MILLISECONDS); sink.timeout().timeout(chain.writeTimeoutMillis(), MILLISECONDS); return new Http1Codec(client, streamAllocation, source, sink); } }
@Test public void readWithoutTimeout() throws Exception { Socket socket = socket(ONE_MB, 0); BufferedSource source = Okio.buffer(Okio.source(socket)); source.timeout().timeout(5000, TimeUnit.MILLISECONDS); source.require(ONE_MB); socket.close(); }
while (true) { Http1Codec tunnelConnection = new Http1Codec(null, null, source, sink); source.timeout().timeout(readTimeout, MILLISECONDS); sink.timeout().timeout(writeTimeout, MILLISECONDS); tunnelConnection.writeRequest(tunnelRequest.headers(), requestLine);
@Test public void readWithTimeout() throws Exception { Socket socket = socket(0, 0); BufferedSource source = Okio.buffer(Okio.source(socket)); source.timeout().timeout(250, TimeUnit.MILLISECONDS); try { source.require(ONE_MB); fail(); } catch (SocketTimeoutException expected) { } socket.close(); }
while (true) { Http1Codec tunnelConnection = new Http1Codec(null, null, source, sink); source.timeout().timeout(readTimeout, MILLISECONDS); sink.timeout().timeout(writeTimeout, MILLISECONDS); tunnelConnection.writeRequest(tunnelRequest.headers(), requestLine);
@Override public Timeout timeout() { return source.timeout(); }
@Override public Timeout timeout() { return source.timeout(); }
@Override public Timeout timeout() { return source.timeout(); }
private String readResponseBody(Response response) { try { BufferedSource bufferedSource = response.body().source(); Timeout timeout = bufferedSource.timeout(); timeout.deadline(1, TimeUnit.SECONDS); return response.body().string(); } catch (IOException ioException) { return "<io exception while parsing body: " + ioException.toString() + ">"; } }
/** * Sets a reading timeout, so the read operation will get unblock if this timeout is reached. * * @param timeout timeout to set * @param unit unit of the timeout to set */ void setTimeout(long timeout, TimeUnit unit) { if (source != null) { source.timeout().timeout(timeout, unit); } }
private String readResponseBody(Response response) { try { BufferedSource bufferedSource = response.body().source(); Timeout timeout = bufferedSource.timeout(); timeout.deadline(1, TimeUnit.SECONDS); return response.body().string(); } catch (IOException ioException) { return "<io exception while parsing body: " + ioException.toString() + ">"; } }
public HttpCodec newCodec(OkHttpClient client, Interceptor.Chain chain, StreamAllocation streamAllocation) throws SocketException { if (http2Connection != null) { return new Http2Codec(client, chain, streamAllocation, http2Connection); } else { socket.setSoTimeout(chain.readTimeoutMillis()); source.timeout().timeout(chain.readTimeoutMillis(), MILLISECONDS); sink.timeout().timeout(chain.writeTimeoutMillis(), MILLISECONDS); return new Http1Codec(client, streamAllocation, source, sink); } }
public HttpCodec newCodec(OkHttpClient client, Interceptor.Chain chain, StreamAllocation streamAllocation) throws SocketException { if (http2Connection != null) { return new Http2Codec(client, chain, streamAllocation, http2Connection); } else { socket.setSoTimeout(chain.readTimeoutMillis()); source.timeout().timeout(chain.readTimeoutMillis(), MILLISECONDS); sink.timeout().timeout(chain.writeTimeoutMillis(), MILLISECONDS); return new Http1Codec(client, streamAllocation, source, sink); } }