jam3s has asked for the wisdom of the Perl Monks concerning the following question:

Hello All I am having problems with the wrong content-type being sent in the HTTP Header as "Content-Type: text/plain". I have tried various different sample scripts such the hellworld one listed below:

#!/usr/local/bin/perl # hello.pl -- my first perl script! print "Content-type: text/html\n\n"; print "Hello, world!\n";
When i preview the script in a browser I can see that the content-type is being added to the body of the page. I have pasted the packet capatured
HTTP/1.1 200 OK Date: Thu, 15 Dec 2011 14:42:52 GMT Server: Apache/2.2.3 (CentOS) Connection: close Transfer-Encoding: chunked Content-Type: text/plain --------- HTTP Content Content-type: text/html Hello, world! ---------- HTTP Content
I think this is probabily a configuration settings gone wrong, I am using perl v5.8.8 on Centos 5 with mod_perl. I am also trying to use the rss2cicsco script (found here http://dontpokebadgers.com/RSS2Cisco/) and getting the same results with each page having the content-type being added to the body of the http packet. THanks for any help James

Replies are listed 'Best First'.
Re: Perl keeps sending wrong content-type
by Anonymous Monk on Dec 15, 2011 at 15:07 UTC

    Perl keeps sending wrong content-type

    I doubt it :) Your program or webserver might send wrong content types but not Perl :)

    I think this is probabily a configuration settings gone wrong,

    It is good you hide those settings you suspect at being important, this will certainly lead to a solution :D

    CGI Help Guide and Troubleshooting Perl CGI scripts

    http://perl.apache.org/docs/1.0/guide/porting.html

    http://search.cpan.org/dist/mod_perl/docs/os/win32/config.pod

    http://httpd.apache.org/docs/2.2/howto/cgi.html

    http://perl.apache.org/docs/1.0/guide/config.html

      Reconfigured Apache and all works now,
      <Directory /var/www/html/scripts> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI Order allow,deny Allow from all </Directory>