Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tlug: HTTP headers q



I am having trouble with HTTP headers again.  What I should do (as I think
I said in my last mail on this topic) is to go back to school.  Can anyone
point me at the standard reference on practical management of Apache with
CGI scripts?

The trouble I'm having arises from not knowing which agent is responsible
for what.  I have a CGI script that initially just spewed from <HTML>.  It
now outputs a Content-type:  header a Pragma: (for no-cache) and
(conditionally) a Set-Cookie:.  This seemed to solve Lynx's complaints
about the script. 

Now I've decided to try to speed things up by running the script as a
FastCGI server.  The server works load OK to the interpreter (Tcl), and
Apache brings up a process manager that launches the resident copy of the
script into memory. 

So far so good.  The script will even run in response to a call from a
browser, from the top-level, okay. But every button (each of which should
trigger another instance of the script, tweaked by options fed through in
QUERY_STRING) causes the script to crash.  The server log says that no
header bytes were received from the script.

Looking at my still-untidy stuff around the headers, I found that AHA! 
The header stuff was only being generated for the initial connection;
after that, a cookie in the browser would be detected, and all of the
header output would be avoided.  Something like: 

    if {[lsearch -exact [cgi_cookie_list] clientid]==-1} {
      puts "Content-type: content=\"text/html\"; charset=\"EUC-JP\""
      puts "Pragma: content=\"no-cache\""
      puts "Set-Cookie: clientid=$clientid"
    }

I also notice that I had no empty line between these "headers"  and the
start of <HTML>.  Oops. 

When I "fixed" things so that Content-type: and the Pragma: both output
always, and added the empty line, I got what looks like *Apache's*
Content-type: header (text/plain) as part of the text of the document when
it is rendered.  What's Apache putting its finger into the works for?

I'm really just thrashing around with this at the moment.  What I want to
do is fix the Content-type: header in the CGI and persuade Apache to just
trust me and pass my headers through to the client verbatim.  I think that
the FastCGI interface may be failing because I am not generating correct
headers, but Apache won't leave well enough alone when I do.  Grrr.

If anyone has read this far without their eyes glazing over ...  any
suggestions?  Including (especially) texts I should read to better learn
my way around Apache and CGI programming. 

This project seemed so delightfully simple when I first dreamed it up ...
:-(

Cheers,
Frank

--------------------------------------------------------------------
Next Nomikai Meeting: February 18 (Fri) 19:00 Tengu TokyoEkiMae
Next Technical Meeting:  March 11 (Sat) 13:00 Temple University Japan
* Topic: TBD
--------------------------------------------------------------------
more info: http://www.tlug.gr.jp        Sponsor: Global Online Japan


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links