Use of uninitialized value $vals in index at /usr/local/share/perl5/HTTP/Headers.pm line 277.
Use of uninitialized value $vals in concatenation (.) or string at /usr/local/share/perl5/HTTP/Headers.pm line 280.
I don't know when or why it started, but I've tried all of:
cpan
upgrade HTTP::Headers
upgrade LWP
upgrade HTML::HeadParser
upgrade LWP::UserAgent
upgrade HTTP
upgrade HTTP::Request
/usr/local/share/perl5/HTTP/Headers.pm:our $VERSION = "6.10";
This is on a CentOS machine, not a Mac, in case that matters.
I don't know why, and I cannot repro it nor had the same bitrot, but I can explain when:
This HTTP/Headers.pm:277 warning with 6.10 will appear with an empty header value.
Headers are processed here: $self->_sorted_field_names, the empty value you get is read at my $vals = $self->{$key};
I debugged it like:
perl -S -d lwp-request -E -m HEAD https://www.jwz.org/blog/2015/09/more-lwp-bit-rot/
> b postpone HTTP::Headers::as_string
> c
and then when you hit it get a better breakpoint
> b 264 !$vals
> c
and then you see which header is empty, with
> x $key
And you can probably bodge around the warnings in the meantime by changing line 263 of Headers.pm from
my $vals = $self->{$key};
to
my $vals = $self->{$key} // '';
to force a defined-but-empty value to exist. (Assuming you're using perl 5.10 or higher.)
I suspect this started with 6.08, or more specifically this commit.
By not using LWP in the first place?
Its 2015, there are more options now, like Furl::HTTP and Mojo::UserAgent.
Yes, let us discard old and predictable brokenness for functionally identical, yet new and exciting, brokenness! Thank God you're here.
Yeah. Why even Perl? New stuff has been around ... PHP... uh,.. running