Fix #250 - Honour Accept: text/xml and Accept: text/json
This commit is contained in:
parent
4545b4fb7f
commit
6fd5aecec7
|
@ -160,6 +160,7 @@ public class Constants {
|
||||||
|
|
||||||
HashSet<String> valXml = new HashSet<String>();
|
HashSet<String> valXml = new HashSet<String>();
|
||||||
valXml.add(CT_FHIR_XML);
|
valXml.add(CT_FHIR_XML);
|
||||||
|
valXml.add("text/xml");
|
||||||
valXml.add("application/xml");
|
valXml.add("application/xml");
|
||||||
valXml.add("xml");
|
valXml.add("xml");
|
||||||
FORMAT_VAL_XML = Collections.unmodifiableSet(valXml);
|
FORMAT_VAL_XML = Collections.unmodifiableSet(valXml);
|
||||||
|
@ -169,6 +170,7 @@ public class Constants {
|
||||||
|
|
||||||
HashSet<String> valJson = new HashSet<String>();
|
HashSet<String> valJson = new HashSet<String>();
|
||||||
valJson.add(CT_FHIR_JSON);
|
valJson.add(CT_FHIR_JSON);
|
||||||
|
valJson.add("text/json");
|
||||||
valJson.add("application/json");
|
valJson.add("application/json");
|
||||||
valJson.add("json");
|
valJson.add("json");
|
||||||
FORMAT_VAL_JSON = Collections.unmodifiableSet(valJson);
|
FORMAT_VAL_JSON = Collections.unmodifiableSet(valJson);
|
||||||
|
|
|
@ -162,6 +162,10 @@ public class ServerFeaturesTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Header value should be application/xml+fhir or application/json+fhir but
|
||||||
|
* we should also accept application/xml and application/json
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testAcceptHeaderNonFhirTypes() throws Exception {
|
public void testAcceptHeaderNonFhirTypes() throws Exception {
|
||||||
|
|
||||||
|
@ -183,6 +187,31 @@ public class ServerFeaturesTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Header value should be application/xml+fhir or application/json+fhir but
|
||||||
|
* we should also accept text/xml and text/json
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testAcceptHeaderNonFhirTypesNonStandard() throws Exception {
|
||||||
|
|
||||||
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/1");
|
||||||
|
httpGet.addHeader("Accept", "text/xml");
|
||||||
|
CloseableHttpResponse status = ourClient.execute(httpGet);
|
||||||
|
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
assertThat(responseContent, StringContains.containsString("<identifier><use"));
|
||||||
|
|
||||||
|
httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/1");
|
||||||
|
httpGet.addHeader("Accept", "text/json");
|
||||||
|
status = ourClient.execute(httpGet);
|
||||||
|
responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
|
assertThat(responseContent, StringContains.containsString("\"identifier\":"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHardcodedAddressStrategy() throws Exception {
|
public void testHardcodedAddressStrategy() throws Exception {
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
Narrative generator did not include OperationOutcome.issue.diagnostics in the
|
Narrative generator did not include OperationOutcome.issue.diagnostics in the
|
||||||
generated narrative.
|
generated narrative.
|
||||||
</action>
|
</action>
|
||||||
<action type="add">
|
<action type="add" issue="250">
|
||||||
Clients (generic and annotation) did not populate the Accept header on outgoing
|
Clients (generic and annotation) did not populate the Accept header on outgoing
|
||||||
requests. This is now populated to indicate that the client supports both XML and
|
requests. This is now populated to indicate that the client supports both XML and
|
||||||
JSON unless the user has explicitly requested one or the other (in which case the
|
JSON unless the user has explicitly requested one or the other (in which case the
|
||||||
|
@ -234,6 +234,12 @@
|
||||||
search. This is experimental, since it is not a part of the core
|
search. This is experimental, since it is not a part of the core
|
||||||
FHIR specification.
|
FHIR specification.
|
||||||
</action>
|
</action>
|
||||||
|
<action type="add" fix="250">
|
||||||
|
Process "Accept: text/xml" and "Accept: text/json" headers was
|
||||||
|
wanting the equivalent FHIR encoding styles. These are not
|
||||||
|
correct, but the intention is clear so we will honour them
|
||||||
|
just to be helpful.
|
||||||
|
</action>
|
||||||
</release>
|
</release>
|
||||||
<release version="1.2" date="2015-09-18">
|
<release version="1.2" date="2015-09-18">
|
||||||
<action type="add">
|
<action type="add">
|
||||||
|
|
Loading…
Reference in New Issue