12345678910111213141516171819202122232425262728293031323334353637 |
- package cn.nosum.http.apache;
- import cn.nosum.http.AbsRequestHttp;
- import cn.nosum.http.RequestHttpProperties;
- import cn.nosum.http.enums.HttpType;
- import org.apache.http.HttpHost;
- import org.apache.http.impl.client.CloseableHttpClient;
- /**
- * APACHE 请求代理封装.
- *
- * @author Young
- */
- public class ApacheRequestHttp extends AbsRequestHttp<CloseableHttpClient, HttpHost> {
- public ApacheRequestHttp(RequestHttpProperties properties) {
- ApacheHttpClientBuilder apacheHttpClientBuilder = DefaultApacheHttpClientBuilder.get();
- apacheHttpClientBuilder.httpProxyHost(properties.getHttpProxyHost())
- .httpProxyPort(properties.getHttpProxyPort())
- .httpProxyUsername(properties.getHttpProxyUsername())
- .httpProxyPassword(properties.getHttpProxyPassword())
- .connectTimeout(properties.getConnectTimeout())
- .readTimeout(properties.getReadTimeout());
- if (properties.getHttpProxyHost() != null && properties.getHttpProxyPort() > 0) {
- httpProxy = new HttpHost(properties.getHttpProxyHost(), properties.getHttpProxyPort());
- }
- httpClient = apacheHttpClientBuilder.build();
- }
- @Override
- public HttpType getRequestType() {
- return HttpType.APACHE_HTTP;
- }
- }
|