in reply to Re: Determining content-length for an HTTP Post
in thread Determining content-length for an HTTP Post

How would I go about using it?
  • Comment on Re^2: Determining content-length for an HTTP Post

Replies are listed 'Best First'.
Re^3: Determining content-length for an HTTP Post
by WizardOfUz (Friar) on Nov 25, 2009 at 17:53 UTC
    use bytes; my $length_in_bytes = length( $xmldata );
      If the problem is that he forgot to encode his XML, the solution is NOT to get the length of the internal representation of the XML, it's to encode the XML.
      use Encode qw( encode ); # Or whatever encoding you specified in <?xml?> $xmldata = encode('UTF-8', $xmldata); my $length = length( $xmldata );
      or
      utf8::encode( $xmldata ); my $length = length( $xmldata );

        Huh? The bytes pragma simply forces $xmldata to be treated as a series of bytes. This should give us the correct value for the Content-Length header whether $xmldata is a character string or an UTF-8 encoded byte string. Or am I missing something?