首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

web server 中设立wifi代理

2012-10-19 
web server 中设置wifi代理DefaultHttpClient httpClient new DefaultHttpClient()HttpParams httpPara

web server 中设置wifi代理
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpParams httpParams = httpClient.getParams();
httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 6000);
httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, 6000);
// 设置代理
String proxyIp = "192.168.81.5"; // 此代理为wifi中设置的代理,获取根据实际情况自行设置
String proxyPort = 80;
if (proxyIp != null && proxyPort != -1) {
HttpHost postProxy = new HttpHost(proxyIp, proxyPort);
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, postProxy);  
}

HttpPost httpPost = new HttpPost(serverURL); // 其中serverURL的值根据实际情况自己定义,此处为String类型
httpPost.setEntity(new UrlEncodedFormEntity(params,HTTP.UTF_8));
HttpResponse httpResponse = httpClient.execute(httpPost); //从服务器返回的结果

热点排行