Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

ArgumentNullException("chars") is thrown when iterating HeaderDictionary #381

Closed
kadukf opened this issue Jul 24, 2017 · 3 comments
Closed
Assignees

Comments

@kadukf
Copy link

kadukf commented Jul 24, 2017

Iterating over Request.Headers throws ArgumentNullException in case the web hosting uses WebListener/HttpSysListener and the request contains a header with empty value, e.g.

GET /api/values HTTP/1.1
If-None-Match:

It fails when calling UTF8Encoding.GetChars(byte* bytes, int byteCount, char* chars, int charCount) because chars point to IntPtr.Zero.

In case of Kestrel, all is fine.

@Tratcher
Copy link
Member

Can you share the full stack trace? I assume the issue is here:

What client are you using? Most won't send empty headers.

@Tratcher Tratcher added the bug label Jul 25, 2017
@kadukf
Copy link
Author

kadukf commented Jul 25, 2017

Stack trace:

at System.Text.UTF8Encoding.GetChars(Byte* bytes, Int32 byteCount, Char* chars, Int32 charCount)
at Microsoft.Net.Http.Server.HeaderEncoding.GetString(SByte* pBytes, Int32 byteCount)
at Microsoft.Net.Http.Server.NativeRequestContext.GetKnownHeader(HttpSysRequestHeader header)
at Microsoft.Net.Http.Server.RequestHeaders.get_IfNoneMatch()
at Microsoft.Net.Http.Server.RequestHeaders.d__201.MoveNext()
at System.Linq.Enumerable.d__58`1.MoveNext()

@kadukf
Copy link
Author

kadukf commented Jul 25, 2017

We have a clients which send us such payload. We migrated from OWIN to ASPNETCORE and we have this regression. We have a nasty hack implemented using reflection (class Microsoft.Net.Http.Server.HeaderEncoding, field Encoding) but we want to get rid of this hack.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants