List of usage examples for org.apache.http.conn HttpHostConnectException getHost
public HttpHost getHost()
From source file:org.ambraproject.wombat.service.remote.ServiceConnectionException.java
ServiceConnectionException(HttpHostConnectException e) { super("Could not connect to: " + e.getHost(), e); }
From source file:com.appnexus.opensdk.AdRequest.java
private AdResponse doRequest() { String query_string = getRequestUrl(); Clog.setLastRequest(query_string);/*from w w w . j a va2s .c o m*/ Clog.d(Clog.httpReqLogTag, Clog.getString(R.string.fetch_url, query_string)); HttpResponse r = null; String out = null; try { HttpParams p = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(p, Settings.getSettings().HTTP_CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(p, Settings.getSettings().HTTP_SOCKET_TIMEOUT); HttpConnectionParams.setSocketBufferSize(p, 8192); DefaultHttpClient h = new DefaultHttpClient(p); r = h.execute(new HttpGet(query_string)); if (!httpShouldContinue(r.getStatusLine())) { return AdRequest.HTTP_ERROR; } out = EntityUtils.toString(r.getEntity()); } catch (ClientProtocolException e) { Clog.e(Clog.httpReqLogTag, Clog.getString(R.string.http_unknown)); return AdRequest.CONNECTIVITY_RETRY; } catch (ConnectTimeoutException e) { Clog.e(Clog.httpReqLogTag, Clog.getString(R.string.http_timeout)); return AdRequest.CONNECTIVITY_RETRY; } catch (HttpHostConnectException he) { Clog.e(Clog.httpReqLogTag, Clog.getString(R.string.http_unreachable, he.getHost().getHostName(), he.getHost().getPort())); return AdRequest.CONNECTIVITY_RETRY; } catch (IOException e) { Clog.e(Clog.httpReqLogTag, Clog.getString(R.string.http_io)); return AdRequest.CONNECTIVITY_RETRY; } catch (SecurityException se) { Clog.e(Clog.baseLogTag, Clog.getString(R.string.permissions_internet)); return null; } catch (Exception e) { e.printStackTrace(); Clog.e(Clog.baseLogTag, Clog.getString(R.string.unknown_exception)); return AdRequest.CONNECTIVITY_RETRY; } if (out.equals("")) { Clog.e(Clog.httpRespLogTag, Clog.getString(R.string.response_blank)); return AdRequest.BLANK_RETRY; } return new AdResponse(out, r.getAllHeaders()); }