Errin when executing a cgi script that sets a cookie in the browser
Cameron Simpson
cs at zip.com.au
Wed Jun 5 20:32:37 EDT 2013
On 05Jun2013 14:18, rurpy at yahoo.com <rurpy at yahoo.com> wrote:
| On Wednesday, June 5, 2013 3:03:29 PM UTC-6, Chris Angelico wrote:
| > On Thu, Jun 6, 2013 at 6:56 AM, <rurpy at yahoo.com> wrote:
| > > On Wednesday, June 5, 2013 1:54:45 PM UTC-6, Νικόλαος Κούρας wrote:
| > >>...
| > >> print( cookie, "Content-type: text/html; charset=utf-8\n", message )
| > >>...
| > > print( cookie, "Content-type: text/html; charset=utf-8\n\n", message )
| > > (ie, note the two \n's after the "utf-8" test.)
| >
| > But that won't solve it either. The default separator for print is a
| > space, so this will indent his Content-type line by one space.
|
| Ah, quite right. Something like
|
| print( cookie, "\nContent-type: text/html; charset=utf-8\n\n", message )
|
| then.
Unless "cookie" already has a newline. Then you'll end the headers there:-)
A more robust approach might be to build a dict (or possibly better,
list) of headers without newlines and then as a separate act to
print them with newlines and add the spacer newline later, before
writing the message body.
Cheers,
--
Cameron Simpson <cs at zip.com.au>
Drill for oil? You mean drill into the ground to try and find oil?
You're crazy.
--Drillers whom Edwin L. Drake tried to enlist to his project
to drill for oil in 1859.
More information about the Python-list
mailing list