use of org.apache.http.client.entity.InputStreamFactory in project spring-boot by spring-projects.
the class AbstractServletWebServerFactoryTests method doTestCompression.
private boolean doTestCompression(int contentSize, String[] mimeTypes, String[] excludedUserAgents) 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"), new HttpComponentsClientHttpRequestFactory(HttpClientBuilder.create().setUserAgent("testUserAgent").setContentDecoderRegistry(contentDecoderMap).build()));
assertThat(response).isEqualTo(testContent);
return inputStreamFactory.wasCompressionUsed();
}
use of org.apache.http.client.entity.InputStreamFactory in project spring-boot by spring-projects.
the class AbstractServletWebServerFactoryTests method doTestCompression.
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);
String response = getResponse(getLocalUrl("/test.txt"), method, new HttpComponentsClientHttpRequestFactory(HttpClientBuilder.create().setUserAgent("testUserAgent").setContentDecoderRegistry(contentDecoderMap).build()));
assertThat(response).isEqualTo(testContent);
return inputStreamFactory.wasCompressionUsed();
}
use of org.apache.http.client.entity.InputStreamFactory in project spring-boot by spring-projects.
the class AbstractServletWebServerFactoryTests method compressionWithoutContentSizeHeader.
@Test
void compressionWithoutContentSizeHeader() throws Exception {
AbstractServletWebServerFactory factory = getFactory();
Compression compression = new Compression();
compression.setEnabled(true);
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);
getResponse(getLocalUrl("/hello"), new HttpComponentsClientHttpRequestFactory(this.httpClientBuilder.get().setContentDecoderRegistry(contentDecoderMap).build()));
assertThat(inputStreamFactory.wasCompressionUsed()).isTrue();
}
Aggregations