Clear DefaultRequestHeaders when adding a new header dictionary (#302)

This commit is contained in:
Florian Jäckel 2018-10-27 13:56:30 +02:00 committed by Jonas Dellinger
parent 9859e9d4ae
commit 467984c6f8

View File

@ -166,12 +166,9 @@ namespace SpotifyAPI.Web
private void AddHeaders(Dictionary<string,string> headers) private void AddHeaders(Dictionary<string,string> headers)
{ {
_client.DefaultRequestHeaders.Clear();
foreach (KeyValuePair<string, string> headerPair in headers) foreach (KeyValuePair<string, string> headerPair in headers)
{ {
if (_client.DefaultRequestHeaders.Contains(headerPair.Key))
{
_client.DefaultRequestHeaders.Remove(headerPair.Key);
}
_client.DefaultRequestHeaders.TryAddWithoutValidation(headerPair.Key, headerPair.Value); _client.DefaultRequestHeaders.TryAddWithoutValidation(headerPair.Key, headerPair.Value);
} }
} }