Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: upstream prematurely closed connection while reading response header from upstream

by Digioso (Sexton)
on Feb 24, 2023 at 14:22 UTC ( [id://11150579]=note: print w/replies, xml ) Need Help??


in reply to Re: upstream prematurely closed connection while reading response header from upstream
in thread upstream prematurely closed connection while reading response header from upstream

Thanks a lot for this. And it seems that is indeed the solution. The scripts have been running for years without any issues, though. So I find it quite astonishing that this really is the case. oO I uploaded a test3.pl where I tried your suggestion and this one works without any issues. But urgh... That would mean I have to adjust that in dozens of scripts... My whole site is running on Perl... :(


Link: https://digioso.tk/test3.pl

Source code test3.pl
#!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); use lib "/home/digioso/web/digioso.tk/stuff"; use Navi2; my $cgi = Navi2::create_cgi(); Navi2::print_navi($cgi); print "test"; Navi2::end_navi($cgi);

Source code Navi2.pm:
#!/usr/bin/perl -w use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); package Navi2; binmode STDOUT, ":utf8"; sub create_cgi { return new CGI; } sub print_navi($) { my $cgi = shift; print $cgi->header (-type => 'text/html', -charset => 'UTF-8'); } sub end_navi($) { my $cgi = shift; print $cgi->end_html; }

Replies are listed 'Best First'.
Re^3: upstream prematurely closed connection while reading response header from upstream
by Corion (Patriarch) on Feb 24, 2023 at 14:48 UTC
    Now I started migrating stuff from my old webhoster to the new server

    This is why things changed, and why you have to edit your scripts.

    If you are interested, you could use this to migrate to (say) Mojolicious, which allows you to locally test your scripts and move some of your HTML generation into templates etc., but as a first step, instead of passing $cgi into print_navi(), you could create it within print_navi() if you don't need it elsewhere, especially if you're only using it for HTML generation.

    You also want to move the binmode STDOUT, ":utf8"; into your first call, likely create_cgi() so it gets called every time.

      Ah, understood. OK, that reduces the number of required changes a lot. :) Regarding Mojolicious (or other CGI.pm alternatives). Yes, I know it's bad to CGI.pm. But basically I really haven't found any alternative. I don't need frameworks to write applications and I don't need templates because I (as you've seen) I use Perl to write HTML. I only use CGI.pm to print out websites, so all the other neat features are totally wasted on me. And my main problem would be that I'd have to spend months to migrate everything I wrote over the past decades to the new system. At least CGI.pm isn't completely abandoned. The last update was beginning of January.

      Adjusted to this now: test3.pl:
      #!/usr/bin/perl -w use strict; use lib "/home/digioso/web/digioso.tk/stuff"; use Navi2; binmode STDOUT, ":utf8"; Navi2::print_navi(); print "test"; Navi2::end_navi();
      Navi2.pm:
      #!/usr/bin/perl -w use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser warningsToBrowser); package Navi2; 1; sub create_cgi { binmode STDOUT, ":utf8"; return new CGI; } sub print_navi() { my $cgi = create_cgi(); print $cgi->header (-type => 'text/html', -charset => 'UTF-8'); } sub end_navi() { my $cgi = create_cgi(); print $cgi->end_html; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11150579]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-03-28 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found