/** * Returns the trailers after the HTTP response, which may be empty. It is an error to call this * before the entire HTTP response body has been consumed. */ public Headers trailers() throws IOException { return httpCodec.trailers(); }
@Override public long contentLength() { return HttpHeaders.contentLength(okHeaders); }
@Override public boolean isCanceled() { return retryAndFollowUpInterceptor.isCanceled(); }
public static StatusLine get(Response response) { return new StatusLine(response.protocol(), response.code(), response.message()); }
/** * Add a header with the specified name and formatted date. Does validation of header names and * value. */ public Builder add(String name, Date value) { if (value == null) throw new NullPointerException("value for name " + name + " == null"); add(name, HttpDate.format(value)); return this; }
/** * Returns true if a Vary header contains an asterisk. Such responses cannot be cached. */ public static boolean hasVaryAll(Headers responseHeaders) { return varyFields(responseHeaders).contains("*"); }
@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); }
/** * Returns true if a Vary header contains an asterisk. Such responses cannot be cached. */ public static boolean hasVaryAll(Response response) { return hasVaryAll(response.headers()); }
@Override public void cancel() { retryAndFollowUpInterceptor.cancel(); }
@Override public Response proceed(Request request) throws IOException { return proceed(request, streamAllocation, httpCodec, connection); }
StreamAllocation streamAllocation() { return retryAndFollowUpInterceptor.streamAllocation(); }
public void cancel() { HttpCodec codecToCancel; RealConnection connectionToCancel; synchronized (connectionPool) { canceled = true; codecToCancel = codec; connectionToCancel = connection; } if (codecToCancel != null) { codecToCancel.cancel(); } else if (connectionToCancel != null) { connectionToCancel.cancel(); } }
public static long contentLength(Headers headers) { return stringToLong(headers.get("Content-Length")); }
private void captureCallStackTrace() { Object callStackTrace = Platform.get().getStackTraceForCloseable("response.body().close()"); retryAndFollowUpInterceptor.setCallStackTrace(callStackTrace); }
public static long contentLength(Response response) { return contentLength(response.headers()); }
private static Set<String> varyFields(Response response) { return varyFields(response.headers()); }
@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); }