* lib/net/http.rb: add rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8368 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
514df9097e
commit
b6b8750a29
@ -1,3 +1,7 @@
|
|||||||
|
Thu Apr 21 01:53:09 2005 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
|
* lib/net/http.rb: add rdoc.
|
||||||
|
|
||||||
Thu Apr 21 00:07:50 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Thu Apr 21 00:07:50 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/mkmf.rb (create_makefile): support platforms have file separator
|
* lib/mkmf.rb (create_makefile): support platforms have file separator
|
||||||
|
@ -46,31 +46,66 @@ module Net # :nodoc:
|
|||||||
#
|
#
|
||||||
# === Getting Document From WWW Server
|
# === Getting Document From WWW Server
|
||||||
#
|
#
|
||||||
# (formal version)
|
# Example #1: Simple GET+print
|
||||||
#
|
|
||||||
# require 'net/http'
|
|
||||||
# Net::HTTP.start('www.example.com', 80) {|http|
|
|
||||||
# response = http.get('/index.html')
|
|
||||||
# puts response.body
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# (shorter version)
|
|
||||||
#
|
#
|
||||||
# require 'net/http'
|
# require 'net/http'
|
||||||
# Net::HTTP.get_print 'www.example.com', '/index.html'
|
# Net::HTTP.get_print 'www.example.com', '/index.html'
|
||||||
#
|
#
|
||||||
# or
|
# Example #2: Simple GET+print by URL
|
||||||
#
|
#
|
||||||
# require 'net/http'
|
# require 'net/http'
|
||||||
# require 'uri'
|
# require 'uri'
|
||||||
# Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
|
# Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
|
||||||
#
|
#
|
||||||
|
# Example #3: More generic GET+print
|
||||||
|
#
|
||||||
|
# require 'net/http'
|
||||||
|
# require 'uri'
|
||||||
|
#
|
||||||
|
# url = URI.parse('http://www.example.com/index.html')
|
||||||
|
# res = Net::HTTP.start(url.host, url.port) {|http|
|
||||||
|
# http.get('/index.html')
|
||||||
|
# }
|
||||||
|
# puts res.body
|
||||||
|
#
|
||||||
|
# Example #4: More generic GET+print
|
||||||
|
#
|
||||||
|
# require 'net/http'
|
||||||
|
#
|
||||||
|
# url = URI.parse('http://www.example.com/index.html')
|
||||||
|
# req = Net::HTTP::Get.new(url.path)
|
||||||
|
# res = Net::HTTP.start(url.host, url.port) {|http|
|
||||||
|
# http.request(req)
|
||||||
|
# }
|
||||||
|
# puts res.body
|
||||||
|
#
|
||||||
# === Posting Form Data
|
# === Posting Form Data
|
||||||
#
|
#
|
||||||
# require 'net/http'
|
# require 'net/http'
|
||||||
# Net::HTTP.start('some.www.server', 80) {|http|
|
# require 'uri'
|
||||||
# response = http.post('/cgi-bin/search.rb', 'query=ruby')
|
#
|
||||||
# }
|
# #1: Simple POST
|
||||||
|
# res = Net::HTTP.post_form(URI.parse('http://www.example.com/search.cgi'),
|
||||||
|
# {'q'=>'ruby', 'max'=>'50'})
|
||||||
|
# puts res.body
|
||||||
|
#
|
||||||
|
# #2: POST with basic authentication
|
||||||
|
# res = Net::HTTP.post_form(URI.parse('http://jack:pass@www.example.com/todo.cgi'),
|
||||||
|
# {'from'=>'2005-01-01', 'to'=>'2005-03-31'})
|
||||||
|
# puts res.body
|
||||||
|
#
|
||||||
|
# #3: Detailed control
|
||||||
|
# url = URI.parse('http://www.example.com/todo.cgi')
|
||||||
|
# req = Net::HTTP::Post.new(url.path)
|
||||||
|
# req.basic_auth 'jack', 'pass'
|
||||||
|
# req.set_form_data({'from'=>'2005-01-01', 'to'=>'2005-03-31'}, ';')
|
||||||
|
# res = Net::HTTP.new(url.host, url.port).start { http.request(req) }
|
||||||
|
# case res
|
||||||
|
# when Net::HTTPSuccess, Net::HTTPRedirection
|
||||||
|
# # OK
|
||||||
|
# else
|
||||||
|
# res.error!
|
||||||
|
# end
|
||||||
#
|
#
|
||||||
# === Accessing via Proxy
|
# === Accessing via Proxy
|
||||||
#
|
#
|
||||||
@ -1467,7 +1502,7 @@ module Net # :nodoc:
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
class HTTP
|
class HTTP # reopen
|
||||||
class Get < HTTPRequest
|
class Get < HTTPRequest
|
||||||
METHOD = 'GET'
|
METHOD = 'GET'
|
||||||
REQUEST_HAS_BODY = false
|
REQUEST_HAS_BODY = false
|
||||||
|
Loading…
x
Reference in New Issue
Block a user