File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
src/main/java/org/scribe/model Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class Request
2727 private HttpURLConnection connection ;
2828 private String charset ;
2929 private byte [] bytePayload = null ;
30+ private boolean connectionKeepAlive = false ;
3031
3132 /**
3233 * Creates a new Http Request
@@ -67,7 +68,7 @@ private void createConnection() throws IOException
6768 String effectiveUrl = URLUtils .appendParametersToQueryString (url , querystringParams );
6869 if (connection == null )
6970 {
70- System .setProperty ("http.keepAlive" , "false" );
71+ System .setProperty ("http.keepAlive" , connectionKeepAlive ? "true" : "false" );
7172 connection = (HttpURLConnection ) new URL (effectiveUrl ).openConnection ();
7273 }
7374 }
@@ -302,6 +303,17 @@ public void setCharset(String charsetName)
302303 this .charset = charsetName ;
303304 }
304305
306+ /**
307+ * Sets wether the underlying Http Connection is persistent or not.
308+ *
309+ * @see http://download.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html
310+ * @param connectionKeepAlive
311+ */
312+ public void setConnectionKeepAlive (boolean connectionKeepAlive )
313+ {
314+ this .connectionKeepAlive = connectionKeepAlive ;
315+ }
316+
305317 /*
306318 * We need this in order to stub the connection object for test cases
307319 */
You can’t perform that action at this time.
0 commit comments