@Override public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { final HttpClientContext clientContext = HttpClientContext.adapt(context); final RequestConfig requestConfig = clientContext.getRequestConfig(); /* Signal support for Accept-Encoding transfer encodings. */ if (!request.containsHeader("Accept-Encoding") && requestConfig.isContentCompressionEnabled()) { request.addHeader("Accept-Encoding", acceptEncoding); } }
@Override public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException { Args.notNull(request, "HTTP request"); if (!request.containsHeader(HTTP.EXPECT_DIRECTIVE)) { if (request instanceof HttpEntityEnclosingRequest) { final ProtocolVersion ver = request.getRequestLine().getProtocolVersion(); final HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity(); // Do not send the expect header if request body is known to be empty if (entity != null && entity.getContentLength() != 0 && !ver.lessEquals(HttpVersion.HTTP_1_0)) { final HttpClientContext clientContext = HttpClientContext.adapt(context); final RequestConfig config = clientContext.getRequestConfig(); if (config.isExpectContinueEnabled()) { request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE); } } } } }