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
IE problems when response headers are changed inside the controller
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
León Domingo  
View profile  
 More options Oct 11 2012, 7:51 am
From: León Domingo <leon.domi...@ender.es>
Date: Thu, 11 Oct 2012 04:51:41 -0700 (PDT)
Local: Thurs, Oct 11 2012 7:51 am
Subject: IE problems when response headers are changed inside the controller

Hi people,

I have this controller method:

        @expose()
    def get(self, codigo):

        aa = dbs.query(ArchivosAsociados).\
            filter(ArchivosAsociados.codigo == codigo).first()

        if aa.caducidad and aa.caducidad > dt.datetime.now():
            content, mt, file_name = SapnsDoc.download(aa.id_recurso)
            response.headerlist.append(('Content-Type', mt.encode('utf-8')))
            response.headerlist.append(('Content-Disposition',
'attachment;filename=%s' % file_name))

            return content

        else:
            redirect(url('/banco_de_recursos/recurso_caducado/',
params=dict(codigo=codigo)))

As you can see "mime-type" is "calculated" ("Content-Type" header is added
dynamically) inside the method. I've read a record from the database which
gives me the "mime-type" (mt) and "file name" (file_name). Content
(content) 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ón


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alessandro Molina  
View profile  
 More options Oct 11 2012, 6:12 pm
From: Alessandro Molina <alessandro.mol...@gmail.com>
Date: Fri, 12 Oct 2012 00:12:22 +0200
Local: Thurs, Oct 11 2012 6:12 pm
Subject: Re: [TurboGears] IE problems when response headers are changed inside the controller
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 characters.

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
León Domingo  
View profile  
 More options Nov 1 2012, 6:00 pm
From: León Domingo <leon.domi...@ender.es>
Date: Thu, 1 Nov 2012 22:59:51 +0100
Local: Thurs, Nov 1 2012 5:59 pm
Subject: Re: [TurboGears] IE problems when response headers are changed inside the controller

Hi again,
I tested it and I think it works.

The reason to encode (.encode('utf-8')) is that those mime types come from
a database and SQLAlchemy give them to me as unicode, so I have to encode
them. Now I do the same thing but using "latin1" coding instead of "utf-8".

Thanks, Alessandro

León Domingo

Ender - Factoría de Software
leon.domi...@ender.es <jestre...@ender.es>
Avda. Cerro del Águila, 7. S23 - 2ª Planta
28703 S.S. de los Reyes (MADRID)
Tlf. 902 01 44 01

<http://www.ender.es/>
<http://www.facebook.com/home.php?#%21/pages/San-Sebastian-de-los-Reye...>
* <http://www.ender.es>*

On 12 October 2012 00:12, Alessandro Molina <alessandro.mol...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »