in reply to Re^5: How to override HTTP::UserAgent::request to return a subclassed HTTP::Response
in thread How to override HTTP::UserAgent::request to return a subclassed HTTP::Response

Initially I wanted to trap someone calling the HTTP::Response content method by accident when it mostly should be the decoded_content method.

  • Comment on Re^6: How to override HTTP::UserAgent::request to return a subclassed HTTP::Response

Replies are listed 'Best First'.
Re^7: How to override HTTP::UserAgent::request to return a subclassed HTTP::Response
by Corion (Patriarch) on Jun 01, 2009 at 16:22 UTC

    How about just overriding the HTTP::Response::content method then?

    require HTTP::Response; use Carp 'cluck'; my $old_content = \&HTTP::Response::content; *HTTP::Response::content = sub { cluck "HTTP::Response::content called - do you want HTTP::Response +::decoded_content instead?"; goto &$old_content; };

    You could get fancy and check whether it's HTTP::Response::decoded_content that is calling you and then suppress your warning, by using caller.