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 2015/01/29 18:41:41 UTC

jena git commit: JENA-873 : Fix for absence of Content-Type in a POST.

Repository: jena
Updated Branches:
  refs/heads/master aafd5d644 -> 2b79b0efb


JENA-873 : Fix for absence of Content-Type in a POST.

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/2b79b0ef
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/2b79b0ef
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/2b79b0ef

Branch: refs/heads/master
Commit: 2b79b0efbad2d1082a0869011de1e8395bbc88a4
Parents: aafd5d6
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Jan 29 16:30:12 2015 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Jan 29 16:30:12 2015 +0000

----------------------------------------------------------------------
 .../apache/jena/fuseki/servlets/SPARQL_Query.java | 18 ++++++++++--------
 .../apache/jena/fuseki/servlets/SPARQL_Query.java | 13 ++++++++-----
 2 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/2b79b0ef/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
----------------------------------------------------------------------
diff --git a/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java b/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
index 9de80bc..06f8340 100644
--- a/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
+++ b/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
@@ -78,28 +78,30 @@ public abstract class SPARQL_Query extends SPARQL_Protocol
     protected final void perform(HttpAction action)
     {
         // GET
-        if ( action.request.getMethod().equals(HttpNames.METHOD_GET) )
-        {
+        if ( action.request.getMethod().equals(HttpNames.METHOD_GET) ) {
             executeWithParameter(action) ;
             return ;
         }
 
         ContentType ct = FusekiLib.getContentType(action) ;
+        if ( ct == null ) {
+            // Validation check it's POST with ?query=
+            executeWithParameter(action) ;
+            return ;
+        }
+        
         String incoming = ct.getContentType() ;
-
         // POST application/sparql-query
-        if (WebContent.contentTypeSPARQLQuery.equals(incoming))
-        {
+        if (WebContent.contentTypeSPARQLQuery.equals(incoming)) {
             executeBody(action) ;
             return ;
         }
         // POST application/x-www-form-url
-        if (WebContent.contentTypeHTMLForm.equals(incoming))
-        {
+        if (WebContent.contentTypeHTMLForm.equals(incoming)) {
             executeWithParameter(action) ;
             return ;
         }
-
+        
         error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Bad content type: "+incoming) ;
     }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/2b79b0ef/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
index 6ab3f71..5a70c7b 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
@@ -101,10 +101,11 @@ public abstract class SPARQL_Query extends SPARQL_Protocol
         }
 
         ContentType ct = FusekiLib.getContentType(action) ;
-        String incoming = ct.getContentType() ;
 
         // POST application/x-www-form-url
-        if ( isHtmlForm(ct) ) {
+        // POST ?query= and no Content-Type
+        if ( ct == null || isHtmlForm(ct) ) {
+            // validation checked that if no Content-type, then its a POST with ?query=
             executeWithParameter(action) ;
             return ;
         }
@@ -115,7 +116,7 @@ public abstract class SPARQL_Query extends SPARQL_Protocol
             return ;
         }
 
-        ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Bad content type: " + incoming) ;
+        ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Bad content type: " + ct.getContentType()) ;
     }
 
     // All the params we support
@@ -170,8 +171,10 @@ public abstract class SPARQL_Query extends SPARQL_Protocol
 
             if ( matchContentType(ctSPARQLQuery, ct) ) {
                 mustHaveQueryParam = false ;
-            } else if ( matchContentType(ctHTMLForm, ct))
-            {} 
+                // Drop through.
+            } else if ( matchContentType(ctHTMLForm, ct)) {
+                // Nothing specific to do
+            } 
             else
                 ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Unsupported: " + incoming) ;
         }