jinanwow jinanwow - 2 months ago 16
Apache Configuration Question

Firefox / Chrome shows plain text from cgi script

I currently have an internal website that is running Apache. It is serving some cgi script webpages (perl code). Recently in Firefox and Chrome it is starting to show plain text version of the HTML code. In Internet Explorer it renders the cgi files as HTML, but in Chrome and Firefox it is rendered as plain text.

In the perl code I have the following:

#!/usr/bin/perl --
#
#Prints the HTML MIME TYPE FOR WEB BROWSERS.
print "content-type: text/html\n\n";
print <<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Statistics</title>

--- OUTPUT SNIPPED ---

HTML


Using an application for firefox, I am seeing the response header as being text/plain instead of text/html.

I am not sure if it could have possibly be an Apache config or if its something that is missing for the content type.

Answer

This was a workaround but it appears to have fixed the issue:

In the apache host configuration file I added the line for the cgi-bin directory:

DefaultType text/html