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

Chris Angelico rosuav at gmail.com
Wed Jun 5 17:03:29 EDT 2013


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 )
>>...
>
> 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.)

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. Nikos,
do you know what effect that will have? If not, research HTTP. RFC
2616 is a good place to start.

ChrisA



More information about the Python-list mailing list