简体   繁体   中英

How to use httpurlconnection.openconnection without any proxy if the proxy is set at Global level?

My application uses some proxy which is set at global level.So,even after doing httpurlconnection.openconnection (not httpurlconnection.openconnection (proxy) which takes proxy as parameter) ,the connection is made through the proxy. I would like to know if I can not use the default proxy in cases?

Apologies if the question was not clear.I finally figured it out myself.If proxy is set at system level,httpurlconnection.openconnection() will use the proxy even if we do not pass a proxy object.However to override it we can use -

httpurlconnection.openconnection(Proxy.NO_PROXY)

By passing NO_PROXY the connection will not use proxy for the connection even if it is set as global level.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM