From ruby-talk Mon Feb 02 07:19:48 2004 From: Emmanuel Touzery Date: Mon, 02 Feb 2004 07:19:48 +0000 To: ruby-talk Subject: Re: nuby: can't get an image via http Message-Id: <401DFAA3.5030101 () wanadoo ! fr> X-MARC-Message: https://marc.info/?l=ruby-talk&m=107570643421517 Tanaka Akira wrote: >>I confirm that the code i posted in the previous message (and that I repost >>here) works under linux. the fact it doesn't work under windows is definitely >>related to the binary flag of the files. maybe it's a bug in open-uri that >>the file is not in binary mode? >> >> > >How about following patch? > >Index: lib/open-uri.rb >=================================================================== >RCS file: /src/ruby/lib/open-uri.rb,v >retrieving revision 1.19 >diff -p -u -r1.19 open-uri.rb >--- lib/open-uri.rb 31 Jan 2004 18:11:54 -0000 1.19 >+++ lib/open-uri.rb 31 Jan 2004 20:12:57 -0000 >@@ -221,6 +221,7 @@ module OpenURI > if StringIO === @io && StringMax < @size > require 'tempfile' > io = Tempfile.new('open-uri') >+ io.binmode > Meta.init io, @io if Meta === @io > io << @io.string > @io = io > > That's it! The patch *looked* right, but now it's tested right. it's now working. It should be commited to ruby-cvs! emmanuel