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 2018/09/21 10:16:04 UTC
[53/70] [abbrv] jena git commit: Wrongly setting Content-Encoding
Wrongly setting Content-Encoding
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/eba45652
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/eba45652
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/eba45652
Branch: refs/heads/master
Commit: eba45652dee1a4ab9f87dbe10a1cf13058196b1b
Parents: 9451f19
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Sep 8 21:40:19 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Sep 8 21:54:07 2018 +0100
----------------------------------------------------------------------
.../java/org/apache/jena/riot/web/HttpOp.java | 26 ++++++++++++++------
1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/eba45652/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java b/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
index 80eaf01..685dd41 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/web/HttpOp.java
@@ -493,7 +493,7 @@ public class HttpOp {
* HTTP Context
*/
public static void execHttpPost(String url, String contentType, String content, String acceptType,
- HttpResponseHandler handler, HttpClient httpClient, HttpContext httpContext) {
+ HttpResponseHandler handler, HttpClient httpClient, HttpContext httpContext) {
StringEntity e = null;
try {
e = new StringEntity(content, StandardCharsets.UTF_8);
@@ -557,7 +557,7 @@ public class HttpOp {
* Response handler called to process the response
*/
public static void execHttpPost(String url, String contentType, InputStream input, long length, String acceptType,
- HttpResponseHandler handler) {
+ HttpResponseHandler handler) {
execHttpPost(url, contentType, input, length, acceptType, handler, null, null);
}
@@ -587,17 +587,17 @@ public class HttpOp {
*
*/
public static void execHttpPost(String url, String contentType, InputStream input, long length, String acceptType,
- HttpResponseHandler handler, HttpClient httpClient, HttpContext httpContext) {
+ HttpResponseHandler handler, HttpClient httpClient, HttpContext httpContext) {
InputStreamEntity e = new InputStreamEntity(input, length);
- e.setContentType(contentType);
- e.setContentEncoding("UTF-8");
+ String ct = decideContentType(contentType);
+ e.setContentType(ct);
try {
execHttpPost(url, e, acceptType, handler, httpClient, httpContext);
} finally {
closeEntity(e);
}
}
-
+
/**
* Executes a HTTP POST of the given entity
*
@@ -932,8 +932,8 @@ public class HttpOp {
public static void execHttpPut(String url, String contentType, InputStream input, long length, HttpClient httpClient,
HttpContext httpContext) {
InputStreamEntity e = new InputStreamEntity(input, length);
- e.setContentType(contentType);
- e.setContentEncoding("UTF-8");
+ String ct = decideContentType(contentType);
+ e.setContentType(ct);
try {
execHttpPut(url, e, httpClient, httpContext);
} finally {
@@ -1130,6 +1130,16 @@ public class HttpOp {
}
/**
+ * Content-Type, ensuring charset is present, defaulting to UTF-8.
+ */
+ private static String decideContentType(String contentType) {
+ String ct = contentType;
+ if ( ct != null && ! ct.contains("charset=") )
+ ct = ct+"; charset=UTF-8";
+ return ct;
+ }
+
+ /**
* Calculate the request URI from a general URI. This means remove any
* fragment.
*/