You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/10/14 19:22:01 UTC
[02/15] jena git commit: Compressing two compression-related settings
into one
Compressing two compression-related settings into one
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/b2c4e61f
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/b2c4e61f
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/b2c4e61f
Branch: refs/heads/master
Commit: b2c4e61fbe0c8512ca45a7f621e0207b855e0649
Parents: 2e8fc56
Author: ajs6f <aj...@virginia.edu>
Authored: Wed Jul 13 10:26:47 2016 -0400
Committer: ajs6f <aj...@virginia.edu>
Committed: Thu Oct 13 16:07:46 2016 -0400
----------------------------------------------------------------------
.../jena/sparql/engine/http/HttpQuery.java | 23 +++--------
.../sparql/engine/http/QueryEngineHTTP.java | 42 +++++---------------
.../apache/jena/sparql/engine/http/Service.java | 12 ++----
.../jena/sparql/engine/http/TestService.java | 21 ++++------
.../java/org/apache/jena/fuseki/TestAuth.java | 6 +--
5 files changed, 28 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/b2c4e61f/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/HttpQuery.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/HttpQuery.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/HttpQuery.java
index 179d730..aceeb13 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/HttpQuery.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/HttpQuery.java
@@ -66,8 +66,7 @@ public class HttpQuery extends Params {
private boolean serviceParams = false;
private final Pattern queryParamPattern = Pattern.compile(".+[&|\\?]query=.*");
private int connectTimeout = 0, readTimeout = 0;
- private boolean allowGZip = false;
- private boolean allowDeflate = false;
+ private boolean allowCompression = false;
private HttpClient client;
private boolean requireClientShutdown = true;
@@ -157,24 +156,14 @@ public class HttpQuery extends Params {
}
/**
- * Sets whether the HTTP request will include a Accept-Encoding: gzip header
- *
- * @param allow
- * Whether to allow GZip encoding
- */
- public void setAllowGZip(boolean allow) {
- allowGZip = allow;
- }
-
- /**
- * Sets whether the HTTP request will include a Accept-Encoding: deflate
+ * Sets whether the HTTP request will include compressed encoding
* header
*
* @param allow
- * Whether to allow Deflate encoding
+ * Whether to allow compressed encoding
*/
- public void setAllowDeflate(boolean allow) {
- allowDeflate = allow;
+ public void setAllowCompression(boolean allow) {
+ allowCompression = allow;
}
/**
@@ -295,7 +284,7 @@ public class HttpQuery extends Params {
private void contextualizeCompressionSettings() {
final RequestConfig.Builder builder = RequestConfig.copy(context.getRequestConfig());
- builder.setContentCompressionEnabled(allowGZip || allowDeflate);
+ builder.setContentCompressionEnabled(allowCompression);
context.setRequestConfig(builder.build());
}
http://git-wip-us.apache.org/repos/asf/jena/blob/b2c4e61f/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java
index 2d8284d..484111d 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/QueryEngineHTTP.java
@@ -80,8 +80,7 @@ public class QueryEngineHTTP implements QueryExecution {
private TimeUnit readTimeoutUnit = TimeUnit.MILLISECONDS;
// Compression Support
- private boolean allowGZip = true;
- private boolean allowDeflate = true;
+ private boolean allowCompression = true;
// Content Types
private String selectContentType = defaultSelectHeader();
@@ -174,8 +173,7 @@ public class QueryEngineHTTP implements QueryExecution {
log.debug("Endpoint URI {} has SERVICE Context: {} ", serviceURI, serviceContext);
// Apply behavioral options
- engine.setAllowGZip(serviceContext.isTrueOrUndef(Service.queryGzip));
- engine.setAllowDeflate(serviceContext.isTrueOrUndef(Service.queryDeflate));
+ engine.setAllowCompression(serviceContext.isTrueOrUndef(Service.queryCompression));
applyServiceTimeouts(engine, serviceContext);
// Apply context-supplied client settings
@@ -256,17 +254,10 @@ public class QueryEngineHTTP implements QueryExecution {
}
/**
- * Sets whether the HTTP request will specify Accept-Encoding: gzip
+ * Sets whether the HTTP requests will permit compressed encoding
*/
- public void setAllowGZip(boolean allowed) {
- allowGZip = allowed;
- }
-
- /**
- * Sets whether the HTTP requests will specify Accept-Encoding: deflate
- */
- public void setAllowDeflate(boolean allowed) {
- allowDeflate = allowed;
+ public void setAllowCompression(boolean allowed) {
+ allowCompression = allowed;
}
public void addParam(String field, String value) {
@@ -570,23 +561,13 @@ public class QueryEngineHTTP implements QueryExecution {
}
/**
- * Gets whether HTTP requests will indicate to the remote server that GZip
- * encoding of responses is accepted
- *
- * @return True if GZip encoding will be accepted
- */
- public boolean getAllowGZip() {
- return allowGZip;
- }
-
- /**
* Gets whether HTTP requests will indicate to the remote server that
- * Deflate encoding of responses is accepted
+ * compressed encoding of responses is accepted
*
- * @return True if Deflate encoding will be accepted
+ * @return True if compressed encoding will be accepted
*/
- public boolean getAllowDeflate() {
- return allowDeflate;
+ public boolean getAllowCompression() {
+ return allowCompression;
}
private static long asMillis(long duration, TimeUnit timeUnit) {
@@ -613,11 +594,8 @@ public class QueryEngineHTTP implements QueryExecution {
if (params != null)
httpQuery.merge(params);
- if (allowGZip)
- httpQuery.setAllowGZip(true);
+ httpQuery.setAllowCompression(allowCompression);
- if (allowDeflate)
- httpQuery.setAllowDeflate(true);
httpQuery.setClient(client);
http://git-wip-us.apache.org/repos/asf/jena/blob/b2c4e61f/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/Service.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/Service.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/Service.java
index 081a822..ae3f153 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/Service.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/http/Service.java
@@ -50,14 +50,9 @@ public class Service {
public static final String base = "http://jena.hpl.hp.com/Service#";
/**
- * Use to set the HttpQuery.allowDeflate flag.
+ * Use to set the HttpQuery.allowCompression flag.
*/
- public static final Symbol queryDeflate = SystemARQ.allocSymbol(base, "queryDeflate");
-
- /**
- * Use to set the HttpQuery.allowGZip flag.
- */
- public static final Symbol queryGzip = SystemARQ.allocSymbol(base, "queryGzip");
+ public static final Symbol queryCompression = SystemARQ.allocSymbol(base, "queryCompression");
/**
* Use to set the HTTP client for a service.
@@ -227,8 +222,7 @@ public class Service {
// configure the query object.
httpQuery.merge(QueryEngineHTTP.getServiceParams(uri, context));
httpQuery.addParam(HttpParams.pQuery, query.toString());
- httpQuery.setAllowGZip(context.isTrueOrUndef(queryGzip));
- httpQuery.setAllowDeflate(context.isTrueOrUndef(queryDeflate));
+ httpQuery.setAllowCompression(context.isTrueOrUndef(queryCompression));
HttpClient client = context.get(queryClient);
if (client != null) httpQuery.setClient(client);
http://git-wip-us.apache.org/repos/asf/jena/blob/b2c4e61f/jena-arq/src/test/java/org/apache/jena/sparql/engine/http/TestService.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/engine/http/TestService.java b/jena-arq/src/test/java/org/apache/jena/sparql/engine/http/TestService.java
index 8ca1294..9a10fd4 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/engine/http/TestService.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/engine/http/TestService.java
@@ -154,8 +154,7 @@ public class TestService {
// Check that no settings were changed
Assert.assertEquals(-1, engine.getTimeout1());
Assert.assertEquals(-1, engine.getTimeout2());
- Assert.assertTrue(engine.getAllowGZip());
- Assert.assertTrue(engine.getAllowDeflate());
+ Assert.assertTrue(engine.getAllowCompression());
Assert.assertNull(engine.getClient());
}
@@ -184,8 +183,7 @@ public class TestService {
// Check that no settings were changed
Assert.assertEquals(-1, engine.getTimeout1());
Assert.assertEquals(-1, engine.getTimeout2());
- Assert.assertTrue(engine.getAllowGZip());
- Assert.assertTrue(engine.getAllowDeflate());
+ Assert.assertTrue(engine.getAllowCompression());
Assert.assertEquals(testClient, engine.getClient());
} finally {
@@ -216,8 +214,7 @@ public class TestService {
// Check that no settings were changed
Assert.assertEquals(-1, engine.getTimeout1());
Assert.assertEquals(10, engine.getTimeout2());
- Assert.assertTrue(engine.getAllowGZip());
- Assert.assertTrue(engine.getAllowDeflate());
+ Assert.assertTrue(engine.getAllowCompression());
Assert.assertNull(engine.getClient());
} finally {
serviceContext.remove(Service.queryTimeout);
@@ -247,8 +244,7 @@ public class TestService {
// Check that no settings were changed
Assert.assertEquals(20, engine.getTimeout1());
Assert.assertEquals(10, engine.getTimeout2());
- Assert.assertTrue(engine.getAllowGZip());
- Assert.assertTrue(engine.getAllowDeflate());
+ Assert.assertTrue(engine.getAllowCompression());
Assert.assertNull(engine.getClient());
} finally {
serviceContext.remove(Service.queryTimeout);
@@ -269,8 +265,7 @@ public class TestService {
}
Context serviceContext = serviceContextMap.get(SERVICE);
try {
- serviceContext.put(Service.queryGzip, false);
- serviceContext.put(Service.queryDeflate, false);
+ serviceContext.put(Service.queryCompression, false);
Query q = QueryFactory.create("ASK { }");
QueryEngineHTTP engine = QueryExecutionFactory.createServiceRequest(SERVICE, q);
@@ -279,12 +274,10 @@ public class TestService {
// Check that no settings were changed
Assert.assertEquals(-1, engine.getTimeout1());
Assert.assertEquals(-1, engine.getTimeout2());
- Assert.assertFalse(engine.getAllowGZip());
- Assert.assertFalse(engine.getAllowDeflate());
+ Assert.assertFalse(engine.getAllowCompression());
Assert.assertNull(engine.getClient());
} finally {
- serviceContext.remove(Service.queryGzip);
- serviceContext.remove(Service.queryDeflate);
+ serviceContext.remove(Service.queryCompression);
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/b2c4e61f/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAuth.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAuth.java b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAuth.java
index 49e6a37..5fc988f 100644
--- a/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAuth.java
+++ b/jena-fuseki2/jena-fuseki-core/src/test/java/org/apache/jena/fuseki/TestAuth.java
@@ -140,8 +140,7 @@ public class TestAuth {
public void query_with_auth_05() {
// Uses auth and enables compression
QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
- qe.setAllowDeflate(true);
- qe.setAllowGZip(true);
+ qe.setAllowCompression(true);
// Auth credentials for valid user with correct password
qe.setClient(withBasicAuth(ANY, "allowed", "password"));
@@ -152,8 +151,7 @@ public class TestAuth {
public void query_with_auth_06() {
// Uses auth and enables compression
QueryEngineHTTP qe = (QueryEngineHTTP) QueryExecutionFactory.sparqlService(authServiceQuery, "ASK { }");
- qe.setAllowDeflate(true);
- qe.setAllowGZip(true);
+ qe.setAllowCompression(true);
// Auth credentials for valid user with bad password
qe.setClient(withBasicAuth(ANY, "allowed", "incorrect"));