Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Howto: Tell if the CGI modules sent Content-type headers

Status
Not open for further replies.

thenewa2x

Programmer
Joined
Dec 10, 2002
Messages
349
Location
US
Does anyone know how to find out if this, Content-type: text/html, header was sent out by the CGI module? When I write a cookie it sends out the header but then when I spit out the html for viewing you also see the Content-type: text/html header "code" when you don't send a cookie.

---------------------------------------
If you helped... thx.
 
Use telnet and the HTTP to view the raw text transfered from your server. If you google on "http command telnet" you can get some tips there.

> telnet xxx.xxx.xxx.xxx 80
> GET /path/to/cgi/script
>


And this should output your results, you can look at the header that way.

--jim
 
What do you mean "spit out the html for viewing"? The CGI module will send out the content-type when you call the "header" function. Here's the docs on it:

To test what is actually output by your script you can either use Codiferous's method or run the script from the command line. See the debugging section of the docs for more info on running cgi scripts from the command line:
 
I cannot use telnet for what i am doing.

what i meant was this:

I load CGI.pm and my [tt]$CGI = new CGI;[/tt] it.

I want to print out a variable ($html) that has precompiled HTML code without the Content-type: header.

Now what I would like to find out is if the Content-type header was already sent so I don't resend it and the client will be able to see it on their web-page.

---------------------------------------
If you helped... thx.
 
The cgi.pm module will not print out the header unless you do something like this:
Code:
print $CGI->header();
As far as I know CGI.pm doesn't have a way to tell whether the header has been printed or not. What results are you getting, do you see the precompiled html code correctly in the browser? Or is it all text?

 
it's correct but you see this with the page:

[tt]Content-type: text/html[/tt]

becauase the header was already sent. thx anyway.

I have another question, what does this mean?

Code:
sub some_function ($$)
{
}

What does the $$ mean after the function name? I don't remember if what combination of $ and : is used in the function that I saw.

---------------------------------------
If you helped... thx.
 
it's correct but you see this with the page:

Content-type: text/html

Then your script is calling for the header twice.

There's always a better way. The fun is trying to find it!
 
Show part of your script (probably the first couple dozen lines) and we might be able to help you better.

I believe the '$$' says that the function expects two scalars. And if the arguments are not scalars they will be forced into scalar context.

 
nvm, taken care of. instead of manually printing the headers, i just use $CGI->header().

---------------------------------------
If you helped... thx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top