Android: Unable to make httprequest behind firewall

后端 未结 2 1177
栀梦
栀梦 2021-01-07 08:16

The standard getUrlContent works welll when there is no firewall. But I got exceptions when I try to do it behind a firewall.

I\'ve tried to set \"http proxy server

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-07 08:32

    You can set proxy in your code too.

       public void setProxy(DefaultHttpClient httpclient) {  
               final String PROXY_IP = "";  
                final int PROXY_PORT = ;  
    
                httpclient.getCredentialsProvider().setCredentials(  
                        new AuthScope(PROXY_IP, PROXY_PORT),  
                        new UsernamePasswordCredentials(  
                                "username", "password"));  
    
               HttpHost proxy = new HttpHost(PROXY_IP, PROXY_PORT);  
    
               httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,  
                       proxy);  
    
    
           }  
    

提交回复
热议问题