From: Minero Aoki Date: 2002-02-19T20:59:36+09:00 Subject: Re: a file name with space for http In mail "a file name with space for http" moontoeki@aol.com (Sung Moon) wrote: > a file name with space for http > > my Ruby 1.6.5 platform is "i386-cygwin" on windows 98 > > i have a trouble for downloading a file using http protocol, like > response , = http.get( "#{FILE_NAME}" ) > > one web site has a file name with space in the name. > how to change the space? > I tried "file name" and "file%20name" which is used in browser, > but it failed. I could get files which name includes spaces, like this: ~ $ mkdir public_html ~ $ echo 'test ok' > 'public_html/a a' ~ $ ruby-1.6.5 -r net/http -e 'Net::HTTP.get_print "localhost", "/~aamine/a%20a", 8080' test ok More generaly, require 'net/http' require 'cgi' host = .... port = .... path = .... Net::HTTP.start(host, port) {|http| res, = http.get(CGI.escape(path)) } FYI: I cannot encode path automatically because it might includes already URL-encoded string. -- Minero Aoki