Example usage for org.springframework.http.client HttpComponentsClientHttpRequestFactory HttpComponentsClientHttpRequestFactory

List of usage examples for org.springframework.http.client HttpComponentsClientHttpRequestFactory HttpComponentsClientHttpRequestFactory

Introduction

In this page you can find the example usage for org.springframework.http.client HttpComponentsClientHttpRequestFactory HttpComponentsClientHttpRequestFactory.

Prototype

public HttpComponentsClientHttpRequestFactory(HttpClient httpClient) 

Source Link

Document

Create a new instance of the HttpComponentsClientHttpRequestFactory with the given HttpClient instance.

Usage

From source file:org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests.java

@Test
public void compressionWithoutContentSizeHeader() throws Exception {
    AbstractServletWebServerFactory factory = getFactory();
    Compression compression = new Compression();
    compression.setEnabled(true);/* w  w  w  .j a  va2s  . c  o  m*/
    factory.setCompression(compression);
    this.webServer = factory
            .getWebServer(new ServletRegistrationBean<>(new ExampleServlet(false, true), "/hello"));
    this.webServer.start();
    TestGzipInputStreamFactory inputStreamFactory = new TestGzipInputStreamFactory();
    Map<String, InputStreamFactory> contentDecoderMap = Collections.singletonMap("gzip",
            (InputStreamFactory) inputStreamFactory);
    getResponse(getLocalUrl("/hello"), new HttpComponentsClientHttpRequestFactory(
            HttpClientBuilder.create().setContentDecoderRegistry(contentDecoderMap).build()));
    assertThat(inputStreamFactory.wasCompressionUsed()).isTrue();
}

From source file:org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests.java

private boolean doTestCompression(int contentSize, String[] mimeTypes, String[] excludedUserAgents,
        HttpMethod method) throws Exception {
    String testContent = setUpFactoryForCompression(contentSize, mimeTypes, excludedUserAgents);
    TestGzipInputStreamFactory inputStreamFactory = new TestGzipInputStreamFactory();
    Map<String, InputStreamFactory> contentDecoderMap = Collections.singletonMap("gzip",
            (InputStreamFactory) inputStreamFactory);
    String response = getResponse(getLocalUrl("/test.txt"), method,
            new HttpComponentsClientHttpRequestFactory(HttpClientBuilder.create().setUserAgent("testUserAgent")
                    .setContentDecoderRegistry(contentDecoderMap).build()));
    assertThat(response).isEqualTo(testContent);
    return inputStreamFactory.wasCompressionUsed();
}