restsharp/RestSharp — pull request #437 by devinrader (2013-10-09 20:18:38+00:00)
Title: All all HTTP responses to be deserialized

Modifies the behavior of

restsharp/RestSharp@fde15e229882bb99618de673ead017c8bc5ae9f4
restsharp/RestSharp@0fe0fa13ad942886199390f1cfd3afec5ec6f2dd
restsharp/RestSharp@9b423a8830983de9b88490cabf7b647717a58a77

which have caused a regression in RestSharp behavior.

These commits limit RestSharp to attempt to deserialize responses only when the 200, 201 and 203 status codes are returned. This is incorrect as virtually every status code allows you to return a message-body. As far as I can tell there are only two that explicitly prohibit it: 204 and 304.

I believe the original intent of these commits was to try to stop RestSharp from attempting deserialization for non-protocol errors (ex: connection timeouts). In most cases, when RestSharp encounters a non-protocol error, it will handle the error and set the ErrorException and ErrorMessage properties allowing you to detect the occurrence of the exception.

This pull request modifies the prior commits to check the ErrorException property in order to determine of deserialization should be attempted, instead of relying on Status Codes.

Tests are included to simulate RestSharp handling a connection timeout and deserialization of an 400 error message-body. If there are other non-protocol error scenarios that should be tested let me know. I also changed one test back to its original code which would have caught this regression.