Permalink
Browse files

add timeout setting

  • Loading branch information...
beartung committed Mar 26, 2012
1 parent 32909bc commit 99944edcb2de98d8a748dece858c22d897c9cd4b
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/com/loopj/android/http/AsyncHttpClient.java
@@ -200,6 +200,17 @@ public void setUserAgent(String userAgent) {
HttpProtocolParams.setUserAgent(this.httpClient.getParams(), userAgent);
}
+ /**
+ * Sets the connection time oout. By default, 10 seconds
+ * @param timeout the connect/socket timeout in milliseconds
+ */
+ public void setTimeout(int timeout){
+ final BasicHttpParams httpParams = this.httpClient.getParams();
+ ConnManagerParams.setTimeout(httpParams, timeout);
+ HttpConnectionParams.setSoTimeout(httpParams, timeout);
+ HttpConnectionParams.setConnectionTimeout(httpParams, timeout);
+ }
+
/**
* Sets the SSLSocketFactory to user when making requests. By default,
* a new, default SSLSocketFactory is used.

0 comments on commit 99944ed

Please sign in to comment.