Skip to content

Commit

Permalink
rename README to README.doc and update some contents for ftp
Browse files Browse the repository at this point in the history
  • Loading branch information
xianhuazhou committed Apr 1, 2009
1 parent 5045c11 commit f7bf654
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Changelog
@@ -0,0 +1,7 @@
v1.1
* new feature: upload or download file by ftp

v1.0
* support get, post, put, delete etc. http methods
* upload files
* and more...
46 changes: 46 additions & 0 deletions README → README.rdoc
Expand Up @@ -132,11 +132,57 @@ $./http_request.rb post http://localhost/test.php 'name=Ruby&time=Now'

such as "get_only_header" and "get_with_header", post and other http methods also can do such as "post_only_header", "put_with_header" etc.

== FTP Example (since 1.0.1):

# download and save to
ftp = HttpRequest.ftp(:get, :url => 'ftp://user:pass@my.domain.name/path/to/hello.mp3', :to => '/tmp/hello.mp3')

# upload from local
ftp = HttpRequest.ftp(:put, :url => 'ftp://user:pass@my.domain.name/path/to/hello.mp3', :from => '/tmp/hello.mp3')

# get server info
puts HttpRequest.ftp(:status, :url => 'ftp://user:pass@my.domain.name/')

# create a new directory (only for last directory)
HttpRequest.ftp(:mkdir, :url => 'ftp://user:pass@my.domain.name/path/to/newdir')
HttpRequest.ftp(:mkdir, :url => 'ftp://user:pass@my.domain.name/newdir')

# remove a directory (only for last directory)
HttpRequest.ftp(:mkdir, :url => 'ftp://user:pass@my.domain.name/path/to/willbe_removed_dir')

# list files
puts HttpRequest.ftp(:list, :url => 'ftp://user:pass@my.domain.name/')

# list files as array
HttpRequest.ftp(:nlst, :url => 'ftp://my.domain.name/', :username => 'user', :password => 'pass').each {|f|
puts f
}

# anonymous
puts HttpRequest.ftp(:status, :url => 'ftp://my.domain.name/')

# working as the "net/ftp" style, need set :close to false
ftp = HttpRequest.ftp(:status, :url => 'ftp://user:pass@my.domain.name/', :close => false)
puts ftp.response # get status from the ftp server
ftp.chdir('/musics')
ftp.getbinaryfile('test.ogg', '/tmp/test.ogg')
ftp.close

# download multiple files from a directory
ftp = HttpRequest.ftp('nlst', :url => 'ftp://user:pass@my.domain.name/mp3/', :close => false)
ftp.response.each {|f|
puts "downloading....#{f}"
ftp.get(f, '/tmp/downloads/' + File.basename(f))
}
ftp.close

== TODO

......

== LATEST VERSION
1.0.1

== Author

xianhua.zhou<xianhua.zhou at gmail.com>, homepage: http://my.cnzxh.net
Binary file removed dist/http_request.rb.1.0.tar.gz
Binary file not shown.

0 comments on commit f7bf654

Please sign in to comment.