Skip to content

Commit f78aa60

Browse files
committed
Merge pull request android-async-http#45 from BearTung/master
add timeout setting
2 parents 32909bc + 99944ed commit f78aa60

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/com/loopj/android/http/AsyncHttpClient.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,17 @@ public void setUserAgent(String userAgent) {
200200
HttpProtocolParams.setUserAgent(this.httpClient.getParams(), userAgent);
201201
}
202202

203+
/**
204+
* Sets the connection time oout. By default, 10 seconds
205+
* @param timeout the connect/socket timeout in milliseconds
206+
*/
207+
public void setTimeout(int timeout){
208+
final BasicHttpParams httpParams = this.httpClient.getParams();
209+
ConnManagerParams.setTimeout(httpParams, timeout);
210+
HttpConnectionParams.setSoTimeout(httpParams, timeout);
211+
HttpConnectionParams.setConnectionTimeout(httpParams, timeout);
212+
}
213+
203214
/**
204215
* Sets the SSLSocketFactory to user when making requests. By default,
205216
* a new, default SSLSocketFactory is used.

0 commit comments

Comments
 (0)