Forum Moderators: coopster & phranque

Message Too Old, No Replies

making sure content type isn't set twice

cgi output include to HTML page

         

Slud

8:26 pm on Jul 29, 2002 (gmt 0)

10+ Year Member



I include the output of a cgi script into a "static" HTML page.

The script prints the standard "Content-type: text/html\n\n" before its output. The page looks fine in IE6, NN4, Lynx and Moz1.1.

Is there any danger of this content-type being set twice on the same page and screwing up crawler bots?

Knowles

10:57 pm on Jul 30, 2002 (gmt 0)

10+ Year Member



Slud here is a bump, I dont think it would hurt bots really just keep you from validating but I am probably not the person to ask.

Brett_Tabke

2:58 am on Aug 9, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Yes there is a danger. You need to check what the source of the call is. There are different ways you can do that.

If called from ssi, compare your headers to a none ssi call of the script.

If called one script from another, you can usually set a variable to flag such as "$pcontent++" after you print content so that it doesn't get executed twice:

if (!$pcontent) { print "content type...."; $pcontent++};

You can also look at your server environ variables. There will be different fields set depending on the source of the call. You'll have to parse and compare between a browser call, and a call as an include from another script.

Slud

2:48 pm on Aug 9, 2002 (gmt 0)

10+ Year Member



Thanks for the reply Brett.

What tool/utility can I use to view the http headers as they are sent to a browser?

How should I view server environ variables, <!--#printenv -->?

Calling the script directly displays in all browsers OK: [site.com...]

Including the script into a static page displays in all browsers OK:
<!--#include virtual="/cgi-bin/readcsv.pl?ModelKey==675" -->

Executing the script at the command line prints the content-type headers:
perl readcsv.pl