Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'charset:iso-8859-7': 0.04; 'skip:\\ 20': 0.07; 'wednesday,': 0.07; 'interpreted': 0.09; 'rfc': 0.09; 'skip:\\ 10': 0.09; 'subject:script': 0.09; 'apache': 0.15; '6:56': 0.16; 'content-type': 0.16; 'cookie,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'headers.': 0.16; 'indent': 0.16; 'subject:when': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'thu,': 0.19; 'not,': 0.20; 'saying': 0.22; 'print': 0.22; 'error': 0.23; 'either.': 0.24; 'script.': 0.24; 'space.': 0.24; 'text.': 0.24; 'header': 0.24; 'header:In-Reply- To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'lines': 0.31; 'subject:that': 0.31; 'text': 0.33; 'subject:the': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'like,': 0.36; 'two': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'blank': 0.60; 'solve': 0.60; 'between': 0.67; 'default': 0.69; 'have?': 0.84; 'start.': 0.84; 'text/html;': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=7NKxd9NBxlqetj5mRGHZOypoHvXfeOKiEZCavfzD23g=; b=QvPG7uwKK2DHEkglcwvq0D1xREvyIN6hX7rhB3+lfRR26/K2OIhAs3lErkf1mDZSoA pOmyKInbYWACFX/wYpICHby3yiIy2AVk7JFNixUGqrYcZsCzaQ1dhJY3sk+Asags8OVG qC4keuTgYHqdfaM581XALqia/k23oTf1AJifoblHldIXlRg68PJ4whH5uONQW9d8DqCq VhFSY+BnYHsrqmHCfOF+8TZyq8OGZCldiZhp3AuBGAYJQukUuicgdo7TPT2Ki3dnEhiJ Z7UyW3xb104VQRTji7bQnggjumf+PanyWo6UQWJnai/Ta5fOgYLUZ34RZ7RN2mntABT2 ssgQ== MIME-Version: 1.0 X-Received: by 10.58.116.229 with SMTP id jz5mr21426158veb.14.1370466209602; Wed, 05 Jun 2013 14:03:29 -0700 (PDT) In-Reply-To: <386bdf4a-53ae-4312-af5d-e28ef10ada42@googlegroups.com> References: <400ea041-adcf-4640-8872-f81808f7d402@googlegroups.com> <386bdf4a-53ae-4312-af5d-e28ef10ada42@googlegroups.com> Date: Thu, 6 Jun 2013 07:03:29 +1000 Subject: Re: Errin when executing a cgi script that sets a cookie in the browser From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370466218 news.xs4all.nl 15908 [2001:888:2000:d::a6]:41888 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:47151 On Thu, Jun 6, 2013 at 6:56 AM, wrote: > On Wednesday, June 5, 2013 1:54:45 PM UTC-6, =CD=E9=EA=FC=EB=E1=EF=F2 =CA= =EF=FD=F1=E1=F2 wrote: >>... >> print( cookie, "Content-type: text/html; charset=3Dutf-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 heade= r from script. Bad header=3D \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=3Dutf-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