Hello people,

I trying to play around with net/http on my Win2K (+cygwin) machine,
but didn't get too far, always getting the error:

/cygdrive/c/ruby/lib/ruby/1.6/net/protocol.rb:507:in `new': Invalid
argument - "connect(2)" (Errno::EINVAL)

(Which is apparently fixed in the current version under development
from what I could see in the newsgroup?)

Anyway, I then tried using ruby to download some files via HTTP using
Ruby on my Freebsd machine and encountered problems when trying to
unzip the file in question. I downloaded it using IE, and it appeared
fine???

Further investigation reveals it to be a CRLF problem, which is weird
in the fact that its happening on FreeBSD....?

As I'm still a ruby neophyte, (you can probably tell from the code
below) I don't think I'm up to diving into other people's libraries
(not yet anyway....)

Anyway, here's the details - any help greatly appreciated.

Cheers,
Gordon


--

Environment:

/usr/local/lib/ruby/1.6/net$ ruby --version
ruby 1.6.4 (2001-09-03) [i386-freebsd4.4]

--

Code fragment 1:

require 'net/http'

serverName =
  String.new("www.pragmaticprogrammer.com")
filePath = 
  String.new("/ruby/downloads/files/rubicon-0.1.4.tgz")

conn = Net::HTTP.new(serverName,80)

conn.start { |x|
  resp, data = x.get(filePath, nil)

  f = File.new("ruby_rubicon-0.1.4.tgz","w")
  f.print data
  f.close
}

--

Code fragment 2:

file1 = File.new("ie_rubicon-0.1.4.tgz","r")
file2 = File.new("ruby_rubicon-0.1.4.tgz","r")

file1Array = Array.new()
file2Array = Array.new()

file1.readlines.to_s.each_byte { |x| 
  file1Array << x.to_s
}

file2.readlines.to_s.each_byte { |x| 
  file2Array << x.to_s
}

puts "BYTE : OK,  NOTOK"
puts "------------------"

1.upto( file2Array.length ) { |x|
  if file1Array[x] != file2Array[x]
    (x - 10).upto(x + 10) { |y|
      puts "------------------" if y == x
      puts y.to_s + " : " + 
           "%03d" % file1Array[y] + 
           ", " +
           "%03d" % file2Array[y]
      puts "------------------" if y == x
    }
    break
  end
}

--

produces:

BYTE : OK,  NOTOK
------------------
3832 : 002, 002
3833 : 197, 197
3834 : 059, 059
3835 : 006, 006
3836 : 216, 216
3837 : 251, 251
3838 : 151, 151
3839 : 012, 012
3840 : 169, 169
3841 : 181, 181
------------------
3842 : 010, 013
------------------
3843 : 190, 010
3844 : 231, 190
3845 : 235, 231
3846 : 188, 235
3847 : 217, 188
3848 : 184, 217
3849 : 189, 184
3850 : 087, 189
3851 : 214, 087
3852 : 189, 214