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

一笑奈何 提交于 2019-12-09 13:29:59

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/992180/google-app-engine-http-header-content-type-not-correct-once-application-is-deplo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!