зеркало из https://github.com/dotnet/aspnetcore.git
Fix HttpHeaders Keys case sensitivity (#50606)
This commit is contained in:
Родитель
6f668d8666
Коммит
436556163a
|
@ -115,7 +115,7 @@ internal abstract partial class HttpHeaders : IHeaderDictionary
|
|||
|
||||
bool ICollection<KeyValuePair<string, StringValues>>.IsReadOnly => _isReadOnly;
|
||||
|
||||
ICollection<string> IDictionary<string, StringValues>.Keys => ((IDictionary<string, StringValues>)this).Select(pair => pair.Key).ToList();
|
||||
ICollection<string> IDictionary<string, StringValues>.Keys => ((IDictionary<string, StringValues>)this).Select(pair => pair.Key).ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
ICollection<StringValues> IDictionary<string, StringValues>.Values => ((IDictionary<string, StringValues>)this).Select(pair => pair.Value).ToList();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
@ -298,4 +299,12 @@ public class HttpHeadersTests
|
|||
Assert.Null(httpHeaders.ContentLength);
|
||||
Assert.False(httpHeaders.ContentLength.HasValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KeysCompareShouldBeCaseInsensitive()
|
||||
{
|
||||
var httpHeaders = (IHeaderDictionary)new HttpRequestHeaders();
|
||||
httpHeaders["Cache-Control"] = "no-cache";
|
||||
Assert.True(httpHeaders.Keys.Contains("cache-control"));
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче