Skip to content

(non default) Request Headers #3298

Description

@JTeeuwissen

Is your feature request related to a problem? Please describe.
Currently, whenever we want to modify the headers for a http request, we have to reset and then set the FhirClient.RequestHeaders. But these headers (HttpClient.DefaultRequestHeaders) are not mend for frequent manipulation and they are not thread-safe.

Describe the solution you'd like
I'd like each BaseFhirClient method to have an overload (or optional parameter, but this would be a breaking change) with a HttpRequestHeaders parameter. Which can be passed to
ToHttpRequestMessage where it can be used to add headers to the HttpRequestMessage

var message = new HttpRequestMessage(method, uri);
if (headers is not null)
{
    foreach (var httpRequestHeader in headers)
    {
        message.Headers.Add(httpRequestHeader.Key, httpRequestHeader.Value);
    }
}

Describe alternatives you've considered
Another option would be using http client middleware. But this doesn't play nice with scoping and doesn't allow for local values to be passed in the headers.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions