Search in sources :

Example 1 with InterceptingClientHttpRequestFactory

use of org.springframework.http.client.InterceptingClientHttpRequestFactory in project spring-boot by spring-projects.

the class RemoteClientConfiguration method clientHttpRequestFactory.

@Bean
public ClientHttpRequestFactory clientHttpRequestFactory() {
    List<ClientHttpRequestInterceptor> interceptors = Arrays.asList(getSecurityInterceptor());
    SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
    Proxy proxy = this.properties.getRemote().getProxy();
    if (proxy.getHost() != null && proxy.getPort() != null) {
        requestFactory.setProxy(new java.net.Proxy(Type.HTTP, new InetSocketAddress(proxy.getHost(), proxy.getPort())));
    }
    return new InterceptingClientHttpRequestFactory(requestFactory, interceptors);
}
Also used : SimpleClientHttpRequestFactory(org.springframework.http.client.SimpleClientHttpRequestFactory) Proxy(org.springframework.boot.devtools.autoconfigure.RemoteDevToolsProperties.Proxy) InetSocketAddress(java.net.InetSocketAddress) InterceptingClientHttpRequestFactory(org.springframework.http.client.InterceptingClientHttpRequestFactory) ClientHttpRequestInterceptor(org.springframework.http.client.ClientHttpRequestInterceptor) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Proxy (org.springframework.boot.devtools.autoconfigure.RemoteDevToolsProperties.Proxy)1 Bean (org.springframework.context.annotation.Bean)1 ClientHttpRequestInterceptor (org.springframework.http.client.ClientHttpRequestInterceptor)1 InterceptingClientHttpRequestFactory (org.springframework.http.client.InterceptingClientHttpRequestFactory)1 SimpleClientHttpRequestFactory (org.springframework.http.client.SimpleClientHttpRequestFactory)1