- intlogger.info("ProxyServlet: proxying with fallback GET "+url);
- try(AbstractHttpClient httpclient = new DefaultHttpClient()){
- HttpRequestBase proxy = new HttpGet(url);
- try {
- httpclient.getConnectionManager().getSchemeRegistry().register(sch);
-
- // Copy request headers and request body
- copyRequestHeaders(req, proxy);
-
- // Execute the request
- HttpResponse pxy_response = httpclient.execute(proxy);
-
- // Get response headers and body
- int code = pxy_response.getStatusLine().getStatusCode();
- resp.setStatus(code);
- copyResponseHeaders(pxy_response, resp);
-
- HttpEntity entity = pxy_response.getEntity();
- if (entity != null) {
- InputStream in = entity.getContent();
- IOUtils.copy(in, resp.getOutputStream());
- in.close();
+ intlogger.info("ProxyServlet: proxying with fallback GET " + url);
+ try (AbstractHttpClient httpclient = new DefaultHttpClient()) {
+ HttpRequestBase proxy = new HttpGet(url);
+ try {
+ httpclient.getConnectionManager().getSchemeRegistry().register(sch);
+
+ // Copy request headers and request body
+ copyRequestHeaders(req, proxy);
+
+ // Execute the request
+ HttpResponse pxyResponse = httpclient.execute(proxy);
+
+ // Get response headers and body
+ int code = pxyResponse.getStatusLine().getStatusCode();
+ resp.setStatus(code);
+ copyResponseHeaders(pxyResponse, resp);
+ copyEntityContent(pxyResponse, resp);
+ rv = true;
+
+ } catch (IOException e) {
+ intlogger.error("ProxyServlet.doGetWithFallback: " + e.getMessage(), e);
+ } finally {
+ proxy.releaseConnection();
+ httpclient.getConnectionManager().shutdown();