From 9a53ce07f1a99b45d5ff74152c7d1f1d01c395dc Mon Sep 17 00:00:00 2001 From: Nathan Doef Date: Thu, 21 Mar 2024 12:05:50 -0400 Subject: [PATCH] Revert "Retain X-Request-ID header key casing in responses (#5787)" This reverts commit 7742aa76c5c8a2f9eec0ce35ffcfa8fd6f89f82d. --- ...788-retain-x-request-id-header-casing.yaml | 6 ----- .../fhir/jpa/provider/r4/ServerR4Test.java | 27 ------------------- .../uhn/fhir/rest/server/RestfulServer.java | 9 +------ .../rest/server/ServerConcurrencyTest.java | 19 ++++--------- 4 files changed, 6 insertions(+), 55 deletions(-) delete mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_2_0/5788-retain-x-request-id-header-casing.yaml diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_2_0/5788-retain-x-request-id-header-casing.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_2_0/5788-retain-x-request-id-header-casing.yaml deleted file mode 100644 index d9a5d1ab36a..00000000000 --- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_2_0/5788-retain-x-request-id-header-casing.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- -type: fix -issue: 5788 -title: "Previously, the casing of the X-Request-ID header key was not retained in the corresponding response. -This has been fixed." - diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerR4Test.java index 2a7abc1c9cc..75f3e142cc2 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerR4Test.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ServerR4Test.java @@ -7,7 +7,6 @@ import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException; import ca.uhn.fhir.util.ExtensionConstants; import org.apache.commons.io.IOUtils; -import org.apache.http.Header; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.hl7.fhir.r4.model.CapabilityStatement; @@ -16,15 +15,11 @@ import org.hl7.fhir.r4.model.CapabilityStatement.CapabilityStatementRestResource import org.hl7.fhir.r4.model.Extension; import org.hl7.fhir.r4.model.Patient; import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; import org.springframework.beans.factory.annotation.Autowired; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.HashSet; -import java.util.List; import java.util.Set; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -146,26 +141,4 @@ public class ServerR4Test extends BaseResourceProviderR4Test { } - - @ParameterizedTest - @ValueSource(strings = {"x-request-id", "X-Request-Id", "X-Request-ID", "X-REQUEST-ID"}) - public void testXRequestIdHeaderRetainsCase(String theXRequestIdHeaderKey) throws Exception { - HttpGet get = new HttpGet(myServerBase + "/Patient"); - String xRequestIdHeaderValue = "abc123"; - get.addHeader(theXRequestIdHeaderKey, xRequestIdHeaderValue); - - try (CloseableHttpResponse response = ourHttpClient.execute(get)) { - assertEquals(200, response.getStatusLine().getStatusCode()); - - String responseContent = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8); - ourLog.debug(responseContent); - - List
xRequestIdHeaders = Arrays.stream(response.getAllHeaders()) - .filter(header -> theXRequestIdHeaderKey.equals(header.getName())) - .toList(); - - assertEquals(1, xRequestIdHeaders.size()); - assertEquals(xRequestIdHeaderValue, xRequestIdHeaders.get(0).getValue()); - } - } } diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java index d3386e5b9b1..8906c74af4a 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java @@ -1325,14 +1325,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer(); }); - when(myRequest.getHeaderNames()).thenAnswer(t -> { - Set headerNames = myHeaders.keySet(); - if (!isEmpty(headerNames)){ - return new IteratorEnumeration<>(headerNames.iterator()); - } - return new EmptyEnumeration<>(); - }); } /**