本文整理了Java中okhttp3.internal.Util.checkDuration()
方法的一些代码示例,展示了Util.checkDuration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.checkDuration()
方法的具体详情如下:
包路径:okhttp3.internal.Util
类名称:Util
方法名:checkDuration
暂无
代码示例来源:origin: square/okhttp
/**
* Sets the default connect timeout for new connections. A value of 0 means no timeout,
* otherwise values must be between 1 and {@link Integer#MAX_VALUE} when converted to
* milliseconds.
*
* <p>The connect timeout is applied when connecting a TCP socket to the target host.
* The default value is 10 seconds.
*/
public Builder connectTimeout(long timeout, TimeUnit unit) {
connectTimeout = checkDuration("timeout", timeout, unit);
return this;
}
代码示例来源:origin: square/okhttp
/**
* Sets the default write timeout for new connections. A value of 0 means no timeout, otherwise
* values must be between 1 and {@link Integer#MAX_VALUE} when converted to milliseconds.
*
* <p>The write timeout is applied for individual write IO operations.
* The default value is 10 seconds.
*
* @see Sink#timeout()
*/
public Builder writeTimeout(long timeout, TimeUnit unit) {
writeTimeout = checkDuration("timeout", timeout, unit);
return this;
}
代码示例来源:origin: square/okhttp
/**
* Sets the default timeout for complete calls. A value of 0 means no timeout, otherwise values
* must be between 1 and {@link Integer#MAX_VALUE} when converted to milliseconds.
*
* <p>The call timeout spans the entire call: resolving DNS, connecting, writing the request
* body, server processing, and reading the response body. If the call requires redirects or
* retries all must complete within one timeout period.
*
* <p>The default value is 0 which imposes no timeout.
*/
public Builder callTimeout(long timeout, TimeUnit unit) {
callTimeout = checkDuration("timeout", timeout, unit);
return this;
}
代码示例来源:origin: square/okhttp
/**
* Sets the default read timeout for new connections. A value of 0 means no timeout, otherwise
* values must be between 1 and {@link Integer#MAX_VALUE} when converted to milliseconds.
*
* <p>The read timeout is applied to both the TCP socket and for individual read IO operations
* including on {@link Source} of the {@link Response}. The default value is 10 seconds.
*
* @see Socket#setSoTimeout(int)
* @see Source#timeout()
*/
public Builder readTimeout(long timeout, TimeUnit unit) {
readTimeout = checkDuration("timeout", timeout, unit);
return this;
}
代码示例来源:origin: square/okhttp
/**
* Sets the interval between HTTP/2 and web socket pings initiated by this client. Use this to
* automatically send ping frames until either the connection fails or it is closed. This keeps
* the connection alive and may detect connectivity failures.
*
* <p>If the server does not respond to each ping with a pong within {@code interval}, this
* client will assume that connectivity has been lost. When this happens on a web socket the
* connection is canceled and its listener is {@linkplain WebSocketListener#onFailure notified
* of the failure}. When it happens on an HTTP/2 connection the connection is closed and any
* calls it is carrying {@linkplain java.io.IOException will fail with an IOException}.
*
* <p>The default value of 0 disables client-initiated pings.
*/
public Builder pingInterval(long interval, TimeUnit unit) {
pingInterval = checkDuration("interval", interval, unit);
return this;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
/**
* Sets the default connect timeout for new connections. A value of 0 means no timeout,
* otherwise values must be between 1 and {@link Integer#MAX_VALUE} when converted to
* milliseconds.
*
* <p>The connect timeout is applied when connecting a TCP socket to the target host.
* The default value is 10 seconds.
*/
public Builder connectTimeout(long timeout, TimeUnit unit) {
connectTimeout = checkDuration("timeout", timeout, unit);
return this;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
/**
* Sets the default write timeout for new connections. A value of 0 means no timeout, otherwise
* values must be between 1 and {@link Integer#MAX_VALUE} when converted to milliseconds.
*
* <p>The write timeout is applied for individual write IO operations.
* The default value is 10 seconds.
*
* @see Sink#timeout()
*/
public Builder writeTimeout(long timeout, TimeUnit unit) {
writeTimeout = checkDuration("timeout", timeout, unit);
return this;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
/**
* Sets the default timeout for complete calls. A value of 0 means no timeout, otherwise values
* must be between 1 and {@link Integer#MAX_VALUE} when converted to milliseconds.
*
* <p>The call timeout spans the entire call: resolving DNS, connecting, writing the request
* body, server processing, and reading the response body. If the call requires redirects or
* retries all must complete within one timeout period.
*
* <p>The default value is 0 which imposes no timeout.
*/
public Builder callTimeout(long timeout, TimeUnit unit) {
callTimeout = checkDuration("timeout", timeout, unit);
return this;
}
代码示例来源:origin: square/okhttp
@Override public Interceptor.Chain withWriteTimeout(int timeout, TimeUnit unit) {
int millis = checkDuration("timeout", timeout, unit);
return new RealInterceptorChain(interceptors, streamAllocation, httpCodec, connection, index,
request, call, eventListener, connectTimeout, readTimeout, millis);
}
代码示例来源:origin: square/okhttp
@Override public Interceptor.Chain withReadTimeout(int timeout, TimeUnit unit) {
int millis = checkDuration("timeout", timeout, unit);
return new RealInterceptorChain(interceptors, streamAllocation, httpCodec, connection, index,
request, call, eventListener, connectTimeout, millis, writeTimeout);
}
代码示例来源:origin: square/okhttp
@Override public Interceptor.Chain withConnectTimeout(int timeout, TimeUnit unit) {
int millis = checkDuration("timeout", timeout, unit);
return new RealInterceptorChain(interceptors, streamAllocation, httpCodec, connection, index,
request, call, eventListener, millis, readTimeout, writeTimeout);
}
代码示例来源:origin: square/okhttp
/**
* Sets the default connect timeout for new connections. A value of 0 means no timeout,
* otherwise values must be between 1 and {@link Integer#MAX_VALUE} when converted to
* milliseconds.
*
* <p>The connect timeout is applied when connecting a TCP socket to the target host.
* The default value is 10 seconds.
*/
@IgnoreJRERequirement
public Builder connectTimeout(Duration duration) {
connectTimeout = checkDuration("timeout", duration.toMillis(), TimeUnit.MILLISECONDS);
return this;
}
代码示例来源:origin: square/okhttp
/**
* Sets the default write timeout for new connections. A value of 0 means no timeout, otherwise
* values must be between 1 and {@link Integer#MAX_VALUE} when converted to milliseconds.
*
* <p>The write timeout is applied for individual write IO operations.
* The default value is 10 seconds.
*
* @see Sink#timeout()
*/
@IgnoreJRERequirement
public Builder writeTimeout(Duration duration) {
writeTimeout = checkDuration("timeout", duration.toMillis(), TimeUnit.MILLISECONDS);
return this;
}
代码示例来源:origin: square/okhttp
/**
* Sets the default read timeout for new connections. A value of 0 means no timeout, otherwise
* values must be between 1 and {@link Integer#MAX_VALUE} when converted to milliseconds.
*
* <p>The read timeout is applied to both the TCP socket and for individual read IO operations
* including on {@link Source} of the {@link Response}. The default value is 10 seconds.
*
* @see Socket#setSoTimeout(int)
* @see Source#timeout()
*/
@IgnoreJRERequirement
public Builder readTimeout(Duration duration) {
readTimeout = checkDuration("timeout", duration.toMillis(), TimeUnit.MILLISECONDS);
return this;
}
代码示例来源:origin: square/okhttp
/**
* Sets the default timeout for complete calls. A value of 0 means no timeout, otherwise values
* must be between 1 and {@link Integer#MAX_VALUE} when converted to milliseconds.
*
* <p>The call timeout spans the entire call: resolving DNS, connecting, writing the request
* body, server processing, and reading the response body. If the call requires redirects or
* retries all must complete within one timeout period.
*
* <p>The default value is 0 which imposes no timeout.
*/
@IgnoreJRERequirement
public Builder callTimeout(Duration duration) {
callTimeout = checkDuration("timeout", duration.toMillis(), TimeUnit.MILLISECONDS);
return this;
}
代码示例来源:origin: square/okhttp
/**
* Sets the interval between HTTP/2 and web socket pings initiated by this client. Use this to
* automatically send ping frames until either the connection fails or it is closed. This keeps
* the connection alive and may detect connectivity failures.
*
* <p>If the server does not respond to each ping with a pong within {@code interval}, this
* client will assume that connectivity has been lost. When this happens on a web socket the
* connection is canceled and its listener is {@linkplain WebSocketListener#onFailure notified
* of the failure}. When it happens on an HTTP/2 connection the connection is closed and any
* calls it is carrying {@linkplain java.io.IOException will fail with an IOException}.
*
* <p>The default value of 0 disables client-initiated pings.
*/
@IgnoreJRERequirement
public Builder pingInterval(Duration duration) {
pingInterval = checkDuration("timeout", duration.toMillis(), TimeUnit.MILLISECONDS);
return this;
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
@Override public Interceptor.Chain withConnectTimeout(int timeout, TimeUnit unit) {
int millis = checkDuration("timeout", timeout, unit);
return new RealInterceptorChain(interceptors, streamAllocation, httpCodec, connection, index,
request, call, eventListener, millis, readTimeout, writeTimeout);
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
@Override public Interceptor.Chain withReadTimeout(int timeout, TimeUnit unit) {
int millis = checkDuration("timeout", timeout, unit);
return new RealInterceptorChain(interceptors, streamAllocation, httpCodec, connection, index,
request, call, eventListener, connectTimeout, millis, writeTimeout);
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
@Override public Interceptor.Chain withWriteTimeout(int timeout, TimeUnit unit) {
int millis = checkDuration("timeout", timeout, unit);
return new RealInterceptorChain(interceptors, streamAllocation, httpCodec, connection, index,
request, call, eventListener, connectTimeout, readTimeout, millis);
}
代码示例来源:origin: com.squareup.okhttp3/okhttp
/**
* Sets the default connect timeout for new connections. A value of 0 means no timeout,
* otherwise values must be between 1 and {@link Integer#MAX_VALUE} when converted to
* milliseconds.
*
* <p>The connect timeout is applied when connecting a TCP socket to the target host.
* The default value is 10 seconds.
*/
@IgnoreJRERequirement
public Builder connectTimeout(Duration duration) {
connectTimeout = checkDuration("timeout", duration.toMillis(), TimeUnit.MILLISECONDS);
return this;
}
内容来源于网络,如有侵权,请联系作者删除!