Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You shouldn't use ref($thing) eq 'HTTP::Response' #16

Closed
tobyink opened this issue Feb 23, 2023 · 1 comment
Closed

You shouldn't use ref($thing) eq 'HTTP::Response' #16

tobyink opened this issue Feb 23, 2023 · 1 comment

Comments

@tobyink
Copy link

tobyink commented Feb 23, 2023

my $content = (ref($response) eq 'HTTP::Response')

You're checking that $response is exactly a member of the HTTP::Response class, which prevents people from using user-agents that return a subclass of HTTP::Response.

Better would be:

    my $content = ( blessed $response and $response->isa('HTTP::Response') )
                    ? $response->decoded_content()
                    : $response->{content};

You'd need to import use Scalar::Util 'blessed'; at the top to get the blessed keyword though.

@freyfogle
Copy link
Member

implemented in v 0.35 which was just uploaded to CPAN
https://metacpan.org/release/EDF/Geo-Coder-OpenCage-0.35

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants