FHIR Chat · Content-Type header changed when InvalidRequestError · hapi

Stream: hapi

Topic: Content-Type header changed when InvalidRequestError


view this post on Zulip Hershil Patel (Aug 23 2021 at 13:51):

In my plain provider, I have a custom server level operation. In this operation I need the Content-Type header of the response to be application/json . I set it using:

 theRequestDetails.getServletResponse().setHeader("Content-Type", "application/json");

This works. However, when I throw an InvalidRequestException in my plain provider, for some reason it changes the Content-Type of the response to application/fhir+xml. This happens even if I set it in the InvalidRequestException

  InvalidRequestException invalidRequestException = new InvalidRequestException(message);

  List<String> headers = new ArrayList<>();

  headers.add("application/json");

  invalidRequestException.getResponseHeaders().put("Content-Type", headers);

  throw invalidRequestException;

Is this a bug, or intended behavior? Is there anyway I can change it?


Last updated: Apr 12 2022 at 19:14 UTC