enable persistent http connections

This commit is contained in:
Pablo Fernandez committed 2011-06-03 16:46:16 -03:00
1 parent 203cf83dc0
commit 0c3fc722b1
1 file changed
+13 -1
+13 -1
View File
@@ -27,6 +27,7 @@ class Request
private HttpURLConnection connection;
private String charset;
private byte[] bytePayload = null;
private boolean connectionKeepAlive = false;
/**
* Creates a new Http Request
@@ -67,7 +68,7 @@ class Request
String effectiveUrl = URLUtils.appendParametersToQueryString(url, querystringParams);
if (connection == null)
{
System.setProperty("http.keepAlive", "false");
System.setProperty("http.keepAlive", connectionKeepAlive ? "true" : "false");
connection = (HttpURLConnection) new URL(effectiveUrl).openConnection();
}
}
@@ -302,6 +303,17 @@ class Request
this.charset = charsetName;
}
/**
* Sets wether the underlying Http Connection is persistent or not.
*
* @see http://download.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html
* @param connectionKeepAlive
*/
public void setConnectionKeepAlive(boolean connectionKeepAlive)
{
this.connectionKeepAlive = connectionKeepAlive;
}
/*
* We need this in order to stub the connection object for test cases
*/