Fixed bug where POST on "Content-Type: application/sparql-query; charset=UTF-8" did not work
--- a/src/main/scala/Post.scala Fri Jun 01 22:54:08 2012 +0200
+++ b/src/main/scala/Post.scala Fri Jun 01 22:59:50 2012 +0200
@@ -27,6 +27,11 @@
val supportContentTypes = Lang.supportContentTypes ++ Image.supportedImages.map(_.contentType) + SPARQL
val supportedAsString = supportContentTypes mkString ", "
+ def supportsContentType(contentTypeHeader: String) = {
+ supportContentTypes.contains(cleanHeader(contentTypeHeader))
+ }
+
+ def cleanHeader(headerVal: String) = headerVal.split(";")(0).trim
val logger: Logger = LoggerFactory.getLogger(this.getClass)
@@ -34,7 +39,7 @@
is: InputStream,
base: URL,
contentType: String): Post = {
- assert(supportContentTypes contains contentType)
+ assert(supportsContentType(contentType))
val inAsString = {
val source = Source.fromInputStream(is, "UTF-8")
@@ -61,7 +66,7 @@
}
- contentType match {
+ cleanHeader(contentType) match {
case SPARQL => postUpdate | (postQuery | PostUnknown)
case RequestLang(lang) => postRDF(lang) | PostUnknown
case GIF.contentType | JPEG.contentType | PNG.contentType => PostBinary(is)
--- a/src/main/scala/ReadWriteWeb.scala Fri Jun 01 22:54:08 2012 +0200
+++ b/src/main/scala/ReadWriteWeb.scala Fri Jun 01 22:59:50 2012 +0200
@@ -149,7 +149,7 @@
}
}
}
- case POST(_) & RequestContentType(ct) if Post.supportContentTypes contains ct => {
+ case POST(_) & RequestContentType(ct) if Post.supportsContentType(ct) => {
Post.parse(Body.stream(req), uri, ct) match {
case PostUnknown => {
logger.info("Couldn't parse the request")