Python CGI problem: correct result, but incorrect browser response.

Tim Roberts timr at probo.com
Fri Apr 7 02:43:53 EDT 2006


"Sullivan WxPyQtKinter" <sullivanz.pku at gmail.com> wrote:
>
>title:Python CGI problem: correct result, but incorrect browser
>response.
>
>In one of my CGI program,named 'login.py', the script return a HEADER
>to web browser:
>
>Set-Cookie: sessionID=LAABUQLUCZIQJTZDWTFE;
>Set-Cookie: username=testuser;
>Status:302
>Location:edit.py
>(blank line)
>
>but the IE prompted to let me choose to save the 'login.py'. When I
>save it, the file is just the header. That means the IE failed to parse
>the header. My IE has already enabled cookie read and write. I also
>tried Firefox, but the result is the same. How does this happen?

Perhaps you should show us the script.  Is it possible that you have
already printed a "Content-Type" header and blank line before these
headers, or perhaps just a blank line?  Remember that this will fail:

    print """
Set-Cookie: sessionID=LAABUQLUCZIQJTZDWTFE;
Set-Cookie: username=testuser;
Status:302
Location:edit.py
"""

because you get a blank line first, which terminates the headers.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list