in reply to Re^4: 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

Yes, this is what I mean. As I don't know how you want to turn a HTTP::Response into your XXX::HTTP::Response, as you've kept the differences between the two well to yourself, I can't tell you any better way than to write some code that creates an XXX::HTTP::Response object from a HTTP::Response object.

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

Replies are listed 'Best First'.
Re^6: How to override HTTP::UserAgent::request to return a subclassed HTTP::Response
by mje (Curate) on Jun 01, 2009 at 16:12 UTC

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

      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.