I tried to fix the Content-Type of a feed in my app, I read the Response Class documentation and it had a line of code (didnt try Expires)):
self.response.headers.add_header('Expires', expires_str)
Needless to say I adopted it and made it to be:
self.response.headers.add_header('Content-Type', 'application/rss+xml; charset=utf-8')
It works on Development Server but not on Production Server, so I also tried after I read wsgiref.headers:
self.response.headers.add_header('content-type', 'application/rss+xml', charset='utf-8')
Still no luck.
I searched on discussion group, then I found everyone coded in this way (and I actually didnt like this way):
self.response.headers['Content-Type'] = 'application/rss+xml; charset=utf-8'
And it works. I have no idea whats going on Production server and I didnt bother to look into it.
I ran into this too. The issue is that if a header already exists, add_header adds a new header, but doesnt overwrite the old one. App Engine sets a text/html header by default. By using the dictionary syntax, you do override that.
ReplyDelete