/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
@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); }
@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); }
@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); }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
@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); }
@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); }
@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); }
/** * 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; }