From bc5161a9d5069006effab34de5514323367be5f5 Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Fri, 21 Sep 2018 10:29:04 +0200 Subject: [PATCH] Fix JSON default for "Accept: */*" used by curl See https://github.com/hbz/lobid-resources/issues/923 --- web/app/controllers/resources/Accept.java | 2 +- web/test/tests/AcceptIntegrationTest.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/web/app/controllers/resources/Accept.java b/web/app/controllers/resources/Accept.java index 21d3b5ae7..6411df583 100644 --- a/web/app/controllers/resources/Accept.java +++ b/web/app/controllers/resources/Accept.java @@ -19,8 +19,8 @@ private Accept() { } enum Format { - BULK("jsonl", "application/x-jsonlines"), // JSON_LD("json(.+)?", "application/json", "application/ld+json"), // + BULK("jsonl", "application/x-jsonlines"), // HTML("html", "text/html"), // RDF_XML("rdf", "application/rdf+xml", "application/xml", "text/xml"), // N_TRIPLE("nt", "application/n-triples", "text/plain"), // diff --git a/web/test/tests/AcceptIntegrationTest.java b/web/test/tests/AcceptIntegrationTest.java index ef27ccf45..36090763f 100644 --- a/web/test/tests/AcceptIntegrationTest.java +++ b/web/test/tests/AcceptIntegrationTest.java @@ -37,8 +37,11 @@ public static Collection data() { return Arrays.asList(new Object[][] { // search, default format: JSON { fakeRequest(GET, "/resources/search?q=*"), /*->*/ "application/json" }, + { fakeRequest(GET, "/resources/search?q=*").header("Accept", "*/*"), /*->*/ "application/json" }, + { fakeRequest(GET, "/resources/search?q=*").header("Accept", "application/x-jsonlines"), /*->*/ "application/x-jsonlines" }, { fakeRequest(GET, "/resources/search?q=*&format="), /*->*/ "application/json" }, { fakeRequest(GET, "/resources/search?q=*&format=json"), /*->*/ "application/json" }, + { fakeRequest(GET, "/resources/search?q=*&format=jsonl"), /*->*/ "application/x-jsonlines" }, { fakeRequest(GET, "/resources/search?q=*&format=whatever"), /*->*/ "application/json" }, { fakeRequest(GET, "/resources/search?q=*").header("Accept", "text/plain"), /*->*/ "application/json" }, // search, others formats as query param: