mohan.siripi has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,

We are using OIDCAuth.pm for processing the requests from our application and when we sent a request from browser or postman we see the following exception from our proxy server.

[Thu May 06 10:11:34.064858 2021] [perl:error] [pid 92949] [client 49. +37.171.196:54868] failed to resolve handler `CastIron::OIDCAuth': Bareword "HTTP::Status::RC_PERMANENT_REDIRECT" not allowed while "stri +ct subs" in use at /usr/local/lib/perl5/site_perl/5.28.3/LWP/UserAgen +t.pm line 318. Compilation failed in require at /etc/httpd/CastIron/OIDCAuth.pm line +17. BEGIN failed--compilation aborted at /etc/httpd/CastIron/OIDCAuth.pm l +ine 17. Compilation failed in require at (eval 38) line 1
In our OIDCAuth.pm we are using LWP UserAgent.Please let me know if there is any module missing or any module need to install to resolve this issue.

Any help would be appreciated

Thanks
Mohan

  • Comment on Bareword "HTTP::Status::RC_PERMANENT_REDIRECT" not allowed while "strict subs" for https request
  • Download Code

Replies are listed 'Best First'.
Re: Bareword "HTTP::Status::RC_PERMANENT_REDIRECT" not allowed while "strict subs" for https request
by bliako (Abbot) on May 06, 2021 at 13:55 UTC

    The absence of use HTTP::Status causes this error:

    use strict; use warnings; #use HTTP::Status; my $x = HTTP::Status::RC_PERMANENT_REDIRECT;

    This is because these "constants" are injected dynamically (via eval) into the module as part of initialisation code in HTTP::Status, see:

    # https://metacpan.org/release/HTTP-Message/source/lib/HTTP/Status.pm # v 6.29 my $mnemonicCode = ''; my ($code, $message); while (($code, $message) = each %StatusCode) { # create mnemonic subroutines $message =~ s/I'm/I am/; $message =~ tr/a-z \-/A-Z__/; $mnemonicCode .= "sub HTTP_$message () { $code }\n"; $mnemonicCode .= "*RC_$message = \\&HTTP_$message;\n"; # legacy $mnemonicCode .= "push(\@EXPORT_OK, 'HTTP_$message');\n"; $mnemonicCode .= "push(\@EXPORT, 'RC_$message');\n"; } eval $mnemonicCode; # only one eval for speed die if $@;

    So, a use HTTP::Status is needed. Furthermore, it seems that mnemonics prepended with RC_ are legacy. I assume the proper way to refer to the codes by message/mnemonic is via HTTP_PERMANENT_REDIRECT() (and not by RC_PERMANENT_REDIRECT)

    LWP::UserAgent loads HTTP::Status indirectly via use LWP::Protocol;. Has your perl upgrade also included all installed modules?

    bw, bliako

Re: Bareword "HTTP::Status::RC_PERMANENT_REDIRECT" not allowed while "strict subs" for https request
by hippo (Archbishop) on May 06, 2021 at 10:59 UTC
    We are using OIDCAuth.pm

    I cannot immediately find that on CPAN. Could you link to the source, please?

    It would also help if you could wrap your error message in <code> ... </code> tags. Thanks.


    🦛

Re: Bareword "HTTP::Status::RC_PERMANENT_REDIRECT" not allowed while "strict subs" for https request
by mohan.siripi (Initiate) on May 06, 2021 at 11:27 UTC
    OIDCAuth.pm will not be available in CPAN.This is own perl script to h +andle the http authentication.I will share some of the perl modules l +oading from this script. package CastIron::OIDCAuth; use strict; use warnings; use lib '/usr/share/perl5'; use URI; use SOAP::Lite; use Apache2::Access (); use Apache2::RequestUtil (); use CastIron::DBIWrap; use Digest::SHA1 qw(sha1_base64); use Cache::Memcached (); use Apache2::Const -compile => qw(OK DECLINED HTTP_UNAUTHORIZED); use LWP::UserAgent; - This is the line it is throwing exception for +us We have upgraded to perl 5.28.3 and after ugrading we are seeing the a +bove exception.Our Previous version of Perl is 5.12.3 there the we do +not see any issues and http request works fine. I have list of perlmodules installs but those are very huge and could +not find how to attach.

      If you are running your script in a persistent environment like a mod_perl script, you might want to explicitly load HTTP::Status to make sure all the subroutines are explicitly defined:

      use HTTP::Status;

      In the long run, LWP::UserAgent should explicitly have use HTTP::Status; in its code as bliako commented, because it uses elements from that module.

      Update: The change has found its way into LWP::UserAgent and will be in some release.