Skip to content

Commit 90780ac

Browse files
committed
fix(proxy): remove no proxy
1 parent 9d0567a commit 90780ac

File tree

1 file changed

+4
-43
lines changed

1 file changed

+4
-43
lines changed

volcengine-java-sdk-core/src/main/java/com/volcengine/ApiClient.java

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ public class ApiClient extends BaseClient{
144144

145145
private String httpProxy;
146146
private String httpsProxy;
147-
private String noProxy;
148147

149148
/*
150149
* Constructor for ApiClient
@@ -652,61 +651,23 @@ public ApiClient setHttpsProxy(String httpsProxy) {
652651
return this;
653652
}
654653

655-
/**
656-
* Get the no proxy.
657-
*
658-
* @return no proxy
659-
*/
660-
public String getNoProxy() {
661-
return this.noProxy;
662-
}
663-
664-
/**
665-
* Set the no proxy.
666-
*
667-
* @return Api client
668-
*/
669-
public ApiClient setNoProxy(String noProxy) {
670-
this.noProxy = noProxy;
671-
updateClientProxy();
672-
return this;
673-
}
674-
675654
private void updateClientProxy() {
676655
httpClient.setProxySelector(new ProxySelector() {
677656
@Override
678657
public List<Proxy> select(URI uri) {
679-
String targetHost = uri.getHost();
680-
681-
String envNoProxy = System.getenv("NO_PROXY");
682-
if (StringUtils.isEmpty(envNoProxy)) {
683-
envNoProxy = System.getenv("no_proxy");
684-
}
685-
686-
boolean noProxyFlag = false;
687-
String noProxyList = (StringUtils.isEmpty(noProxy) ? envNoProxy : noProxy);
688-
if (!StringUtils.isEmpty(noProxyList)) {
689-
String[] noProxyArr = noProxyList.split(",");
690-
for (String noProxyHost : noProxyArr) {
691-
if (noProxyHost.equals(targetHost)) {
692-
noProxyFlag = true;
693-
break;
694-
}
695-
}
696-
}
697658

698659
List<Proxy> proxies = new ArrayList<>();
699-
if (noProxyFlag) {
700-
proxies.add(Proxy.NO_PROXY);
701-
return proxies;
702-
}
703660

704661
if (disableSSL) {
705662
addProxy(proxies, httpProxy, "HTTP_PROXY");
706663
} else {
707664
addProxy(proxies, httpsProxy, "HTTPS_PROXY");
708665
}
709666

667+
if(proxies.isEmpty()){
668+
proxies.add(Proxy.NO_PROXY);
669+
}
670+
710671
return proxies;
711672
}
712673

0 commit comments

Comments
 (0)