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

This question has more to do with the html protocol, I guess, then with perl. But can anyone here help me understand why a 644 file with an .html extension and headers that look like this:

<!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" xml:lang="en" lang="en"> <head> <title>
would not be recognized by either the apache server or my local mozilla browser as being eligible to be served in the usual way? Instead I'm asked by my browser which application it should open it with. When I choose mozilla it does so from a local file in /tmp and except for a few broken image links I am getting the content I expect. But I'll lose users if folks have to figure out what application to use.

-- Hugh

P.S. The html file is generated by a perl script, if that makes it any more relevant to this forum.

Replies are listed 'Best First'.
Re: getting the html to the browser
by jZed (Prior) on Jan 22, 2006 at 01:57 UTC
    You wrote:
    The html file is generated by a perl script, if that makes it any more relevant to this forum.

    Do you mean that a script creates a file, e.g. foo.html located in your webserver document tree and when a user gives the URL to the file it isn't served? Are you sure the file is named .htm or .html?

    Or more likely, you probably don't mean that the script creates a file, but rather that a CGI script sends a CGI header and content to a browser (e.g. user clicks on foo.cgi or foo.pl). In that case are you sure that apache is set up to serve files with those extensions, and that CGI-scripts are executable in that location?

    Either way, it sounds like you should look in your apache config for the answer.
      No, I mean that a perl script uses wget to grab and massage a file served dynamically by a CMS to make it available for static service by another apache box. We're working to mitigate sometimes heavy loads on the script and database driven cms server.

      It is under the document root, or my browser would not find it to download it. What else would I need to tell apache so that it serves this as .html instead of a foreign file type it has to ask a human about?

      -- Hugh

        Do other files of the same file extension download correctly from that particular apache? If you look at the headers of the response, is it sending the correct Content-type header?

        Just wondering - are you sure that file is actually created on the server? I'm wondering whether it's not being created, or possible being given incorrect permissions. Also, have you checked who's the owner of the file after it's created (assuming it is created)?

Re: getting the html to the browser
by pajout (Curate) on Jan 22, 2006 at 12:23 UTC
    Perhaps you did not send content type header (eq 'text/html') to browser, and your mozilla strictly does not know and does not try any guess, how to serve content of unknown content type.