Extra CR chars inserted into a downloaded file

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"
"text/plain"
"iso-8859-1"

"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

···

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"
"text/plain"
"iso-8859-1"

"abcdefg\n"

Exit code: 0

thanks,
Nate Morse

Have we tried:

open("http://localhost/test/test.txt", 'rb') { |f|
   ...etc...
}

···

On May 26, 2006, at 9:39 AM, Nate Morse wrote:

open("http://localhost/test/test.txt"\) {|f|
f.each_line {|line| p line}
p f.content_type
p f.charset + '\n'

}

Hi Mat et.al.
Trying various Apache config settings such as:
    # tried others such as application/x-gzip and application/octet-stream ...
    AddType application/x-other .txt

yeilds:
p f.content_type --> 'application/x-other'
p f.charset --> nil

but the extra \r's are still appearing "abcdefg\r\n",
also I downloaded the same file using FireFox with no extra chars
hmmm... do I dive into the source of Net::HTTP, or is the jury still
out on Apache
--Nate

···

On 5/26/06, Mat Schaffer <schapht@gmail.com> wrote:

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&quot;\) {|f|
> f.each_line {|line| p line}
> p f.content_type
> p f.charset
> print "\n"
> }
>
> File.open("C:/www/test/test.txt", "r") {|f|
> f.each_line {|line| p line}
> }
>
> # EOF
>
> -->
>
>> ruby downloadFile.rb
> "abcdefg\r\n"
> "text/plain"
> "iso-8859-1"
>
> "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

I'd do one last thing. I seem to remember something about \r\n being the line separator for the HTTP standard (in the RFC). If you could hack together something that accesses apache without Net::HTTP, I'd try that. If it works, then the problem lies in Net:::HTTP.
Good luck,
Mat

···

On May 26, 2006, at 12:21 PM, Nate Morse wrote:

Hi Mat et.al.
Trying various Apache config settings such as:
   # tried others such as application/x-gzip and application/octet-stream ...
   AddType application/x-other .txt

yeilds:
p f.content_type --> 'application/x-other'
p f.charset --> nil

but the extra \r's are still appearing "abcdefg\r\n",
also I downloaded the same file using FireFox with no extra chars
hmmm... do I dive into the source of Net::HTTP, or is the jury still
out on Apache
--Nate

On 5/26/06, Mat Schaffer <schapht@gmail.com> wrote:

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&quot;\) {|f|
> f.each_line {|line| p line}
> p f.content_type
> p f.charset
> print "\n"
> }
>
> File.open("C:/www/test/test.txt", "r") {|f|
> f.each_line {|line| p line}
> }
>
> # EOF
>
> -->
>
>> ruby downloadFile.rb
> "abcdefg\r\n"
> "text/plain"
> "iso-8859-1"
>
> "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