toland / patron

Ruby HTTP client based on libcurl
http://toland.github.com/patron/
MIT License
541 stars 73 forks source link

RFC: Add the ability to override the Response class by subclassing Session #99

Closed julik closed 8 years ago

julik commented 8 years ago

When running repetitive requests (tremendous amounts of repetitive requests in fact), you might want to skip charset detection and header parsing for performance. That is very difficult to do if the class lookup for Response happens at the C level. Therefore, it might be a good idea to use dynamic lookup to figure out the response class. If you subclass Session and override the response_class you can then use an optimised version of a Response that, for instance, quickly grabs the status code that you got and moves on.

Adds one method call per request-response cycle and one stack cruby ref, so should be gentle performance-wise.

toland commented 8 years ago

This looks reasonable to me. Thanks for the contribution.