Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.61k stars 594 forks source link

[Feature request] Allow reusing the original request even if asObject has failed #113

Closed mlippens closed 5 years ago

mlippens commented 9 years ago

Suppose I do a request, and use asObject(MyObject.class), and this fails. I can't do anything anymore with the response if parsing has failed which makes this method useless to me. I have to resort to parsing it myself using jackson or gson in order to avoid doing a second request just to reparse it.

It should somehow be possible to provide an alternative strategy to apply if the first one fails.

steve-taylor commented 8 years ago

This is definitely a shortcoming of Unirest. It's like no one ever anticipated the response body would contain anything other than the expected result, even when the server returns an error.

ryber commented 5 years ago

Hello, this should be resolved or addressed in Unirest 2. Please see the upgrade guide for important changes.