2001-07-18 16:45:55 -04:00
=begin
= net/http.rb version 1.2.3
== <20> <> <EFBFBD> Υ 饤<CEA5> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> ˤĤ<CBA4> <C4A4> <EFBFBD>
<EFBFBD> <EFBFBD> <EFBFBD> ѥǡ<EFBFBD> <EFBFBD> <EFBFBD> ž<EFBFBD> <EFBFBD> <EFBFBD> ץ<EFBFBD> <EFBFBD> ȥ<EFBFBD> <EFBFBD> <EFBFBD> HTTP <20> <EFBFBD> <F2B0B7A4> 饤<EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> Ǥ<EFBFBD> <C7A4> <EFBFBD>
<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> [RFC2616] ((<URL:http://www.ietf.org/rfc/rfc2616.txt>)) <20> <>
<EFBFBD> 𤤤Ƥ<EFBFBD> <EFBFBD> ޤ<EFBFBD> <EFBFBD> <EFBFBD>
== <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
=== <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> Ф<EFBFBD> <D0A4> <EFBFBD> <EFBFBD> ɥ<EFBFBD> <C9A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> <EFBFBD> (GET)
require 'net/http'
Net::HTTP.start( 'some.www.server', 80 ) {|http|
response , = http.get('/index.html')
puts response.body
}
<EFBFBD> ޤ<EFBFBD> <EFBFBD> ʲ<EFBFBD> <EFBFBD> <EFBFBD> Ʊ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̣<EFBFBD> <EFBFBD> û<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Τ Ǥ<EFBFBD> <EFBFBD> <EFBFBD>
require 'net/http'
Net::HTTP.get_print 'some.www.server', '/index.html'
=== <20> ե<EFBFBD> <D5A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ξ<EFBFBD> <CEBE> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (POST)
require 'net/http'
Net::HTTP.start( 'some.www.server', 80 ) {|http|
2001-12-09 03:58:30 -05:00
response , = http.post( '/cgi-bin/any.rhtml',
'querytype=subject&target=ruby' )
2001-07-18 16:45:55 -04:00
}
=== <20> ץ<EFBFBD> <D7A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͳ<EFBFBD> Υ <EFBFBD> <CEA5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Net::HTTP <20> Υ <EFBFBD> <CEA5> 饹<EFBFBD> <EFBFBD> å<EFBFBD> Net::HTTP.Proxy <20> ϡ<EFBFBD> <CFA1> <EFBFBD> <EFBFBD> ˥ץ<CBA5> <D7A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͳ<EFBFBD> <CDB3>
<EFBFBD> <EFBFBD> ³<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 褦<EFBFBD> <EFBFBD> ư<EFBFBD> <EFBFBD> <EFBFBD> 롢<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 饹<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֤<EFBFBD> <EFBFBD> ޤ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Υ <EFBFBD> <EFBFBD> 饹<EFBFBD> <EFBFBD>
Net::HTTP <20> <> <EFBFBD> Ѿ<EFBFBD> <D1BE> <EFBFBD> <EFBFBD> Ƥ<EFBFBD> <C6A4> <EFBFBD> <EFBFBD> Τ <EFBFBD> Net::HTTP <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ʊ<EFBFBD> <C6B1> <EFBFBD> 褦<EFBFBD> ˻Ȥ<CBBB> <C8A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
require 'net/http'
$proxy_addr = 'your.proxy.addr'
$proxy_port = 8080
:
Net::HTTP::Proxy($proxy_addr, $proxy_port).start( 'some.www.server' ) {|http|
# always connect to your.proxy.addr:8080
:
}
<EFBFBD> ޤ<EFBFBD> Net::HTTP.Proxy <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> nil <20> <> <EFBFBD> <EFBFBD> Net::HTTP <20> <> <EFBFBD> Ȥ<EFBFBD> <C8A4> ֤<EFBFBD> <D6A4> Τ <EFBFBD>
<EFBFBD> <EFBFBD> <EFBFBD> Υ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɤΤ 褦<EFBFBD> ˽Ƥ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Х ץ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʤ<EFBFBD> <EFBFBD> ξ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˤ<EFBFBD> <EFBFBD> б <EFBFBD> <EFBFBD> Ǥ<EFBFBD> <EFBFBD> ޤ<EFBFBD> <EFBFBD> <EFBFBD>
=== <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 쥯<EFBFBD> Ȥ<EFBFBD> <C8A4> б <EFBFBD> <D0B1> <EFBFBD> <EFBFBD> <EFBFBD>
require 'net/http'
Net::HTTP.version_1_1
host = 'www.ruby-lang.org'
path = '/'
begin
Net::HTTP.start( host, 80 ) {|http|
response , = http.get(path)
print response.body
}
rescue Net::ProtoRetriableError => err
if m = %r<http://([^/]+)>.match( err.response['location'] ) then
host = m[1].strip
path = m.post_match
retry
end
end
<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ǥ<EFBFBD> URL <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ۥ<EFBFBD> <DBA5> <EFBFBD> ̾<EFBFBD> <CCBE> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Τ ˤ<CEA4> <CBA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˡ<EFBFBD> <CBA1> <EFBFBD> ȤäƤ<C3A4> <C6A4> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> URI <20> <> <EFBFBD> 饹<EFBFBD> <E9A5B9> ɸ<EFBFBD> <C9B8> ź<EFBFBD> դˤʤ<CBA4> <CAA4> Ф<EFBFBD> <D0A4> äȴ<C3A4> ñ<EFBFBD> ˤʤ<CBA4> <CAA4> Ϥ<EFBFBD> <CFA4> Ǥ<EFBFBD> <C7A4> <EFBFBD>
=== Basic ǧ<> <C7A7>
require 'net/http'
Net::HTTP.start( 'auth.some.domain' ) {|http|
2001-12-09 03:58:30 -05:00
response , = http.get( '/need-auth.cgi',
'Authentication' => ["#{account}:#{password}"].pack('m').strip )
print response.body
2001-07-18 16:45:55 -04:00
}
<EFBFBD> С <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 1.2 (Ruby 1.7 <20> ʹ ߤ<CAB9> ź<EFBFBD> <C5BA> ) <20> Ǥϼ<C7A4> <CFBC> Τ 褦<CEA4> ˽ޤ<F1A4B1A4> <DEA4> <EFBFBD>
require 'net/http'
req = Net::HTTP::Get.new('/need-auth.cgi')
req.basic_auth 'account', 'password'
Net::HTTP.start( 'auth.some.domain' ) {|http|
2001-12-09 03:58:30 -05:00
response = http.request(req)
print response.body
2001-07-18 16:45:55 -04:00
}
== <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͤؤ<CDA4> <D8A4> ѹ<EFBFBD> <D1B9> Ȱܹ<C8B0> <DCB9> <EFBFBD> <EFBFBD> ֤ˤĤ<CBA4> <C4A4> <EFBFBD>
Ruby 1.6 <20> <> <EFBFBD> <EFBFBD> <EFBFBD> äƤ<C3A4> <C6A4> <EFBFBD> <EFBFBD> Τ <EFBFBD> http.rb 1.1 <20> <> 1.7 <20> ʹ ߤ<CAB9> 1.2 <20> Ǥ<EFBFBD> <C7A4> <EFBFBD> <EFBFBD> <EFBFBD>
<EFBFBD> <EFBFBD> <EFBFBD> δ֤ǤϤ<EFBFBD> <EFBFBD> ʤ<EFBFBD> <EFBFBD> 礭<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͤ<EFBFBD> <EFBFBD> Ѥ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˻<EFBFBD> <EFBFBD> ͤ<EFBFBD> <EFBFBD> ѹ<EFBFBD>
<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Τ Ǥʤ<EFBFBD> <EFBFBD> <EFBFBD> ξ<EFBFBD> <EFBFBD> <EFBFBD> μ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ¸ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ߤ<EFBFBD> <EFBFBD> 뤳<EFBFBD> Ȥˤ<EFBFBD> <EFBFBD> ޤ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
<EFBFBD> <EFBFBD> å<EFBFBD> HTTP.version_1_2<5F> <32> HTTP.version_1_1 <20> <> <EFBFBD> Ƥ֤<C6A4>
<EFBFBD> <EFBFBD> <EFBFBD> Τ <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Net::HTTP <20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȤϤ<C8A4> <CFA4> 줾<EFBFBD> <ECA4BE> <EFBFBD> <EFBFBD>
<EFBFBD> С <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> λ<EFBFBD> <EFBFBD> ͤ<EFBFBD> ư<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 褦<EFBFBD> ˤʤ<EFBFBD> <EFBFBD> ޤ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʲ<EFBFBD> <EFBFBD> ϻ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ǥ<EFBFBD> <EFBFBD> <EFBFBD>
# example
Net::HTTP.start {|http1| ...(http1 has 1.2 features)... }
Net::HTTP.version_1_1
Net::HTTP.start {|http2| ...(http2 has 1.1 features)... }
Net::HTTP.version_1_2
Net::HTTP.start {|http3| ...(http3 has 1.2 features)... }
<EFBFBD> <EFBFBD> <EFBFBD> ε<EFBFBD> ǽ<EFBFBD> ϥ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> åɥ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> դǤϤ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
== class Net::HTTP
=== <20> <> <EFBFBD> 饹<EFBFBD> <EFBFBD> å<EFBFBD>
2001-08-16 23:08:45 -04:00
: new( address, port = 80, proxy_addr = nil, proxy_port = nil )
2001-07-18 16:45:55 -04:00
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> HTTP <20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> address <20> <> HTTP <20> <> <EFBFBD> <EFBFBD> <EFBFBD> С <EFBFBD> <D0A1> <EFBFBD> FQDN <20> ǡ<EFBFBD>
port <20> <> <EFBFBD> <EFBFBD> ³<EFBFBD> <C2B3> <EFBFBD> <EFBFBD> <EFBFBD> ݡ<EFBFBD> <DDA1> <EFBFBD> <EFBFBD> ֹ<EFBFBD> <D6B9> Ǥ<EFBFBD> <C7A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Υ <CEA5> åɤǤϤޤ<CFA4> <DEA4> <EFBFBD> ³<EFBFBD> Ϥ<EFBFBD> <CFA4> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
proxy_addr <20> <> Ϳ <EFBFBD> <CDBF> <EFBFBD> <EFBFBD> <EFBFBD> ȥץ<C8A5> <D7A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 𤷤<EFBFBD> <F0A4B7A4> <EFBFBD> ³<EFBFBD> <C2B3> <EFBFBD> 륪<EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
2001-08-16 23:08:45 -04:00
: start( address, port = 80, proxy_addr = nil, proxy_port = nil )
: start( address, port = 80, proxy_addr = nil, proxy_port = nil ) {|http| .... }
2001-07-18 16:45:55 -04:00
<20> ʲ<EFBFBD> <CAB2> <EFBFBD> Ʊ<EFBFBD> <C6B1> <EFBFBD> Ǥ<EFBFBD> <C7A4> <EFBFBD>
Net::HTTP.new(address, port, proxy_addr, proxy_port).start(&block)
: get( address, path, port = 80 )
<20> ۥ<EFBFBD> <DBA5> <EFBFBD> address <20> <> port <20> ֥ݡ<D6A5> <DDA1> Ȥ<EFBFBD> <C8A4> <EFBFBD> ³<EFBFBD> <C2B3> <EFBFBD> <EFBFBD> path <20> <> ɽ<EFBFBD> <C9BD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֤<EFBFBD> <D6A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
: get_print( address, path, port = 80 )
<20> ۥ<EFBFBD> <DBA5> <EFBFBD> address <20> <> port <20> ֥ݡ<D6A5> <DDA1> Ȥ<EFBFBD> <C8A4> <EFBFBD> ³<EFBFBD> <C2B3> <EFBFBD> <EFBFBD> path <20> <> ɽ<EFBFBD> <C9BD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> $stdout <20> <> << <20> ǽ<EFBFBD> <C7BD> Ϥ<EFBFBD> <CFA4> ޤ<EFBFBD> <DEA4> <EFBFBD>
: Proxy( address, port = 80 )
<20> <> <EFBFBD> ˻<EFBFBD> <CBBB> ꤵ<EFBFBD> 줿<EFBFBD> ץ<EFBFBD> <D7A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ³<EFBFBD> <C2B3> <EFBFBD> 륯<EFBFBD> 饹<EFBFBD> <E9A5B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֤<EFBFBD> <D6A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> <> <EFBFBD> Υ <EFBFBD> <CEA5> 饹<EFBFBD> <E9A5B9> Net::HTTP <20> <> <EFBFBD> Ѿ<EFBFBD> <D1BE> <EFBFBD> <EFBFBD> Ƥ<EFBFBD> <C6A4> <EFBFBD> <EFBFBD> Τ <EFBFBD> Net::HTTP <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
Ʊ<> <C6B1> <EFBFBD> 褦<EFBFBD> ˻Ȥ<CBBB> <C8A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
address <20> <> nil <20> Τ Ȥ<CEA4> <C8A4> <EFBFBD> Net::HTTP <20> <> <EFBFBD> 饹<EFBFBD> Τ ޤ<CEA4> <DEA4> ֤<EFBFBD> <D6A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
# example
proxy_class = Net::HTTP::Proxy( 'proxy.foo.org', 8080 )
2001-12-09 03:58:30 -05:00
:
proxy_class.start( 'www.ruby-lang.org' ) {|http|
# connecting proxy.foo.org:8080
:
}
2001-07-18 16:45:55 -04:00
: proxy_class?
<20> <> <EFBFBD> Ȥ<EFBFBD> (Proxy <20> <EFBFBD> åɤˤ<C9A4> <CBA4> äƺ<C3A4> <C6BA> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 줿) <20> ץ<EFBFBD> <D7A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ѤΥ <D1A4> <CEA5> 饹<EFBFBD> ʤ<EFBFBD> <CAA4> п<EFBFBD> <D0BF> <EFBFBD>
: port
HTTP <20> Υ ǥե<C7A5> <D5A5> <EFBFBD> <EFBFBD> ȥݡ<C8A5> <DDA1> <EFBFBD> (80)<29> <>
=== <20> <EFBFBD> å<EFBFBD>
: start
: start {|http| .... }
TCP <20> <> <EFBFBD> ͥ<EFBFBD> <CDA5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ĥ<EFBFBD> ꡢHTTP <20> <> <EFBFBD> å<EFBFBD> <C3A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ϥ<F2B3ABBB> <CFA4> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> <> <EFBFBD> Ǥ˥<C7A4> <CBA5> å<EFBFBD> <C3A5> <EFBFBD> <EFBFBD> <EFBFBD> <F3A4ACB3> Ϥ<EFBFBD> <CFA4> Ƥ<EFBFBD> <C6A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 㳰 IOError <20> <> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> <> <EFBFBD> ƥ졼<C6A5> <ECA1BC> <EFBFBD> Ȥ<EFBFBD> <C8A4> ƸƤФ줿<D0A4> <ECA4BF> <EFBFBD> ϥ֥<CFA5> <D6A5> å<EFBFBD> <C3A5> δ֤<CEB4> <D6A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> å<EFBFBD> <C3A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ³<EFBFBD> <C2B3> <EFBFBD> <EFBFBD>
<20> ֥<EFBFBD> <D6A5> å<EFBFBD> <C3A5> <EFBFBD> λ<EFBFBD> ȤȤ<C8A4> <C8A4> ˼<EFBFBD> ưŪ<C6B0> ˥<EFBFBD> <CBA5> å<EFBFBD> <C3A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ĥ<EFBFBD> <C4A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
: active?
HTTP <20> <> <EFBFBD> å<EFBFBD> <C3A5> <EFBFBD> <EFBFBD> <EFBFBD> <F3A4ACB3> Ϥ<EFBFBD> <CFA4> <EFBFBD> <EFBFBD> Ƥ<EFBFBD> <C6A4> <EFBFBD> <EFBFBD> 鿿<EFBFBD> <E9BFBF>
: address
<20> <> ³<EFBFBD> <C2B3> <EFBFBD> 륢<EFBFBD> ɥ쥹
: port
<20> <> ³<EFBFBD> <C2B3> <EFBFBD> <EFBFBD> <EFBFBD> ݡ<EFBFBD> <DDA1> <EFBFBD> <EFBFBD> ֹ<EFBFBD>
: open_timeout
: open_timeout=(n)
<20> <> ³<EFBFBD> <C2B3> <EFBFBD> <EFBFBD> <EFBFBD> Ԥĺ<D4A4> <C4BA> <EFBFBD> <EFBFBD> ÿ<EFBFBD> <C3BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ÿ<EFBFBD> <C3BF> <EFBFBD> <EFBFBD> äƤ⥳<C6A4> ͥ<EFBFBD> <CDA5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> ʤ<EFBFBD> <CAA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 㳰 TimeoutError <20> <> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
: read_timeout
: read_timeout=(n)
<20> ɤߤ<C9A4> <DFA4> <EFBFBD> (read(1) <20> <> <EFBFBD> <EFBFBD> ) <20> ǥ֥<C7A5> <D6A5> å<EFBFBD> <C3A5> <EFBFBD> <EFBFBD> Ƥ褤<C6A4> <E8A4A4> <EFBFBD> <EFBFBD> <EFBFBD> ÿ<EFBFBD> <C3BF> <EFBFBD>
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> ÿ<EFBFBD> <C3BF> <EFBFBD> <EFBFBD> äƤ<C3A4> <C6A4> ɤߤ<C9A4> <DFA4> <EFBFBD> <EFBFBD> ʤ<EFBFBD> <CAA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 㳰 TimeoutError <20> <> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
: finish
HTTP <20> <> <EFBFBD> å<EFBFBD> <C3A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> λ<EFBFBD> <CEBB> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> å<EFBFBD> <C3A5> <EFBFBD> <EFBFBD> <EFBFBD> <F3B3ABBB> <EFBFBD> <EFBFBD> ˤ<EFBFBD> <CBA4> Υ <CEA5> åɤ<C3A5>
<20> ƤФ줿<D0A4> <ECA4BF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 㳰 IOError <20> <> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
: proxy?
<20> ץ<EFBFBD> <D7A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 𤷤<EFBFBD> <F0A4B7A4> <EFBFBD> ³<EFBFBD> <C2B3> <EFBFBD> <EFBFBD> <EFBFBD> ʤ鿿<CAA4> <E9BFBF>
: proxy_address
<20> ץ<EFBFBD> <D7A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͳ<EFBFBD> <CDB3> <EFBFBD> <EFBFBD> ³<EFBFBD> <C2B3> <EFBFBD> <EFBFBD> HTTP <20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥʤ<C8A4> <CAA4> ץ<EFBFBD> <D7A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Υ <EFBFBD> <CEA5> ɥ쥹<C9A5> <ECA5B9>
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ǥʤ<C7A4> <CAA4> ʤ<EFBFBD> nil<69> <6C>
: proxy_port
<20> ץ<EFBFBD> <D7A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͳ<EFBFBD> <CDB3> <EFBFBD> <EFBFBD> ³<EFBFBD> <C2B3> <EFBFBD> <EFBFBD> HTTP <20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥʤ<C8A4> <CAA4> ץ<EFBFBD> <D7A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Υ ݡ<CEA5> <DDA1> ȡ<EFBFBD>
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ǥʤ<C7A4> <CAA4> ʤ<EFBFBD> nil<69> <6C>
: get( path, header = nil, dest = '' )
: get( path, header = nil ) {|str| .... }
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> о <EFBFBD> <D0BE> <EFBFBD> path <20> ˤ<EFBFBD> <CBA4> 륨<EFBFBD> <EBA5A8> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> dest <20> <> << <20> <EFBFBD> åɤ<C3A5>
<20> Ȥäƽ <C6BD> <F1A4ADA4> ߤޤ<DFA4> <DEA4> <EFBFBD> <EFBFBD> ޤ<EFBFBD> header <20> <> nil <20> Ǥʤ<C7A4> <CAA4> <EFBFBD> <EFBFBD> Х ꥯ<D0A5> <EAA5AF> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> <EFBFBD>
<20> Ȥ<EFBFBD> <C8A4> ˤ<EFBFBD> <CBA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƥ<EFBFBD> HTTP <20> إå<D8A5> <C3A5> Ȥ<EFBFBD> <C8A4> ƽ <C6BD> <F1A4ADA4> ߤޤ<DFA4> <DEA4> <EFBFBD> header <20> ϥϥå<CFA5> <C3A5> <EFBFBD> <EFBFBD> ǡ<EFBFBD>
<20> ֥إå<D8A5> ̾ => <20> <> <EFBFBD> ơפΤ 褦<CEA4> ʷ<EFBFBD> <CAB7> <EFBFBD> <EFBFBD> Ǥʤ<C7A4> <CAA4> <EFBFBD> <EFBFBD> Ф<EFBFBD> <D0A4> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
<20> ֤<EFBFBD> <D6A4> ͤϡ<CDA4> <CFA1> С <EFBFBD> <D0A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 1.1 <20> Ǥ<EFBFBD> HTTPResponse <20> <> dest <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ǥ<EFBFBD> <C7A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ǥ<EFBFBD> <C7A4> <EFBFBD>
1.2 <20> Ǥ<EFBFBD> HTTPResponse <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ҤȤĤΤ ߤǤ<DFA4> <C7A4> <EFBFBD>
<20> ֥<EFBFBD> <D6A5> å<EFBFBD> <C3A5> ȤȤ<C8A4> <C8A4> ˸ ƤФ줿<D0A4> <ECA4BF> <EFBFBD> ϥ<EFBFBD> <CFA5> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> ܥǥ<DCA5> <C7A5> <EFBFBD> <F2BEAFA4> Ťĥ֥<C4A5> <D6A5> å<EFBFBD> <C3A5> <EFBFBD>
Ϳ <> <CDBF> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
1.1 <20> Ǥ<EFBFBD> 3xx (<28> ƻ<EFBFBD> <C6BB> Բ<EFBFBD> ǽ<EFBFBD> ʥ<EFBFBD> <CAA5> 顼)<29> <> <EFBFBD> Ф<EFBFBD> <D0A4> Ƥ<EFBFBD> <C6A4> 㳰<EFBFBD> <E3B3B0> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ξ<EFBFBD> <CEBE> <EFBFBD>
HTTPResponse <20> <> <EFBFBD> 㳰<EFBFBD> <E3B3B0> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> err.response <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 뤳<EFBFBD> Ȥ<EFBFBD> <C8A4> Ǥ<EFBFBD> <C7A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> <> <EFBFBD> <EFBFBD> 1.2 <20> Ǥ<EFBFBD> <C7A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 㳰<EFBFBD> <E3B3B0> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
# version 1.1 (bundled with Ruby 1.6)
response, body = http.get( '/index.html' )
# version 1.2 (bundled with Ruby 1.7 or later)
response = http.get( '/index.html' )
# compatible in both version
response , = http.get( '/index.html' )
response.body
# using block
File.open( 'save.txt', 'w' ) {|f|
2001-12-09 03:58:30 -05:00
http.get( '/~foo/', nil ) do |str|
f.write str
end
2001-07-18 16:45:55 -04:00
}
# same effect
File.open( 'save.txt', 'w' ) {|f|
2001-12-09 03:58:30 -05:00
http.get '/~foo/', nil, f
2001-07-18 16:45:55 -04:00
}
: head( path, header = nil )
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> о <EFBFBD> <D0BE> <EFBFBD> path <20> ˤ<EFBFBD> <CBA4> 륨<EFBFBD> <EBA5A8> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> Υ إå<D8A5> <C3A5> Τ ߤ<CEA4> <DFA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> ޤ<EFBFBD> header <20> <> nil <20> Ǥʤ<C7A4> <CAA4> <EFBFBD> <EFBFBD> Х ꥯ<D0A5> <EAA5AF> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> ˤ<EFBFBD> <CBA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƥ<EFBFBD>
HTTP <20> إå<D8A5> <C3A5> Ȥ<EFBFBD> <C8A4> ƽ <C6BD> <F1A4ADA4> ߤޤ<DFA4> <DEA4> <EFBFBD> header <20> ϥϥå<CFA5> <C3A5> <EFBFBD> <EFBFBD> ǡ<EFBFBD>
<20> ֥إå<D8A5> ̾ => <20> <> <EFBFBD> ơפΤ 褦<CEA4> ʷ<EFBFBD> <CAB7> <EFBFBD> <EFBFBD> Ǥʤ<C7A4> <CAA4> <EFBFBD> <EFBFBD> Ф<EFBFBD> <D0A4> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
HTTPResponse <20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> ֤<EFBFBD> <D6A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
1.1 <20> Ǥ<EFBFBD> 3xx (<28> ƻ<EFBFBD> <C6BB> Բ<EFBFBD> ǽ<EFBFBD> ʥ<EFBFBD> <CAA5> 顼)<29> <> <EFBFBD> Ф<EFBFBD> <D0A4> Ƥ<EFBFBD> <C6A4> 㳰<EFBFBD> <E3B3B0> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ξ<EFBFBD> <CEBE> <EFBFBD>
HTTPResponse <20> <> <EFBFBD> 㳰<EFBFBD> <E3B3B0> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> err.response <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 뤳<EFBFBD> Ȥ<EFBFBD> <C8A4> Ǥ<EFBFBD> <C7A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> <> <EFBFBD> <EFBFBD> 1.2 <20> Ǥ<EFBFBD> <C7A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 㳰<EFBFBD> <E3B3B0> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
response = nil
Net::HTTP.start( 'some.www.server', 80 ) {|http|
2001-12-09 03:58:30 -05:00
response = http.head( '/index.html' )
2001-07-18 16:45:55 -04:00
}
p response['content-type']
: post( path, data, header = nil, dest = '' )
: post( path, data, header = nil ) {|str| .... }
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> о <EFBFBD> <D0BE> <EFBFBD> path <20> ˤ<EFBFBD> <CBA4> 륨<EFBFBD> <EBA5A8> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> Ф<EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> data <20> <>
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> 쥹<EFBFBD> ݥ<DDA5> << <20> <EFBFBD> åɤ<C3A5> <C9A4> Ȥä<C8A4> dest <20> ˽<EFBFBD> <CBBD> <EFBFBD>
<20> <> <EFBFBD> ޤ<EFBFBD> <DEA4> ޤ<EFBFBD> <DEA4> <EFBFBD> header <20> <> get <20> <EFBFBD> åɤ<C3A5> Ʊ<EFBFBD> <C6B1> <EFBFBD> Ǥ<EFBFBD> <C7A4> <EFBFBD>
HTTPResponse <20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> dest <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֤<EFBFBD> <D6A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> <> <EFBFBD> ƥ졼<C6A5> <ECA1BC> <EFBFBD> Ȥ<EFBFBD> <C8A4> ƸƤӤ<C6A4> <D3A4> <EFBFBD> <EFBFBD> 줿<EFBFBD> Ȥ<EFBFBD> <C8A4> ϥ<EFBFBD> <CFA5> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> ܥǥ<DCA5> <C7A5> <EFBFBD> <F2BEAFA4> Ť<EFBFBD>
<20> ֥<EFBFBD> <D6A5> å<EFBFBD> <C3A5> <EFBFBD> Ϳ <EFBFBD> <CDBF> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
1.1 <20> Ǥ<EFBFBD> 3xx (<28> ƻ<EFBFBD> <C6BB> Բ<EFBFBD> ǽ<EFBFBD> ʥ<EFBFBD> <CAA5> 顼)<29> <> <EFBFBD> Ф<EFBFBD> <D0A4> Ƥ<EFBFBD> <C6A4> 㳰<EFBFBD> <E3B3B0> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ξ<EFBFBD> <CEBE> <EFBFBD>
HTTPResponse <20> <> <EFBFBD> 㳰<EFBFBD> <E3B3B0> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> err.response <20> <> <EFBFBD> <EFBFBD> <EFBFBD> 뤳<EFBFBD> Ȥ<EFBFBD> <C8A4> Ǥ<EFBFBD> <C7A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> <> <EFBFBD> <EFBFBD> 1.2 <20> Ǥ<EFBFBD> <C7A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 㳰<EFBFBD> <E3B3B0> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
# version 1.1
response, body = http.post( '/cgi-bin/search.rb', 'querytype=subject&target=ruby' )
# version 1.2
response = http.post( '/cgi-bin/search.rb', 'querytype=subject&target=ruby' )
# compatible for both version
response , = http.post( '/cgi-bin/search.rb', 'querytype=subject&target=ruby' )
# using block
File.open( 'save.html', 'w' ) {|f|
2001-12-09 03:58:30 -05:00
http.post( '/cgi-bin/search.rb', 'querytype=subject&target=ruby' ) do |str|
f.write str
end
2001-07-18 16:45:55 -04:00
}
# same effect
File.open( 'save.html', 'w' ) {|f|
2001-12-09 03:58:30 -05:00
http.post '/cgi-bin/search.rb', 'querytype=subject&target=ruby', nil, f
2001-07-18 16:45:55 -04:00
}
: get2( path, header = nil )
: get2( path, header = nil ) {|response| .... }
path <20> ˤ<EFBFBD> <CBA4> 륨<EFBFBD> <EBA5A8> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> HTTPResponse
<20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> ֤<EFBFBD> <D6A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> ֥<EFBFBD> <D6A5> å<EFBFBD> <C3A5> ȤȤ<C8A4> <C8A4> ˸ ƤӽФ<D3BD> <D0A4> 줿<EFBFBD> Ȥ<EFBFBD> <C8A4> ϡ<EFBFBD> <CFA1> ֥<EFBFBD> <D6A5> å<EFBFBD> <C3A5> ¹<EFBFBD> <C2B9> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ³<EFBFBD> <C2B3>
<20> ݻ<EFBFBD> <DDBB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> HTTPResponse <20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> ֥<EFBFBD> <D6A5> å<EFBFBD> <C3A5> <EFBFBD> <EFBFBD> Ϥ<EFBFBD> <CFA4> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> <> <EFBFBD> Υ <CEA5> åɤϥ<C9A4> <CFA5> ơ<EFBFBD> <C6A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˴ ؤ餺<D8A4> 㳰<EFBFBD> <E3B3B0> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
# example
response = http.get2( '/index.html' )
p response['content-type']
puts response.body # body is already read
# using block
http.get2( '/index.html' ) {|response|
2001-12-09 03:58:30 -05:00
p response['content-type']
response.read_body do |str| # read body now
print str
end
2001-07-18 16:45:55 -04:00
}
: post2( path, header = nil )
: post2( path, header = nil ) {|response| .... }
path <20> ˤ<EFBFBD> <CBA4> 륨<EFBFBD> <EBA5A8> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> HTTPResponse
<20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> ֤<EFBFBD> <D6A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> ֥<EFBFBD> <D6A5> å<EFBFBD> <C3A5> ȤȤ<C8A4> <C8A4> ˸ ƤӽФ<D3BD> <D0A4> 줿<EFBFBD> Ȥ<EFBFBD> <C8A4> ϡ<EFBFBD> <CFA1> ܥǥ<DCA5> <C7A5> <EFBFBD> <EFBFBD> ɤߤ<C9A4> <DFA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
HTTPResponse <20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> ֥<EFBFBD> <D6A5> å<EFBFBD> <C3A5> <EFBFBD> <EFBFBD> Ϥ<EFBFBD> <CFA4> ޤ<EFBFBD> <DEA4> <EFBFBD>
<20> <> <EFBFBD> Υ <CEA5> åɤϥ<C9A4> <CFA5> ơ<EFBFBD> <C6A1> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ˴ ؤ餺<D8A4> 㳰<EFBFBD> <E3B3B0> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
# example
response = http.post2( '/cgi-bin/nice.rb', 'datadatadata...' )
p response.status
puts response.body # body is already read
# using block
http.post2( '/cgi-bin/nice.rb', 'datadatadata...' ) {|response|
2001-12-09 03:58:30 -05:00
p response.status
p response['content-type']
response.read_body do |str| # read body now
print str
end
2001-07-18 16:45:55 -04:00
}
: request( request [, data] )
: request( request [, data] ) {|response| .... }
<20> ꥯ<EFBFBD> <EAA5AF> <EFBFBD> <EFBFBD> <EFBFBD> ȥ<EFBFBD> <C8A5> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> request <20> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> POST <20> λ<EFBFBD> <CEBB> <EFBFBD> data <20> <>
Ϳ <> <CDBF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD> (POST <20> ʳ<EFBFBD> <CAB3> <EFBFBD> data <20> <> Ϳ <EFBFBD> <CDBF> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ArgumentError <20> <> ȯ<EFBFBD> <C8AF> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> )
<20> ֥<EFBFBD> <D6A5> å<EFBFBD> <C3A5> ȤȤ<C8A4> <C8A4> ˸ ƤӤ<C6A4> <D3A4> <EFBFBD> <EFBFBD> 줿<EFBFBD> Ȥ<EFBFBD> <C8A4> ϥܥǥ<DCA5> <C7A5> <EFBFBD> <EFBFBD> ɤߤ<C9A4> <DFA4> ޤ<EFBFBD> <DEA4> <EFBFBD> HTTPResponse
<20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> ֥<EFBFBD> <D6A5> å<EFBFBD> <C3A5> <EFBFBD> Ϳ <EFBFBD> <CDBF> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
== class Net::HTTP::Get, Head, Post
HTTP <20> ꥯ<EFBFBD> <EAA5AF> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> ݲ<EFBFBD> <DDB2> <EFBFBD> <EFBFBD> 륯<EFBFBD> 饹<EFBFBD> <E9A5B9> key <20> Ϥ<EFBFBD> <CFA4> ٤<EFBFBD> <D9A4> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD>
<EFBFBD> <EFBFBD> <EFBFBD> ̤<EFBFBD> <EFBFBD> ޤ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
=== <20> <> <EFBFBD> 饹<EFBFBD> <EFBFBD> å<EFBFBD>
: new
HTTP <20> ꥯ<EFBFBD> <EAA5AF> <EFBFBD> <EFBFBD> <EFBFBD> ȥ<EFBFBD> <C8A5> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
=== <20> <EFBFBD> å<EFBFBD>
: self[ key ]
key <20> إå<D8A5> <C3A5> ե<EFBFBD> <D5A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɤ<EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
key <20> <> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̤<EFBFBD> <CCA4> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
: self[ key ] = val
key <20> إå<D8A5> <C3A5> ե<EFBFBD> <D5A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɤ<EFBFBD> val <20> åȤ<C3A5> <C8A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
key <20> <> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̤<EFBFBD> <CCA4> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
: each {|name, val| .... }
<20> إå<D8A5> ̾<EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> ͤ<EFBFBD> <CDA4> Ф<EFBFBD> <D0A4> 뤯<EFBFBD> ꤫<EFBFBD> <EAA4AB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> إå<D8A5> ̾<EFBFBD> Ͼ<EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 줵<EFBFBD> <ECA4B5> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
: basic_auth( account, password )
Authrization: <20> إå<D8A5> <C3A5> <EFBFBD> basic auth <20> Ѥ˥<D1A4> <CBA5> åȤ<C3A5> <C8A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
: range
Range: <20> إå<D8A5> <C3A5> μ<EFBFBD> <CEBC> <EFBFBD> <EFBFBD> ϰϤ<CFB0> Range <20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> ֤<EFBFBD> <D6A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
: range = r
: set_range( i, len )
<20> ϰϤ<CFB0> <CFA4> <EFBFBD> <EFBFBD> ꤷ<EFBFBD> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 뤿<EFBFBD> <EBA4BF> <EFBFBD> Υ إå<D8A5> Range: <20> åȤ<C3A5> <C8A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
r <20> <> Range <20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ȡ<EFBFBD> i, len <20> ϻ<EFBFBD> <CFBB> <EFBFBD> <EFBFBD> <EFBFBD> Ĺ<EFBFBD> <C4B9> <EFBFBD> Ǥ<EFBFBD> <C7A4> <EFBFBD>
: content_length
Content-Length: <20> إå<D8A5> <C3A5> <EFBFBD> <EFBFBD> <EFBFBD> (<28> <> <EFBFBD> <EFBFBD> )<29> <>
: content_range
Content-Range: <20> إå<D8A5> <C3A5> <EFBFBD> <EFBFBD> <EFBFBD> (Range)<29> <>
== class Net::HTTPResponse
HTTP <20> 쥹<EFBFBD> ݥΥ <F3A5B9A4> <CEA5> 饹<EFBFBD> Ǥ<EFBFBD> <C7A4> <EFBFBD>
<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> إå<EFBFBD> <EFBFBD> ե<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̾<EFBFBD> Ǥ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 硢<EFBFBD> <EFBFBD> ʸ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̤<EFBFBD> <EFBFBD> ޤ<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
=== <20> <EFBFBD> å<EFBFBD>
: self[ key ]
key <20> إå<D8A5> <C3A5> ե<EFBFBD> <D5A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> (ʸ<> <CAB8> <EFBFBD> <EFBFBD> )<29> Ǥ<EFBFBD> <C7A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> Х <EFBFBD> <D0A5> <EFBFBD> 'content-length'
<20> <> <EFBFBD> Ф<EFBFBD> <D0A4> Ƥ<EFBFBD> '2048' <20> Τ 褦<CEA4> <E8A4A6> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
key <20> <> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̤<EFBFBD> <CCA4> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
: self[ key ] = val
key <20> إå<D8A5> <C3A5> ե<EFBFBD> <D5A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɤ<EFBFBD> value <20> <> <EFBFBD> <EFBFBD> <EFBFBD> ꤷ<EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
key <20> <> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̤<EFBFBD> <CCA4> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
: key?( key )
key <20> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> إå<D8A5> <C3A5> ե<EFBFBD> <D5A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɤ<EFBFBD> <C9A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> п<EFBFBD> <D0BF> <EFBFBD>
key <20> <> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̤<EFBFBD> <CCA4> ޤ<EFBFBD> <DEA4> <EFBFBD> <EFBFBD> <EFBFBD>
: each {|name,value| .... }
<20> <> <EFBFBD> ٤ƤΥ إå<D8A5> <C3A5> ե<EFBFBD> <D5A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̾<EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> ͤΥ ڥ<CEA5> <DAA5> <EFBFBD> <EFBFBD> Ф<EFBFBD> <D0A4> 뤯<EFBFBD> ꤫<EFBFBD> <EAA4AB> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
: canonical_each {|name,value| .... }
<20> إå<D8A5> <C3A5> ե<EFBFBD> <D5A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ɤ<EFBFBD> <C9A4> <EFBFBD> <EFBFBD> <EFBFBD> ̾<EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> ͤΥ ڥ<CEA5> <DAA5> <EFBFBD> <EFBFBD> Ф<EFBFBD> <D0A4> Ʒ <EFBFBD> <C6B7> <EFBFBD> <EFBFBD> ֤<EFBFBD> <D6A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
: code
HTTP <20> Υ ꥶ<CEA5> <EAA5B6> <EFBFBD> ȥ<EFBFBD> <C8A5> <EFBFBD> <EFBFBD> ɤǤ<C9A4> <C7A4> <EFBFBD> <EFBFBD> 㤨<EFBFBD> <E3A4A8> '302' <20> ʤɤǤ<C9A4> <C7A4> <EFBFBD>
: message
HTTP <20> <> <EFBFBD> <EFBFBD> <EFBFBD> Ф<EFBFBD> <D0A4> ꥶ<EFBFBD> <EAA5B6> <EFBFBD> ȥ<EFBFBD> <C8A5> <EFBFBD> <EFBFBD> ɤ<EFBFBD> <C9A4> ղä<D5B2> <C3A4> <EFBFBD> <EFBFBD> ֤<EFBFBD> <D6A4> <EFBFBD> <EFBFBD> å<EFBFBD> <C3A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ǥ<EFBFBD> <C7A4> <EFBFBD>
<20> 㤨<EFBFBD> <E3A4A8> 'Not Found' <20> ʤɤǤ<C9A4> <C7A4> <EFBFBD>
: read_body( dest = '' )
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> ܥǥ<DCA5> <C7A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> dest <20> <> << <20> <EFBFBD> åɤ<C3A5> <C9A4> Ȥäƽ <C6BD> <F1A4ADA4> ߤޤ<DFA4> <DEA4> <EFBFBD>
Ʊ<> <C6B1> HTTPResponse <20> <> <EFBFBD> ֥<EFBFBD> <D6A5> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> Ф<EFBFBD> <D0A4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ʾ <EFBFBD> <CABE> ƤФ줿<D0A4> <ECA4BF> <EFBFBD> 硢
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> ܤ<EFBFBD> <DCA4> <EFBFBD> <EFBFBD> Ϥʤˤ⤻<CBA4> <E2A4BB> <EFBFBD> ˰<EFBFBD> <CBB0> <EFBFBD> <EFBFBD> ܤ<EFBFBD> <DCA4> ֤<EFBFBD> <D6A4> ͤΤ ޤ<CEA4> <DEA4> ֤<EFBFBD> <D6A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
: read_body {|str| .... }
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> ܥǥ<DCA5> <C7A5> <EFBFBD> <F2BEAFA4> Ťļ<C5A4> <C4BC> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƽ 缡<C6BD> ֥<EFBFBD> <D6A5> å<EFBFBD> <C3A5> <EFBFBD> Ϳ <EFBFBD> <CDBF> <EFBFBD> ޤ<EFBFBD> <DEA4> <EFBFBD>
: body
<20> <> <EFBFBD> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> ܥǥ<DCA5> <C7A5> Ǥ<EFBFBD> <C7A4> <EFBFBD> read_body <20> <> <EFBFBD> Ƥ<EFBFBD> <C6A4> Ǥ<EFBFBD> <C7A4> <EFBFBD> <EFBFBD> Ф<EFBFBD> <D0A4> ΰ<EFBFBD> <CEB0> <EFBFBD> dest<73> <74>
<20> Ƥ<EFBFBD> <C6A4> Ǥ<EFBFBD> <C7A4> ʤ<EFBFBD> <CAA4> <EFBFBD> <EFBFBD> Х <EFBFBD> <D0A5> <EFBFBD> <EFBFBD> ƥ<EFBFBD> <C6A5> ƥ<EFBFBD> <C6A5> ܥǥ<DCA5> <C7A5> <EFBFBD> ʸ<EFBFBD> <CAB8> <EFBFBD> <EFBFBD> <EFBFBD> Ȥ<EFBFBD> <C8A4> <EFBFBD> <EFBFBD> ɤߤ<C9A4> <DFA4> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ֤<EFBFBD> <D6A4> ޤ<EFBFBD> <DEA4> <EFBFBD>
=end