From 33c282929e2d1a43fac7c2149ca568e4f0427b95 Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Fri, 7 Jul 2023 17:36:15 +0200 Subject: [PATCH] fix(headers): changed case insensitive for getting value (#77) --- CHANGELOG.md | 6 ++++++ package.json | 2 +- src/FluentlyHttpClient/FluentHttpHeaders.cs | 4 ++-- test/FluentHttpHeadersTest.cs | 18 +++++++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a236e0d..e911f53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/package.json b/package.json index 218048f..2b01343 100644 --- a/package.json +++ b/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", diff --git a/src/FluentlyHttpClient/FluentHttpHeaders.cs b/src/FluentlyHttpClient/FluentHttpHeaders.cs index cce9bdb..a637c30 100644 --- a/src/FluentlyHttpClient/FluentHttpHeaders.cs +++ b/src/FluentlyHttpClient/FluentHttpHeaders.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Primitives; +using Microsoft.Extensions.Primitives; using System.Collections; namespace FluentlyHttpClient; @@ -43,7 +43,7 @@ public partial class FluentHttpHeaders : IFluentHttpHeaderBuilder _data = new(); + private readonly Dictionary _data = new(StringComparer.OrdinalIgnoreCase); public string[] this[string key] { diff --git a/test/FluentHttpHeadersTest.cs b/test/FluentHttpHeadersTest.cs index feedae9..59b33ca 100644 --- a/test/FluentHttpHeadersTest.cs +++ b/test/FluentHttpHeadersTest.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Primitives; +using Microsoft.Extensions.Primitives; using Newtonsoft.Json; // ReSharper disable InconsistentNaming @@ -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]