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

HTTP::Config->match generates "uninitialized value" in matching method [rt.cpan.org #115670] #62

Open
oalders opened this issue Mar 31, 2017 · 1 comment

Comments

@oalders
Copy link
Member

oalders commented Mar 31, 2017

Migrated from rt.cpan.org#115670 (status was 'new')

Requestors:

From [email protected] on 2016-06-28 13:24:50:

Use case: LWP::UserAgent response redirect handler with matching
specific response header, eg "Client-Warning"

Current code:
    m_header__ => sub {
        my($v, $k, $uri, $request, $response) = @_;
        return unless $request;
        return 1 if $request->header($k) eq $v;
        return 1 if $response && $response->header($k) eq $v;
        return 0;
    },

Quick fix:

    m_header__ => sub {
        my($v, $k, $uri, $request, $response) = @_;
        return unless $request;
        return 1 if $request->header($k) && $request->header($k) eq $v;
        return 1 if $response && $response->header($k) &&
$response->header($k) eq $v;
        return 0;
    },

or just disable warnings in those lamdas.
@openstrike
Copy link
Contributor

I have tried to formulate a test for this prior to fixing it but have been unable to reproduce the reported problem. There are 2 additional tests in t/http-config.t in https://github.com/openstrike/HTTP-Message/tree/issue-62 both of which pass.

Have I missed an important detail? Given that there is no "match" method I've used matching_items() as in the other tests in that file.

vitstradal added a commit to vitstradal/HTTP-Message that referenced this issue Feb 17, 2021
vitstradal added a commit to vitstradal/HTTP-Message that referenced this issue Feb 17, 2021
vitstradal added a commit to vitstradal/HTTP-Message that referenced this issue Feb 17, 2021
vitstradal added a commit to vitstradal/HTTP-Message that referenced this issue Feb 17, 2021
vitstradal added a commit to vitstradal/HTTP-Message that referenced this issue Feb 19, 2021
vitstradal added a commit to vitstradal/HTTP-Message that referenced this issue Feb 19, 2021
vitstradal added a commit to vitstradal/HTTP-Message that referenced this issue Feb 19, 2021
oalders added a commit that referenced this issue Feb 19, 2021
    - fix warnings during HTTP::Config->match #62 (GH#152) (Viťas Strádal)
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