I would like to see this behaviour, too (although in the Net::Http adapter, as I also do not user faraday).
I see multiple ways to implement the behaviour, of wich i will outline some and which are possible to combine.
1. Like Mechanize, throw an Exception if the response is not .kind_of? Net::HTTPSuccess. And (also like Mechanize (
http://rubydoc.info/gems/mechanize/Mechanize/HTTP/Agent#allowed_error_codes-instance_method), allow that certain error codes would be ignored. Code would go into lib/roar/representer/feature/http_verbs.rb#handle_response, I guess.
This, for my understanding changes the API usage, it is an incompatible change.
2. Have a post! (and the usual post) method, and respective other http-verbs-BANG methods, that return the response (instead of the representer) but update the represented object, if possible. Handling errors is then left to the caller. The post-method would return a new representer. Again, incompatible change.
3. Have the behaviour controlled by an additional parameter to #post, #get etc (raise_on_error: true, ignore_error_codes: [407]).
4. Implement new methods like post_response that acts similar to the "post!" outlined above.
I somewhat favor the post! - way. I will create an github issue and link to a repository, where I made minimal changes to the sinatra example_server to have a base for discussion.
Have fun,
felix
- Like e.g. Mechanize, throw an Exception if the response is not
response.kind_of? Net::HTTPSuccess. Like