Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion IE problems when response headers are changed inside the controller

Received: by 10.50.0.148 with SMTP id 20mr402369ige.3.1349993546876;
        Thu, 11 Oct 2012 15:12:26 -0700 (PDT)
X-BeenThere: turbogears@googlegroups.com
Received: by 10.50.0.208 with SMTP id 16ls571536igg.1.canary; Thu, 11 Oct 2012
 15:12:23 -0700 (PDT)
Received: by 10.42.80.2 with SMTP id t2mr188370ick.9.1349993543190;
        Thu, 11 Oct 2012 15:12:23 -0700 (PDT)
Received: by 10.42.80.2 with SMTP id t2mr188369ick.9.1349993543181;
        Thu, 11 Oct 2012 15:12:23 -0700 (PDT)
Return-Path: <alessandro.mol...@gmail.com>
Received: from mail-ie0-f181.google.com (mail-ie0-f181.google.com [209.85.223.181])
        by gmr-mx.google.com with ESMTPS id ba5si2381igb.3.2012.10.11.15.12.23
        (version=TLSv1/SSLv3 cipher=OTHER);
        Thu, 11 Oct 2012 15:12:23 -0700 (PDT)
Received-SPF: pass (google.com: domain of alessandro.mol...@gmail.com designates 209.85.223.181 as permitted sender) client-ip=209.85.223.181;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of alessandro.mol...@gmail.com designates 209.85.223.181 as permitted sender) smtp.mail=alessandro.mol...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-ie0-f181.google.com with SMTP id 16so4052774iea.40
        for <turbogears@googlegroups.com>; Thu, 11 Oct 2012 15:12:23 -0700 (PDT)
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=lotclsimKMcFbJeQVHegIh5ppfliNlb1Ijy2QfEjBQQ=;
        b=dtYk+sOfzS/vtwA7RHSvnqhPDRPZC/GTsFHu9Mv97NhJdGLFJDjdLaTeZpJmx/HB0r
         aIIq4ZHNh9l2fbf3G8N+hrOau8hvD0xbqnBiMAnoI9G6CkopNZZtha0WkkE8B1hZDTSH
         uOkVsAM/PIS/A9ojJqTrCwlabeka7nG6IEEcwn/0eDb7sgv9UeZi7PwJ/4KFRcSCefC5
         /xi5LjEt1aNaI+6HCAHgcCc/oFXxAnacsk8TwCGxEise4bKoLmwY2lq/sHLaDZaV3Sfj
         r15h8rqikybtM7lZncvWXImtzCrx189bM7VX3iPT3X6t9zyjrRWaPumcGt1w9NKSAWMQ
         mVQA==
MIME-Version: 1.0
Received: by 10.50.41.132 with SMTP id f4mr447781igl.39.1349993543000; Thu, 11
 Oct 2012 15:12:23 -0700 (PDT)
Received: by 10.64.129.225 with HTTP; Thu, 11 Oct 2012 15:12:22 -0700 (PDT)
In-Reply-To: <54ca5bfa-374c-4a18-8ac2-eb2e576da7a0@googlegroups.com>
References: <54ca5bfa-374c-4a18-8ac2-eb2e576da7a0@googlegroups.com>
Date: Fri, 12 Oct 2012 00:12:22 +0200
Message-ID: <CAJfq2JHWH9fVxHod8AG=C6CRrJnguBCW4=p3LA9PFU6ZCDa...@mail.gmail.com>
Subject: Re: [TurboGears] IE problems when response headers are changed inside
 the controller
From: Alessandro Molina <alessandro.mol...@gmail.com>
To: turbogears@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

mt.encode('utf-8') might end up being wrong, HTTP Headers should only
be latin1 if I remember correctly.
Even though, probably, there aren't mime types which contain utf8 character=
s.

Also you should be able to use response.content_type =3D
'yourcontenttype' and response.headers['Content-Disposition']=3D...
instead of relying on response.headerlist.append, which is a bit
easier to read and write.



On Thu, Oct 11, 2012 at 1:51 PM, Le=F3n Domingo <leon.domi...@ender.es> wro=
te:
> Hi people,
>
> I have this controller method:
>
>         @expose()
>     def get(self, codigo):
>
>         aa =3D dbs.query(ArchivosAsociados).\
>             filter(ArchivosAsociados.codigo =3D=3D codigo).first()
>
>         if aa.caducidad and aa.caducidad > dt.datetime.now():
>             content, mt, file_name =3D SapnsDoc.download(aa.id_recurso)
>             response.headerlist.append(('Content-Type', mt.encode('utf-8'=
)))
>             response.headerlist.append(('Content-Disposition',
> 'attachment;filename=3D%s' % file_name))
>
>             return content
>
>         else:
>             redirect(url('/banco_de_recursos/recurso_caducado/',
> params=3Ddict(codigo=3Dcodigo)))
>
> As you can see "mime-type" is "calculated" ("Content-Type" header is adde=
d
> dynamically) inside the method. I've read a record from the database whic=
h
> gives me the "mime-type" (mt) and "file name" (file_name). Content (conte=
nt)
> is read from the file itself which is stored in the hard disk.
>
> Ok, this thing does not work on IE8 or IE7. Chrome, FF, Opera, Safari or
> even IE9 do the right thing.
>
> Any suggestion?
>
> Thanks in advance
>
> Le=F3n
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/EIFdY1yODPgJ.
> To post to this group, send email to turbogears@googlegroups.com.
> To unsubscribe from this group, send email to
> turbogears+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=3Den.