Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine HTTP header Content-Type not correct once application is deployed

I am writing an app on GAE and I have a URL that will always return XML and set the Content-Type to "text/xml; charset=utf-8".

I am using the built in webapp framework and using the following code to set content type and return XML in the web handler:

self.response.headers.add_header('Content-Type',"text/xml; charset=utf-8")
self.response.out.write(template.render("my_xml",{"key1":"val1"}))

This works fine on the local development environment but once I deploy to the Google servers the content type is always set to "text/html; charset=utf-8".

How do I make sure that correct Content-Type is set once it runs on the Google servers?

like image 724
Evan Avatar asked Jun 14 '09 04:06

Evan


1 Answers

Use self.response.headers['Content-Type'] = "text/xml; charset=utf-8", so that you override the content-type rather than adding another homonymous header.

like image 165
Alex Martelli Avatar answered Nov 11 '22 01:11

Alex Martelli