Patch for libwww-perl 5.03 and binary files

Christopher J. Madsen (ac608@yfn.ysu.edu)
Fri, 18 Oct 96 11:52:06 -0500


I want to report a couple of bugs in libwww-perl 5.03.
The first is just a minor typo:

*** lib/URI/URL/file.pm~	Tue Sep 17 04:21:10 1996
--- lib/URI/URL/file.pm		Tue Oct  1 21:22:40 1996
***************
*** 57,59 ****
  
!     Carp::Croak("Only implemented for Unix file systems")
        unless $ostype eq "unix";
--- 57,59 ----
  
!     Carp::croak("Only implemented for Unix file systems")
        unless $ostype eq "unix";

The other is more serious.  I use OS/2, not Unix, and I discovered
that passing a filename to the response() method resulted in corrupted
binary files.  The problem turned out to be the LWP::Protocol::collect
method, which did not use 'binmode' when opening the file.  This patch
sets binary mode for all content-types except text/*.  I believe this
is the correct behavior, but I'm not an expert in this area.

*** lib\LWP\Protocol.pm~	Tue Sep 17 04:20:58 1996
--- lib\LWP\Protocol.pm		Fri Oct 18 00:38:26 1996
***************
*** 217,222 ****
--- 217,223 ----
  	open(OUT, ">$arg") or
  	    return new HTTP::Response RC_INTERNAL_SERVER_ERROR,
  			  "Cannot write to '$arg': $!";
+         binmode OUT unless $response->content_type =~ m!^text/!;
          local($\) = ""; # ensure standard $OUTPUT_RECORD_SEPARATOR
  	while ($content = &$collector, length $$content) {
  	    if ($parser) {

I have also made some patches to the test scripts to make them run on
my system, but I haven't included those.  Many of them are specific to
my directory structure, and others would break on Unix.  If anyone
would like a copy, I'll be glad to mail them one.

BTW, I'm not on this list, since I'm only an occasional user of LWP.

-- 
Chris Madsen                                         ac608@yfn.ysu.edu
 ------- http://www.geocities.com/SiliconValley/Heights/3222/ -------