+ public String getResponseContent(HttpResponse response) {\r
+ HttpEntity entity = response.getEntity();\r
+ InputStream is = null;\r
+ if (entity != null) {\r
+ try {\r
+ is = entity.getContent();\r
+ final ContentType contentType = ContentType.getOrDefault(entity);\r
+ Charset charset = contentType.getCharset();\r
+ if (charset == null) {\r
+ charset = HTTP.DEF_CONTENT_CHARSET;\r
+ }\r
+ final StringBuilder b = new StringBuilder();\r
+ final char[] tmp = new char[1024];\r
+ final Reader reader = new InputStreamReader(is, charset);\r
+ try {\r
+ int l;\r
+ while ((l = reader.read(tmp)) != -1) {\r
+ b.append(tmp, 0, l);\r
+ }\r
+ } catch (ConnectionClosedException ignore) {\r
+\r
+ } catch (IOException e) {\r
+ log.info("Failed to read the contents of the input stream of the http entity.", e);\r
+ }\r
+ return b.toString();\r
+ } catch (IOException e) {\r
+ log.info("Failed to read the contents of the http entity.", e);\r
+ } finally {\r
+ try {\r
+ if (is != null) {\r
+ is.close();\r
+ }\r
+ } catch (IOException e) {\r
+ log.info("Failed to close the input stream of the http entity.", e);\r
+ }\r
+ }\r
+ }\r
+ return "{}";\r
+ }\r
+\r