spaziocodice / SolRDF

An RDF plugin for Solr
Apache License 2.0
113 stars 20 forks source link

Error 400 when using YASGUI as a frontend #107

Closed hansidm closed 8 years ago

hansidm commented 8 years ago

I am getting the following error when using YASGUI as a frontend to SolRDF

<?xml version="1.0" encoding="UTF-8"?>

4001SPARQL Protocol violation: Cannot determine the POST request type you sent. Content-type must be application/sparql-query or application/sparql-update and body must contains a valid query or update command.400

Here are some details of the request sent Params: query:"PREFIX+rdf:+http://www.w3.org/1999/02/22-rdf-syntax-ns# PREFIX+rdfs:+http://www.w3.org/2000/01/rdf-schema# SELECT+*+WHERE+{ ++?sub+?pred+?obj+. }+ LIMIT+10"

Headers: headers

agazzarini commented 8 years ago

The content-type detection was a bit wrong, as the check was using "equals" instead of "startsWith". The request that caused the failured contained a content-type like

"application/xxx-blabalbal;charset=UTF-8"

so SolRDF, looking for the only mime-type section, rejected the request as "application/xxx-blabalbal;charset=UTF-8" != "application/xxx-blabalbal" and therefore the requested content type was unknown

The change has been applied also to other kind of requests (this issue is related to a SPARQL query but the same error would happen with UPDATE requests). I also added three unit tests for checking the current behaviour correctness.
In the test package org.gazzax.labs.solrdf.handler.search.handler see

Sparql11SearchHandlerTestCase.queryUsingPOSTWithURLEncodedParameters_II()  
Sparql11SearchHandlerTestCase.requestContainsContentType()
Sparql11SearchHandlerTestCase.requestContainsContentType()

@hansidm I'm not closing the issue. Could you please give it a try and (eventually) close it?