Makes the format from MIME type converter accept more MIME types

pull/41/head
Tpt 4 years ago
parent 955249b3e6
commit 71016ce475
  1. 4
      lib/src/sparql/model.rs
  2. 14
      lib/src/syntax.rs
  3. 2
      server/src/main.rs

@ -106,10 +106,10 @@ impl FileSyntax for QueryResultSyntax {
fn from_mime_type(media_type: &str) -> Option<Self> {
if let Some(base_type) = media_type.split(';').next() {
match base_type {
"application/xml" | "application/sparql-results+xml" => {
"application/sparql-results+xml" | "application/xml" | "text/xml" => {
Some(QueryResultSyntax::Xml)
}
"application/json" | "application/sparql-results+json" => {
"application/sparql-results+json" | "application/json" | "text/json" => {
Some(QueryResultSyntax::Json)
}
_ => None,

@ -60,9 +60,11 @@ impl FileSyntax for GraphSyntax {
fn from_mime_type(media_type: &str) -> Option<Self> {
if let Some(base_type) = media_type.split(';').next() {
match base_type {
"application/n-triples" => Some(GraphSyntax::NTriples),
"text/turtle" => Some(GraphSyntax::Turtle),
"application/xml" | "application/rdf+xml" => Some(GraphSyntax::RdfXml),
"application/n-triples" | "text/plain" => Some(GraphSyntax::NTriples),
"text/turtle" | "application/turtle" | "application/x-turtle" => {
Some(GraphSyntax::Turtle)
}
"application/rdf+xml" | "application/xml" | "text/xml" => Some(GraphSyntax::RdfXml),
_ => None,
}
} else {
@ -105,8 +107,10 @@ impl FileSyntax for DatasetSyntax {
fn from_mime_type(media_type: &str) -> Option<Self> {
if let Some(base_type) = media_type.split(';').next() {
match base_type {
"application/n-quads" => Some(DatasetSyntax::NQuads),
"application/trig" => Some(DatasetSyntax::TriG),
"application/n-quads" | "text/x-nquads" | "text/nquads" => {
Some(DatasetSyntax::NQuads)
}
"application/trig" | "application/x-trig" => Some(DatasetSyntax::TriG),
_ => None,
}
} else {

@ -343,7 +343,7 @@ mod tests {
#[test]
fn post_unsupported_file() {
let mut request = Request::new(Method::Post, Url::parse("http://localhost/").unwrap());
request.insert_header("Content-Type", "text/plain");
request.insert_header("Content-Type", "text/foo");
exec(request, StatusCode::UnsupportedMediaType)
}

Loading…
Cancel
Save