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 {
@@ -1225,6 +1220,9 @@ public ParserConfig getParserConfig() {
12251220 * Gets the http connection read timeout in milliseconds.
12261221 */
12271222 public long getConnectionTimeout () {
1223+ if (params == null ) {
1224+ return 0 ;
1225+ }
12281226 return (long )params .getIntParameter (CoreConnectionPNames .SO_TIMEOUT , 0 );
12291227 }
12301228
@@ -1235,6 +1233,9 @@ public long getConnectionTimeout() {
12351233 * timeout in milliseconds. Zero sets to infinity.
12361234 */
12371235 public void setConnectionTimeout (long timeout ) {
1236+ if (params == null ) {
1237+ params = new BasicHttpParams ();
1238+ }
12381239 params .setIntParameter (CoreConnectionPNames .SO_TIMEOUT , (int )timeout );
12391240 }
12401241}
0 commit comments