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

  • Thread starter Sullivan WxPyQtKinter
  • Start date
S

Sullivan WxPyQtKinter

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?
 
T

Tim Roberts

Sullivan WxPyQtKinter said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top