Skip to content

Commit

Permalink
fix(headers): changed case insensitive for getting value (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlautier committed Jul 7, 2023
1 parent 4593ea7 commit 33c2829
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,12 @@

[_vNext_](https://github.com/sketch7/FluentlyHttpClient/compare/3.8.1...3.9.0) (2020-X-X)

## [3.9.4](https://github.com/sketch7/FluentlyHttpClient/compare/3.9.3...3.9.4) (2023-07-07)

### Bug Fixes

- **headers:** changed case insensitive for getting value

## [3.9.3](https://github.com/sketch7/FluentlyHttpClient/compare/3.9.2...3.9.3) (2023-06-09)

### Chore
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@sketch7/fluently-http-client",
"version": "3.9.3",
"version": "3.9.4",
"versionSuffix": "",
"scripts": {
"pack": "bash ./tools/pack.sh",
Expand Down
4 changes: 2 additions & 2 deletions src/FluentlyHttpClient/FluentHttpHeaders.cs
@@ -1,4 +1,4 @@
using Microsoft.Extensions.Primitives;
using Microsoft.Extensions.Primitives;
using System.Collections;

namespace FluentlyHttpClient;
Expand Down Expand Up @@ -43,7 +43,7 @@ public partial class FluentHttpHeaders : IFluentHttpHeaderBuilder<FluentHttpHead
{
private static readonly FluentHttpHeadersOptions DefaultOptions = new();
private FluentHttpHeadersOptions _options = DefaultOptions;
private readonly Dictionary<string, string[]> _data = new();
private readonly Dictionary<string, string[]> _data = new(StringComparer.OrdinalIgnoreCase);

public string[] this[string key]
{
Expand Down
18 changes: 17 additions & 1 deletion test/FluentHttpHeadersTest.cs
@@ -1,4 +1,4 @@
using Microsoft.Extensions.Primitives;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;

// ReSharper disable InconsistentNaming
Expand Down Expand Up @@ -141,6 +141,22 @@ public void ShouldNotThrowWhenRemovingNonExisting()
}
}

public class FluentHttpHeaders_GetValue
{
[Fact]
public void ShouldBeCaseInsensitive()
{
var headers = new FluentHttpHeaders
{
{ "X-Custom", "the-xx" }
};
var value = headers.GetValue("X-Custom");
var value2 = headers.GetValue("x-custom");
Assert.Equal("the-xx", value);
Assert.Equal("the-xx", value2);
}
}

public class FluentHttpHeaders_Accessors
{
[Fact]
Expand Down

0 comments on commit 33c2829

Please sign in to comment.