Errin when executing a cgi script that sets a cookie in the browser

rurpy at yahoo.com rurpy at yahoo.com
Wed Jun 5 16:56:03 EDT 2013


On Wednesday, June 5, 2013 1:54:45 PM UTC-6, Νικόλαος Κούρας wrote:
>...
> print( cookie, "Content-type: text/html; charset=utf-8\n", message )
>...

If you look in the Apache error log file, you will see something like,

  [Wed Jun 05 16:39:14 2013] [error] [client 192.168.0.1] malformed header from script. Bad header= \xce\x91\xce\xa0\xce\x9f \xce\x94\xce\xa9 \xce\x9a\xce\x91\xce\x99 \xce\xa3\xce\xa4\xce\x9f \xce\x95\xce: koukos.py

which is saying that the 'message' text is being interpreted as 
being part of the headers.

You are missing a blank line between the header lines and the 
page text.  That is, I think you want, 

  print( cookie, "Content-type: text/html; charset=utf-8\n\n", message )

(ie, note the two \n's after the "utf-8" test.)



More information about the Python-list mailing list