firely-net-sdk
firely-net-sdk copied to clipboard
Case-sensitivity for custom HTTP headers in response
Discussed in https://github.com/FirelyTeam/firely-net-sdk/discussions/2107
Originally posted by cdaven June 1, 2022
The HTTP specification says that headers are case insensitive (see RFC 2616, section 4.2). .NET parses the basic headers and puts them in the HttpResponseMessage.Headers
object, so we don't have to think about this. However, all custom headers are copied to the EntryResponse
object by HttpToEntryExtensions.SetHeaders()
into a case-sensitive Dictionary
.
You can see what I mean in the unit test TestToTypedEntryResponse()
, and change this line:
Headers = new Dictionary<string, string>() { { "Test-key", "Test-value" } },
Change e.g. "Test-key"
to "test-key"
, and the test will fail. Is this intended or a bug?
I thought we could make this easy by making EntryResponse.Headers
case-insensitive in the constructor:
public EntryResponse()
{
Headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
}
But since Headers
is replaced in e.g. ToTypedEntryResponse()
, that would have to be refactored as well.
What do you think? The Swedish NLL implementation has suddenly announced that they will start using lowercase headers only.