Please note this value can be overridden by the {@link #setHttpProcessor(org.apache.http.protocol.HttpProcessor)} method.
248249250251252253254255256257258
{ assertNotNull(r.getHeaders(HttpHeaders.CONTENT_RANGE)); assertEquals(1, r.getHeaders(HttpHeaders.CONTENT_RANGE).length); } }); client.addInterceptorFirst(new HttpResponseInterceptor() { public void process(final HttpResponse r, final HttpContext context) throws HttpException, IOException { assertEquals(204, r.getStatusLine().getStatusCode()); }
269270271272273274275276277278279
@Test public void testGetRange() throws Exception { final HttpClientBuilder client = HttpClientBuilder.create(); client.addInterceptorFirst(new HttpResponseInterceptor() { public void process(final HttpResponse r, final HttpContext context) throws HttpException, IOException { // Verify partial content response assertEquals(206, r.getStatusLine().getStatusCode());
192193194195196197198199200201202
@Test public void testBasicPreemptiveAuthHeader() throws Exception { final HttpClientBuilder client = HttpClientBuilder.create(); client.addInterceptorFirst(new HttpRequestInterceptor() { public void process(final HttpRequest r, final HttpContext context) throws HttpException, IOException { assertNotNull(r.getHeaders(HttpHeaders.AUTHORIZATION)); assertEquals(1, r.getHeaders(HttpHeaders.AUTHORIZATION).length);
8990919293949596979899
@Test public void testGetSingleFileGzip() throws Exception { final HttpClientBuilder client = HttpClientBuilder.create(); client.addInterceptorFirst(new HttpResponseInterceptor() { public void process(final HttpResponse r, final HttpContext context) throws HttpException, IOException { assertEquals(200, r.getStatusLine().getStatusCode()); assertNotNull(r.getHeaders(HttpHeaders.CONTENT_ENCODING));
223224225226227228229230231232233
@Test public void testPutRange() throws Exception { final HttpClientBuilder client = HttpClientBuilder.create(); client.addInterceptorFirst(new HttpResponseInterceptor() { public void process(final HttpResponse r, final HttpContext context) throws HttpException, IOException { assertEquals(201, r.getStatusLine().getStatusCode()); }
240241242243244245246247248249250
{ // Append to existing file final Map<String, String> header = Collections.singletonMap(HttpHeaders.CONTENT_RANGE, "bytes " + 2 + "-" + 3 + "/" + 4); client.addInterceptorFirst(new HttpRequestInterceptor() { public void process(final HttpRequest r, final HttpContext context) throws HttpException, IOException { assertNotNull(r.getHeaders(HttpHeaders.CONTENT_RANGE)); assertEquals(1, r.getHeaders(HttpHeaders.CONTENT_RANGE).length);
189190191192193194195196197198199
credentialsProvider.setCredentials( new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(graphiteUsername, graphitePassword)); clientBuilder.setDefaultCredentialsProvider(credentialsProvider); context.setAttribute("preemptive-auth", new BasicScheme()); clientBuilder.addInterceptorFirst(new PreemptiveAuth()); } return clientBuilder.build(); }
176177178179180181182183184185186
} public static CloseableHttpClient newClient(int timeout) { HttpClientBuilder builder = HttpClients.custom(); builder.useSystemProperties(); builder.addInterceptorFirst(REMOVE_INCORRECT_CONTENT_ENCODING); builder.disableAutomaticRetries(); builder.setSslcontext(SSL_CONTEXT); builder.setHostnameVerifier(SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);