Remove outdated lock from ParseRawHeaderValues (#54130)
authorStephen Toub <stoub@microsoft.com>
Tue, 15 Jun 2021 00:15:32 +0000 (20:15 -0400)
committerGitHub <noreply@github.com>
Tue, 15 Jun 2021 00:15:32 +0000 (20:15 -0400)
commitbfb8d6bfd3c708e148755caa3e3ae916cdef7ed9
treee5f4a1e26dff1f69cde7fecf5de0c4d9139552fc
parent90c1750027a0935a40f1db85d084261ea11b0d08
Remove outdated lock from ParseRawHeaderValues (#54130)

This lock existed to protect HttpClient.DefaultRequestHeaders.  While headers collections aren't meant to be thread-safe, out of necessity the design of DefaultRequestHeaders required this lock be in place, with multiple concurrent requests all potentially enumerating DefaultRequestHeaders in order to copy its contents into the outgoing request.  Such enumeration could trigger parsing, which could trigger the same object to be mutated from multiple threads to store the parsed result.  But as of https://github.com/dotnet/runtime/pull/49673, we no longer force parsing of the DefaultRequestHeaders, instead preferring to just transfer everything over as-is.  With that, there shouldn't be any concurrent mutation of these objects (and if there is, it's user error doing their own concurrent enumeration of a header collection).
src/libraries/System.Net.Http/src/System/Net/Http/Headers/HttpHeaders.cs
src/libraries/System.Net.Http/src/System/Net/Http/Headers/HttpRequestHeaders.cs
src/libraries/System.Net.Http/src/System/Net/Http/HttpClient.cs