split after ; in "Content-Type: text/turtle; utf-8"
authorHenry Story <henry.story@bblfish.net>
Wed, 27 Jun 2012 15:47:56 +0200
changeset 236 d680f5d15862
parent 235 6104e3809b62
child 237 4309422da544
split after ; in "Content-Type: text/turtle; utf-8"
src/main/scala/Lang.scala
src/main/scala/RequestLang.scala
--- a/src/main/scala/Lang.scala	Tue Jun 26 23:05:11 2012 +0200
+++ b/src/main/scala/Lang.scala	Wed Jun 27 15:47:56 2012 +0200
@@ -40,15 +40,17 @@
   
   val default = RDFXML
   
-  def apply(contentType: String): Option[Lang] =
-    contentType.trim.toLowerCase match {
-      case "text/n3" => Some(N3)
-      case "text/turtle" => Some(TURTLE)
-      case "application/rdf+xml" => Some(RDFXML)
-      case "text/html" => Some(HTML)
-      case "application/xhtml+xml" => Some(XHTML)
-      case _ => None
-  }    
+  def apply(contentType: String): Option[Lang] = {
+     val ct = contentType.split(";")(0)
+     ct.trim.toLowerCase match {
+        case "text/n3" => Some(N3)
+        case "text/turtle" => Some(TURTLE)
+        case "application/rdf+xml" => Some(RDFXML)
+        case "text/html" => Some(HTML)
+        case "application/xhtml+xml" => Some(XHTML)
+        case _ => None
+     }
+  }
   
   def apply(cts: Iterable[String]): Option[Lang] =
     cts map Lang.apply collectFirst { case Some(lang) => lang }
--- a/src/main/scala/RequestLang.scala	Tue Jun 26 23:05:11 2012 +0200
+++ b/src/main/scala/RequestLang.scala	Wed Jun 27 15:47:56 2012 +0200
@@ -32,8 +32,10 @@
   def apply(req: HttpRequest[_]): Option[Lang] =
     Lang(RequestContentType(req))
 
-  def unapply(req: HttpRequest[_]): Option[Lang] =
-    Lang(RequestContentType(req))
+  def unapply(req: HttpRequest[_]): Option[Lang] = {
+    val res = Lang(RequestContentType(req))
+    res
+  }
 
   def unapply(ct: String): Option[Lang] =
     Lang(ct)