All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sc.utils.rest.resttemplete.CustomSimpleClientHttpRequestFactory Maven / Gradle / Ivy

The newest version!
package com.sc.utils.rest.resttemplete;

import org.springframework.http.client.SimpleClientHttpRequestFactory;

import java.io.IOException;
import java.net.HttpURLConnection;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;

public class CustomSimpleClientHttpRequestFactory extends SimpleClientHttpRequestFactory {


    private final HostnameVerifier verifier;

    public CustomSimpleClientHttpRequestFactory(HostnameVerifier verifier) {
        this.verifier = verifier;
    }

    @Override
    protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
        if (connection instanceof HttpsURLConnection) {
            ((HttpsURLConnection) connection).setHostnameVerifier(verifier);
        }
        super.prepareConnection(connection, httpMethod);
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy