The perl length() function returns the number of characters in a string, while the HTTP Content-Length header is the number of bytes in the content. If your content contains multi-byte characters, these won't be the same thing.
>From perldoc length: Note the characters: if the EXPR is in Unicode, you will get the number of characters, not the number of bytes. To get the length of the internal string in bytes, use bytes::length(EXPR) , see bytes. Note that the internal encoding is variable, and the number of bytes usually meaningless. To get the number of bytes that the string would have when encoded as UTF-8, use length(Encoding::encode_utf8(EXPR)). On Sep 5, 11:02 am, Ethan <[EMAIL PROTECTED]> wrote: > I am using a Perl script to post the contents of text file to my app > from a Solaris server. The script is available here. > > http://www.cpan.org/authors/id/E/EL/ELIJAH/bget-1.1 > > It sets the Content-Length based on the size of the file I am posting, > however when I check self.request.body it ends up truncating a few of > the characters off the end. If I modify the bget script and increase > the size the characters show up. There doesn't seem to be any > consistency, more lines in the file usually means more characters > getting clipped, so it isn't like I need to add 1 byte or anything. > > Perhaps there is a bug in the perl script but I am thinking this is > some sort of character/type language thing. What are the rules in > regards to setting the Content-Length correctly? > > Thanks, > Ethan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" 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/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---
