seraphx2 / ESI.NET

A C# wrapper for the Eve Online ESI API.
https://www.nuget.org/packages/ESI.NET/
MIT License
40 stars 23 forks source link

Http Authorization Header Duplicate Key #28

Closed SebFerraro closed 4 years ago

SebFerraro commented 4 years ago

An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at System.Net.Http.Headers.HttpHeaders.AddHeaderToStore(String name, HeaderStoreItemInfo info) at System.Net.Http.Headers.HttpHeaders.CreateAndAddHeaderToStore(String name) at System.Net.Http.Headers.HttpHeaders.GetOrCreateHeaderInfo(String name, Boolean parseRawValues) at System.Net.Http.Headers.HttpHeaders.SetParsedValue(String name, Object value) at System.Net.Http.Headers.HttpRequestHeaders.set_Authorization(AuthenticationHeaderValue value) at ESI.NET.EsiRequest.<Execute>d__11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at ESI.NET.Logic.UniverseLogic.d__23.MoveNext()

Error potentially occurring on line 35 of EsiRequest.cs

Suggestion for fix:

if (client.DefaultRequestHeaders.Contains("Authorization")) { client.DefaultRequestHeaders.Remove("Authorization"); } client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

seraphx2 commented 4 years ago

hmmm, so looking at my code, I feel like the existence of client.DefaultRequestHeaders.Clear(); at the beginning of each Execute call indicates I ran into this already.

Do you know if you are totally up to date on ESI.NET version?