BTW, the reason you would not see last character with your original length is because mod_wsgi will cut off any content beyond the specificed Content-Length header as returning more is in violation of the HTTP specification. Your program was thus in violation and mod_wsgi tidied up for you so no problems would occur with Apache or intermediate proxy if pipelining was being used.
Graham On 7 October 2011 07:05, Graham Dumpleton <[email protected]> wrote: > As Joonas said, use: > > #!/usr/local/bin/python3.2 > # -*- coding: utf-8 -*- > > > def application(environ, start_response): > status = '200 OK' > output = 'Prueba con Ñ1' > > bytes_output = output.encode('utf-8') > > response_headers = [('Content-type', 'text/plain; charset=utf-8'), > ('Content-Length', str(len(bytes_output)))] > start_response(status, response_headers) > > return [bytes_output] > > IOW, Content-Length must be calculated from encode byte string, not > unicode string. > > Graham > > On 7 October 2011 05:14, Manuel Antonio Mora Sandoval > <[email protected]> wrote: >> Yes, I agree, but why don't I see the content complete?, I need to see >> "Prueba con Ñ1" and in this moment I am seeing "Prueba con Ñ", without 1 >> Thank yuo for you answer. >> >> 2011/10/6 Jason Garber <[email protected]> >>> >>> The len() of the string is likely 1 less than the len() of the encided >>> bytes because of multibyte characters. >>> >>> Content-length is expressed in bytes. >>> >>> Take care, >>> JG >>> >>> On Oct 6, 2011 11:33 AM, "Manuel Antonio Mora Sandoval" >>> <[email protected]> wrote: >>> > Hi. >>> > >>> > I have a problem. When I use characters like Ñ, á, é, etc, the navegator >>> > don't shows the last caracters. >>> > >>> > for example, I have the follow code: >>> > >>> > #!/usr/local/bin/python3.2 >>> > # -*- coding: utf-8 -*- >>> > >>> > >>> > def application(environ, start_response): >>> > status = '200 OK' >>> > output = 'Prueba con Ñ1' >>> > >>> > response_headers = [('Content-type', 'text/plain; charset=utf-8'), >>> > ('Content-Length', str(len(output)))] >>> > start_response(status, response_headers) >>> > >>> > return [output.encode('utf-8')] >>> > >>> > I would in the navegator "Prueba con Ñ1", but I get "Prueba con Ñ", >>> > without >>> > number 1. >>> > >>> > I reviewed the headers, and these have Content-Length: 13, I think that >>> > "Ñ" >>> > occupy two positions and the apache or module cut the string. >>> > >>> > I don't know how do I fixed it? >>> > >>> > thank you for help me. >>> > >>> > -- >>> > You received this message because you are subscribed to the Google >>> > Groups "modwsgi" group. >>> > To post to this group, send email to [email protected]. >>> > To unsubscribe from this group, send email to >>> > [email protected]. >>> > For more options, visit this group at >>> > http://groups.google.com/group/modwsgi?hl=en. >>> > >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "modwsgi" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/modwsgi?hl=en. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "modwsgi" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/modwsgi?hl=en. >> > -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
