3131import org .apache .http .auth .AuthScope ;
3232import org .apache .http .auth .UsernamePasswordCredentials ;
3333import org .apache .http .client .AuthCache ;
34- import org .apache .http .client .CookieStore ;
3534import org .apache .http .client .CredentialsProvider ;
3635import org .apache .http .client .HttpClient ;
3736import org .apache .http .client .entity .UrlEncodedFormEntity ;
3837import org .apache .http .client .methods .HttpGet ;
3938import org .apache .http .client .methods .HttpPost ;
4039import org .apache .http .client .methods .HttpUriRequest ;
41- import org .apache .http .client .params .ClientPNames ;
42- import org .apache .http .client .params .CookiePolicy ;
43- import org .apache .http .client .protocol .ClientContext ;
4440import org .apache .http .client .protocol .HttpClientContext ;
4541import org .apache .http .client .utils .URIBuilder ;
4642import org .apache .http .entity .ContentType ;
@@ -176,7 +172,7 @@ public class SPARQLProtocolSession implements HttpClientDependent {
176172
177173 private final HttpClientContext httpContext ;
178174
179- private final HttpParams params = new BasicHttpParams () ;
175+ private HttpParams params ;
180176
181177 private ParserConfig parserConfig = new ParserConfig ();
182178
@@ -197,10 +193,7 @@ public SPARQLProtocolSession(HttpClient client, ExecutorService executor) {
197193 this .httpContext = new HttpClientContext ();
198194 this .executor = executor ;
199195 valueFactory = SimpleValueFactory .getInstance ();
200- params .setBooleanParameter (ClientPNames .HANDLE_REDIRECTS , true );
201- CookieStore cookieStore = new BasicCookieStore ();
202- httpContext .setAttribute (ClientContext .COOKIE_STORE , cookieStore );
203- params .setParameter (ClientPNames .COOKIE_POLICY , CookiePolicy .RFC_2109 );
196+ httpContext .setCookieStore (new BasicCookieStore ());
204197
205198 // parser used for processing server response data should be lenient
206199 parserConfig .addNonFatalError (BasicParserSettings .VERIFY_DATATYPE_VALUES );
@@ -1114,7 +1107,9 @@ protected HttpResponse execute(HttpUriRequest method)
11141107 throws IOException , RDF4JException
11151108 {
11161109 boolean consume = true ;
1117- method .setParams (params );
1110+ if (params != null ) {
1111+ method .setParams (params );
1112+ }
11181113 HttpResponse response = httpClient .execute (method , httpContext );
11191114
11201115 try {
@@ -1228,6 +1223,9 @@ public ParserConfig getParserConfig() {
12281223 * Gets the http connection read timeout in milliseconds.
12291224 */
12301225 public long getConnectionTimeout () {
1226+ if (params == null ) {
1227+ return 0 ;
1228+ }
12311229 return (long )params .getIntParameter (CoreConnectionPNames .SO_TIMEOUT , 0 );
12321230 }
12331231
@@ -1238,6 +1236,9 @@ public long getConnectionTimeout() {
12381236 * timeout in milliseconds. Zero sets to infinity.
12391237 */
12401238 public void setConnectionTimeout (long timeout ) {
1239+ if (params == null ) {
1240+ params = new BasicHttpParams ();
1241+ }
12411242 params .setIntParameter (CoreConnectionPNames .SO_TIMEOUT , (int )timeout );
12421243 }
12431244}
0 commit comments