Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public override void OnActionExecuting(ActionExecutingContext context)

if (!context.HttpContext.Request.Headers.TryGetValue(HeaderNames.Accept, out var acceptHeaderValue) ||
acceptHeaderValue.Count != 1 ||
!string.Equals(acceptHeaderValue[0], KnownContentTypes.JsonContentType, StringComparison.OrdinalIgnoreCase))
!MediaTypeHeaderValue.TryParse(acceptHeaderValue[0], out var parsedMediaType) ||
!string.Equals(parsedMediaType.MediaType.Value, KnownContentTypes.JsonContentType, StringComparison.OrdinalIgnoreCase))
{
throw new RequestNotValidException(string.Format(Api.Resources.UnsupportedHeaderValue, acceptHeaderValue.FirstOrDefault(), HeaderNames.Accept));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,21 @@ public void GivenARequestWithCorrectHeaderAndNoQueryParams_WhenGettingAnExportOp
_filter.OnActionExecuting(context);
}

[Theory]
[InlineData("application/fhir+json; charset=utf-8")]
[InlineData("application/fhir+json;charset=utf-8")]
[InlineData("application/fhir+json; charset=UTF-8")]
public void GivenARequestWithAcceptHeaderContainingMediaTypeParams_WhenGettingAnExportOperationRequest_ThenTheResultIsSuccessful(string acceptHeader)
{
// .NET HttpClient automatically appends "; charset=utf-8" to the Accept header.
// Validate that media type parameters do not cause the request to be rejected.
var context = CreateContext();
context.HttpContext.Request.Headers[HeaderNames.Accept] = acceptHeader;
context.HttpContext.Request.Headers[PreferHeaderName] = CorrectPreferHeaderValue;

_filter.OnActionExecuting(context);
}

[Theory]
[InlineData("respond-async", true)]
[InlineData("respond-async,handling=strict", true)]
Expand Down
Loading