本文整理了Java中okio.BufferedSource.timeout()
方法的一些代码示例,展示了BufferedSource.timeout()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedSource.timeout()
方法的具体详情如下:
包路径:okio.BufferedSource
类名称:BufferedSource
方法名:timeout
暂无
代码示例来源:origin: square/okhttp
@Override public Timeout timeout() {
return source.timeout();
}
代码示例来源:origin: square/okhttp
@Override public Timeout timeout() {
return source.timeout();
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
@Override public Timeout timeout() {
return source.timeout();
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
@Override public Timeout timeout() {
return source.timeout();
}
代码示例来源:origin: square/okhttp
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);
}
}
代码示例来源:origin: square/okhttp
long timeoutBefore = source.timeout().timeoutNanos();
source.timeout().clearTimeout();
try {
b0 = source.readByte() & 0xff;
} finally {
source.timeout().timeout(timeoutBefore, TimeUnit.NANOSECONDS);
代码示例来源:origin: com.squareup.okhttp3/okhttp
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);
}
}
代码示例来源:origin: square/okio
@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();
}
代码示例来源:origin: square/okhttp
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);
代码示例来源:origin: square/okio
@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();
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
long timeoutBefore = source.timeout().timeoutNanos();
source.timeout().clearTimeout();
try {
b0 = source.readByte() & 0xff;
} finally {
source.timeout().timeout(timeoutBefore, TimeUnit.NANOSECONDS);
代码示例来源:origin: com.squareup.okhttp3/okhttp
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);
代码示例来源:origin: huxq17/SwipeCardsView
@Override public Timeout timeout() {
return source.timeout();
}
代码示例来源:origin: duzechao/OKHttpUtils
@Override public Timeout timeout() {
return source.timeout();
}
代码示例来源:origin: duzechao/OKHttpUtils
@Override public Timeout timeout() {
return source.timeout();
}
代码示例来源:origin: com.contentful.java/java-sdk
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() + ">";
}
}
代码示例来源:origin: heremaps/oksse
/**
* 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);
}
}
代码示例来源:origin: contentful/contentful.java
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() + ">";
}
}
代码示例来源:origin: com.github.ljun20160606/okhttp
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);
}
}
代码示例来源:origin: apache/servicemix-bundles
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);
}
}
内容来源于网络,如有侵权,请联系作者删除!