evemon
evemon copied to clipboard
Improvement for HttpClientServiceRequest.EnsureSuccessStatusCode to simplyfy debugging ESI
In 'src\EVEMon.Common\Net\HttpClientServiceRequest.cs', I replaced the EnsureSuccessStatusCode method by the version below that outputs traces (seen in the VS output window) when ESI requests fail.
As the new code shows the request uri and response content it greatly simplyfies finding ESI endpoints that fail.
private static void EnsureSuccessStatusCode(HttpResponseMessage response)
{
var code = response.StatusCode;
if ((int)code < 100)
{
response.StatusCode = HttpStatusCode.OK;
response.ReasonPhrase = "OK";
}
else if (code != HttpStatusCode.NotModified)
{
if (response.RequestMessage.RequestUri.ToString().StartsWith(NetworkConstants.ESIBase) && !response.IsSuccessStatusCode)
{
String body = response.Content.ReadAsStringAsync().Result;
EveMonClient.Trace($"Request: {response.RequestMessage.RequestUri} returned: {(Int32)response.StatusCode} ({response.ReasonPhrase}) with content: '{body}'.", printMethod: false);
}
// Allow "not modified" so that it will be detected by the front end
response.EnsureSuccessStatusCode();
}
}
can you add all last changes to your fork?