Skip Menu |

This queue is for tickets about the libwww-perl CPAN distribution.

Report information
The Basics
Id: 28910
Status: rejected
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: branschen [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 5.10
  • 5.18
  • 5.22
  • 5.36
  • 5.43
  • 5.44
  • 5.45
  • 5.46
  • 5.47
  • 5.48
  • 5.49
  • 5.50
  • 5.51
  • 5.52
  • 5.53
  • 5.53_97
  • 5.60
  • 5.61
  • 5.62
  • 5.63
  • 5.64
  • 5.65
  • 5.66
  • 5.67
  • 5.68
  • 5.69
  • 5.70
  • 5.71
  • 5.72
  • 5.73
  • 5.74
  • 5.75
  • 5.76
  • 5.77
  • 5.78
  • 5.79
  • 5.800
  • 5.801
  • 5.802
  • 5.803
  • 5.804
  • 5.805
  • 5.806
  • 5.807
  • 5.808
Fixed in: (no value)



Subject: HTTP::Daemon sends invalid Content-Length for wide character content (fixed)
The Content-Length HTTP header should represent the number of bytes to expect. The length(EXPR) function in Perl returns the number of characters. For content with wide characters, the length(EXPR) of the string is not equal to the number of bytes. This causes web browsers to stop reading before the entire page is loaded. To get the length in bytes, one should use "do { use bytes; length(EXPR) }". The attached patch fixes the problem. % perl -v This is perl, v5.6.1 built for i386-linux % uname -a Linux barracuda 2.4.21 #5 SMP Wed Jan 7 15:17:13 UTC 2004 i686 unknown
Subject: HTTP_Daemon.patch
--- Daemon.pm.old Mon Aug 20 12:00:36 2007 +++ Daemon.pm Mon Aug 20 11:59:07 2007 @@ -228,7 +228,7 @@ # pretend it was a normal entity body $r->remove_header('Transfer-Encoding'); - $r->header('Content-Length', length($body)); + $r->header('Content-Length', do { use bytes; length($body) }); my($key, $val); FOOTER: @@ -436,7 +436,7 @@ } } elsif (length($content)) { - $res->header("Content-Length" => length($content)); + $res->header("Content-Length" => do { use bytes; length($content) }); } else { $self->force_last_request; @@ -498,7 +498,7 @@ unless ($self->antique_client) { $self->send_basic_header($status); print $self "Content-Type: text/html$CRLF"; - print $self "Content-Length: " . length($mess) . $CRLF; + print $self "Content-Length: " . do { use bytes; length($mess) } . $CRLF; print $self $CRLF; } print $self $mess;
The content of HTTP::Message objects should always be bytes and the lower level functions that use it should be able to assume this. Please make sure that any content is encoded before it's added to an HTTP::Message. I've now added tests to HTTP::Message that make it croak if you try to set the content to a Unicode string.