Nuby: can't get an image via http

Hello,

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?
setting it when I get it using “binmode” doesn’t seem to help :O(

···

===============
require ‘open-uri’

mapfile = File.open(‘map.png’, ‘wb’)
open(‘http://ras.chizumaru.com/ncg/tcmap.dll?id=NCZ&PASS=NewCZPrtT&X=129374719&Y=103205254&LV=3&WID=650&HEI=680&SZ=PRT_T&TAB=live2003_scl&FUNC=2’)
{|f|
f.binmode
mapfile.write f.read
}
mapfile.close

In article 200401271823.35269.emmanuel.touzery@wanadoo.fr,
Emmanuel Touzery emmanuel.touzery@wanadoo.fr writes:

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
    


Tanaka Akira

I’d be happy to test, unfortunately i don’t have a compiler nor much time to
try and compile ruby for win32… :O(

hopefully someone will step in and check this out.

emmanuel

···

On Saturday 31 of January 2004 21:23, Tanaka Akira wrote:

In article 200401271823.35269.emmanuel.touzery@wanadoo.fr,

Emmanuel Touzery emmanuel.touzery@wanadoo.fr writes:

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?

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

i’m stupid :O)
i just need to change the open-uri .rb files in the ruby distribution :O)

i’ll try that on monday at work (linux at home, windows at home).
i’ll repost then with results :O)

emmanuel

···

On Sunday 01 of February 2004 11:05, Emmanuel Touzery wrote:

On Saturday 31 of January 2004 21:23, Tanaka Akira wrote:

In article 200401271823.35269.emmanuel.touzery@wanadoo.fr,

Emmanuel Touzery emmanuel.touzery@wanadoo.fr writes:

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?

I’d be happy to test, unfortunately i don’t have a compiler nor much time
to try and compile ruby for win32… :O(

hopefully someone will step in and check this out.