Fix HeaderSegmentCollection failing when header value has a trailing space (#23159)
Co-authored-by: Filip Staffa <git@filipstaffa.net>
This commit is contained in:
parent
71e388eab7
commit
e1d4728d90
|
|
@ -254,6 +254,11 @@ namespace Microsoft.AspNetCore.Http
|
|||
switch (attr)
|
||||
{
|
||||
case Attr.Delimiter:
|
||||
if (ch == (char)0)
|
||||
{
|
||||
_valueEnd = _offset;
|
||||
_trailingStart = _offset;
|
||||
}
|
||||
_mode = Mode.Produce;
|
||||
break;
|
||||
case Attr.Quote:
|
||||
|
|
|
|||
|
|
@ -103,5 +103,18 @@ namespace Microsoft.AspNetCore.Http
|
|||
Assert.Throws<InvalidOperationException>(() => headers.Remove(new KeyValuePair<string, StringValues>("header1", "value1")));
|
||||
Assert.Throws<InvalidOperationException>(() => headers.Remove("header1"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetCommaSeparatedValues_WorksForUnquotedHeaderValuesEndingWithSpace()
|
||||
{
|
||||
var headers = new HeaderDictionary
|
||||
{
|
||||
{ "Via", "value " },
|
||||
};
|
||||
|
||||
var result = headers.GetCommaSeparatedValues("Via");
|
||||
|
||||
Assert.Equal(new[]{"value "}, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue