Kayıtlar

Mayıs, 2018 tarihine ait yayınlar gösteriliyor

Proxy Setting in Apache HttpClient

Problem:  Apache HttpClient does request without system proxy settings. And we want to use jvm proxy settings. Solution:  HttpClient httpclient = new DefaultHttpClient();     try { HttpGet httpget = new HttpGet("http://www.linkedin.com"); HttpHost proxy = new HttpHost(System.getProperty("http.proxyHost"), Integer.parseInt(System.getProperty("http.proxyPort"))); httpclient = new DefaultHttpClient(); httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); if (response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK) {         BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent()));         String line = "";         while ((line = bufferedReader.readLine()) != null) {     stringBuffer.append...