- MkColMethod mkcol = new MkColMethod(mUri.toString() + path);\r
- int status = executeMethod(mkcol);\r
- Log.d(TAG, "Status returned " + status);\r
- Log.d(TAG, "uri: " + mkcol.getURI().toString());\r
- Log.i(TAG, "Creating dir completed");\r
- } catch (final Exception e) {\r
- e.printStackTrace();\r
- return false;\r
+ if (readTimeout >= 0) { \r
+ method.getParams().setSoTimeout(readTimeout); // this should be enough...\r
+ getParams().setSoTimeout(readTimeout); // ... but this looks like necessary for HTTPS\r
+ }\r
+ if (connectionTimeout >= 0) {\r
+ getHttpConnectionManager().getParams().setConnectionTimeout(connectionTimeout);\r
+ }\r
+ return executeMethod(method);\r
+ } finally {\r
+ getParams().setSoTimeout(oldSoTimeout);\r
+ getHttpConnectionManager().getParams().setConnectionTimeout(oldConnectionTimeout);\r
+ }\r
+ }\r
+\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