+\r
+ /**\r
+ * Exhausts a not interesting HTTP response. Encouraged by HttpClient documentation.\r
+ * \r
+ * @param responseBodyAsStream InputStream with the HTTP response to exhaust.\r
+ */\r
+ public void exhaustResponse(InputStream responseBodyAsStream) {\r
+ if (responseBodyAsStream != null) {\r
+ try {\r
+ while (responseBodyAsStream.read(sExhaustBuffer) >= 0);\r
+ responseBodyAsStream.close();\r
+ \r
+ } catch (IOException io) {\r
+ Log.e(TAG, "Unexpected exception while exhausting not interesting HTTP response; will be IGNORED", io);\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * Logs an exception triggered in a HTTP request. \r
+ * \r
+ * @param e Caught exception.\r
+ * @param doing Suffix to add at the end of the logged message.\r
+ */\r
+ private void logException(Exception e, String doing) {\r
+ if (e instanceof HttpException) {\r
+ Log.e(TAG, "HTTP violation while " + doing, e);\r
+\r
+ } else if (e instanceof IOException) {\r
+ Log.e(TAG, "Unrecovered transport exception while " + doing, e);\r
+\r
+ } else {\r
+ Log.e(TAG, "Unexpected exception while " + doing, e);\r
+ }\r
+ }\r
+\r
+ \r
+ /**\r
+ * Sets the connection and wait-for-data timeouts to be applied by default to the methods performed by this client.\r
+ */\r
+ public void setDefaultTimeouts(int defaultDataTimeout, int defaultConnectionTimeout) {\r
+ getParams().setSoTimeout(defaultDataTimeout);\r
+ getHttpConnectionManager().getParams().setConnectionTimeout(defaultConnectionTimeout);\r
+ }\r
+\r
+ /**\r
+ * Sets the base URI for the helper methods that receive paths as parameters, instead of full URLs\r
+ * @param uri\r
+ */\r
+ public void setBaseUri(Uri uri) {\r
+ mUri = uri;\r
+ }\r
+\r
+ public Uri getBaseUri() {\r
+ return mUri;\r
+ }\r
+\r