com.xkcoding.http.support.java11.DefaultProxySelector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xkcoding-simple-http Show documentation
Show all versions of xkcoding-simple-http Show documentation
修复 HttpClientImpl timeout 配置失效问题, forked from https://github.com/xkcoding/simple-http,
简单的 http 实现
The newest version!
package com.xkcoding.http.support.java11;
import com.xkcoding.http.config.HttpConfig;
import com.xkcoding.http.exception.SimpleHttpException;
import java.io.IOException;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.util.Collections;
import java.util.List;
/**
*
* 默认代理选择器
*
*
* @author yangkai.shen
* @date Created in 2020-04-29 15:59
*/
public class DefaultProxySelector extends ProxySelector {
private HttpConfig httpConfig;
public DefaultProxySelector(HttpConfig httpConfig) {
this.httpConfig = httpConfig;
}
@Override
public List select(URI uri) {
return Collections.singletonList(httpConfig.getProxy());
}
@Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
throw new SimpleHttpException("Proxy connect failed!");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy