From: Mat Schaffer Date: 2006-05-26T23:07:12+09:00 Subject: Re: Extra CR chars inserted into a downloaded file On May 26, 2006, at 9:39 AM, Nate Morse wrote: > Hello all, > Could anyone help shed light on some pesky (extra) Carrige Rreturns > '\r's > > I'm in a windows environment, and I'm seeing extra chars in a download > vs. direct file access. > normally I would not care but later I will be checking MD5's on both > sides and they will not match. > > # Ruby file downloadFile.rb > require 'open-uri' > > open("http://localhost/test/test.txt") {|f| > f.each_line {|line| p line} > p f.content_type > p f.charset + '\n' > > } > > File.open("C:/www/test/test.txt", "r") {|f| > f.each_line {|line| p line} > } > > # EOF > > --> > >> ruby downloadFile.rb > "abcdefg\r\n" > "abcdefg\r\n" > "abcdefg\r\n" > "text/plain" > "iso-8859-1" > > "abcdefg\n" > "abcdefg\n" > "abcdefg\n" >> Exit code: 0 > > thanks, > Nate Morse I would blame the webserver before ruby... Try to make the webserver consider .txt to be binary data, and see what happens. -Mat