处理wsgi时需小心的问题

Posted in Tech on 2009/08/13 – 21:19
Post a comment

首先,response的所有heaer必须为字符串,unicode,数字都不可以!

当然,在一般的测试服务器中没什么大不了的,但是在apache的mod_wsgi中你或许就会遇到这种很奇怪的问题。

再者,计算response的content-length时需小心。不然就可能出现页面下载不完全的问题。

请注意 len(”中文”) 和 len(u”中文”)的长度是不同的,因此计算输出页面长度之前,最好先encode为utf-8。这样页面显示就正常了。

如果你喜欢这篇文章,欢迎 订阅我的 RSS feed!


Tags: , |
This entry was written by youngking, filed under Tech and tagged , .
Bookmark the permalink or follow any comments here with the RSS feed for this post.
Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never shared. Required fields are marked *

*
*