Skip to content

Commit

Permalink
JENA-873 : Fix for absence of Content-Type in a POST.
Browse files Browse the repository at this point in the history
  • Loading branch information
afs committed Jan 29, 2015
1 parent aafd5d6 commit 2b79b0e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,30 @@ protected void doOptions(HttpServletRequest request, HttpServletResponse respons
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) ;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,11 @@ protected final void perform(HttpAction action) {
}

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 ;
}
Expand All @@ -115,7 +116,7 @@ protected final void perform(HttpAction action) {
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
Expand Down Expand Up @@ -170,8 +171,10 @@ protected void validateParams(HttpAction action, Collection<String> params) {

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) ;
}
Expand Down

0 comments on commit 2b79b0e

Please sign in to comment.