Reverted old code and added simple IgnoreCase to header dictionary

This commit is contained in:
ObsidianMinor
2016-11-10 21:21:21 -06:00
parent bb9c43b21a
commit 29c9ac9ef3
2 changed files with 2 additions and 4 deletions

View File

@@ -49,9 +49,7 @@ namespace Discord.Net.Queue
Debug.WriteLine($"[{id}] Sending...");
var response = await request.SendAsync().ConfigureAwait(false);
string headerDate;
bool headerHasDate = response.Headers.TryGetValue("Date", out headerDate);
TimeSpan lag = DateTimeOffset.UtcNow - (headerHasDate ? DateTimeOffset.Parse(headerDate) : DateTimeOffset.UtcNow);
TimeSpan lag = DateTimeOffset.UtcNow - DateTimeOffset.Parse(response.Headers["Date"]);
var info = new RateLimitInfo(response.Headers);
if (response.StatusCode < (HttpStatusCode)200 || response.StatusCode >= (HttpStatusCode)300)

View File

@@ -120,7 +120,7 @@ namespace Discord.Net.Rest
cancelToken = CancellationTokenSource.CreateLinkedTokenSource(_cancelToken, cancelToken).Token;
HttpResponseMessage response = await _client.SendAsync(request, cancelToken).ConfigureAwait(false);
var headers = response.Headers.ToDictionary(x => x.Key, x => x.Value.FirstOrDefault());
var headers = response.Headers.ToDictionary(x => x.Key, x => x.Value.FirstOrDefault(), StringComparer.OrdinalIgnoreCase);
var stream = !headerOnly ? await response.Content.ReadAsStreamAsync().ConfigureAwait(false) : null;
return new RestResponse(response.StatusCode, headers, stream);