use of org.springframework.http.client.BufferingClientHttpRequestFactory in project esup-papercut by EsupPortail.
the class RestConfig method restTemplate.
@Bean
public RestTemplate restTemplate() throws Exception {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
RestTemplate restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(requestFactory));
restTemplate.setInterceptors(Collections.singletonList(new RequestResponseLoggingInterceptor()));
restTemplate.getMessageConverters().add(0, jacksonConverter());
return restTemplate;
}
use of org.springframework.http.client.BufferingClientHttpRequestFactory in project open-kilda by telstra.
the class DefaultServiceConfig method buildLoggingRestTemplate.
/**
* Build rest template with enabled logging support.
*/
public static RestTemplate buildLoggingRestTemplate() {
final RestTemplate restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory()));
List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();
interceptors.add(new LoggingRequestInterceptor());
restTemplate.setErrorHandler(new ExtendedErrorHandler());
return restTemplate;
}
use of org.springframework.http.client.BufferingClientHttpRequestFactory in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method readTimeoutCanBeConfiguredOnAWrappedRequestFactory.
@Test
void readTimeoutCanBeConfiguredOnAWrappedRequestFactory() {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
this.builder.requestFactory(() -> new BufferingClientHttpRequestFactory(requestFactory)).setReadTimeout(Duration.ofMillis(1234)).build();
assertThat(requestFactory).hasFieldOrPropertyWithValue("readTimeout", 1234);
}
use of org.springframework.http.client.BufferingClientHttpRequestFactory in project xm-ms-entity by xm-online.
the class TemplateUtil method disableSSL.
public static void disableSSL(RestTemplate restTemplate) {
try {
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null, (X509Certificate[] chain, String authType) -> true).build();
CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE)).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(requestFactory));
} catch (Exception e) {
log.error("Exception occurred while creating http factory, error={}", e.getMessage(), e);
}
}
use of org.springframework.http.client.BufferingClientHttpRequestFactory in project vorto by eclipse.
the class RepositoryConfiguration method restTemplate.
@Bean
public RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory()));
List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>();
interceptors.add(new LoggingInterceptor());
restTemplate.setInterceptors(interceptors);
restTemplate.getMessageConverters().add(new ByteArrayHttpMessageConverter());
return restTemplate;
}
Aggregations