1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/doc/net/http.rd.ja

503 lines
15 KiB
Text
Raw Normal View History

=begin
= net/http.rb
== <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 version 1.1 <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'
# or
Net::HTTP.get_print URI.parse('http://www.example.com/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|
response = http.post('/cgi-bin/any.rhtml',
'querytype=subject&target=ruby')
}
=== <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'
def read_uri( uri_str )
response = Net::HTTP.get_response(URI.parse(uri_str))
case response
when Net::HTTPSuccess then response
when Net::HTTPRedirection then read_uri(response['location'])
else
response.error!
end
end
print read_uri('http://www.ruby-lang.org')
HTTPSuccess <20><> HTTPRedirection <20><> HTTPResponse <20><><EFBFBD><EFBFBD>β<EFBFBD><CEB2>̥<EFBFBD><CCA5><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>
HTTPResponse <20><><EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȤϤ<C8A4><CFA4><EFBFBD><ECA4BE> HTTP <20><EFBFBD>ݥ󥹤Υ<F3A5B9A4><CEA5>ơ<EFBFBD><C6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˤ<EFBFBD><CBA4>ä<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 <20><EFBFBD>ݥ󥹥<DDA5><F3A5B9A5><EFBFBD><E9A5B9><EFBFBD>פ<EFBFBD><D7A4><EFBFBD><EFBFBD>򸫤Ƥ<F2B8ABA4><C6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
=== Basic ǧ<><C7A7>
require 'net/http'
req = Net::HTTP::Get.new('/need-auth.cgi')
req.basic_auth 'account', 'password'
Net::HTTP.start( 'auth.some.domain' ) {|http|
response = http.request(req)
print response.body
}
=== HTTP <20><EFBFBD>ݥ󥹥<DDA5><F3A5B9A5><EFBFBD><E9A5B9>
<EFBFBD>ʲ<EFBFBD><EFBFBD><EFBFBD> HTTP 1.1 <20>Υ<CEA5><EAA5B6><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>ɤȤ<C9A4><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݥ󥹥<DDA5><F3A5B9A5><EFBFBD><E9A5B9>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϥ<EFBFBD><EFBFBD>٤<EFBFBD> Net <20><EFBFBD><EFBFBD><E5A1BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƥ<EFBFBD><C6A4>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǥ<EFBFBD><EFBFBD>Ȥ<EFBFBD><EFBFBD>Ѿ<EFBFBD><EFBFBD>ط<EFBFBD><EFBFBD><EFBFBD>ɽ<EFBFBD><EFBFBD>Ƥ<EFBFBD><EFBFBD>ޤ<EFBFBD><EFBFBD><EFBFBD>
xxx HTTPResponse
1xx HTTPInformation
100 HTTPContinue
101 HTTPSwitchProtocol
2xx HTTPSuccess
200 HTTPOK
201 HTTPCreated
202 HTTPAccepted
203 HTTPNonAuthoritativeInformation
204 HTTPNoContent
205 HTTPResetContent
206 HTTPPartialContent
3xx HTTPRedirection
300 HTTPMultipleChoice
301 HTTPMovedPermanently
302 HTTPFound
303 HTTPSeeOther
304 HTTPNotModified
305 HTTPUseProxy
307 HTTPTemporaryRedirect
4xx HTTPClientError
400 HTTPBadRequest
401 HTTPUnauthorized
402 HTTPPaymentRequired
403 HTTPForbidden
404 HTTPNotFound
405 HTTPMethodNotAllowed
406 HTTPNotAcceptable
407 HTTPProxyAuthenticationRequired
408 HTTPRequestTimeOut
409 HTTPConflict
410 HTTPGone
411 HTTPLengthRequired
412 HTTPPreconditionFailed
413 HTTPRequestEntityTooLarge
414 HTTPRequestURITooLong
415 HTTPUnsupportedMediaType
416 HTTPRequestedRangeNotSatisfiable
417 HTTPExpectationFailed
5xx HTTPServerError
500 HTTPInternalServerError
501 HTTPNotImplemented
502 HTTPBadGateway
503 HTTPServiceUnavailable
504 HTTPGatewayTimeOut
505 HTTPVersionNotSupported
xxx HTTPUnknownResponse
== <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͤؤ<CDA4><D8A4>ѹ<EFBFBD><D1B9>Ȱܹ<C8B0><DCB9><EFBFBD><EFBFBD>֤ˤĤ<CBA4><C4A4><EFBFBD>
Ruby 1.6 <20>ˤ<EFBFBD> http.rb 1.1<EFBFBD><EFBFBD>Ruby 1.7 <20>ˤ<EFBFBD> http.rb 1.2 <20><>ź<EFBFBD><C5BA>
<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><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>
: new( address, port = 80, proxy_addr = nil, proxy_port = nil )
<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>
: start( address, port = 80, proxy_addr = nil, proxy_port = nil )
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Net::HTTP <20><><EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <20><><EFBFBD>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<20><><EFBFBD>Ϥ<EFBFBD><CFA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>ޤ<EFBFBD><DEA4><EFBFBD>
: start( address, port = 80, proxy_addr = nil, proxy_port = nil ) {|http| .... }
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Net::HTTP <20><><EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֥<EFBFBD><D6A5>å<EFBFBD><C3A5><EFBFBD><EFBFBD>Ϥ<EFBFBD><CFA4>ޤ<EFBFBD><DEA4><EFBFBD>
<20>֥<EFBFBD><D6A5>å<EFBFBD><C3A5>¹<EFBFBD><C2B9><EFBFBD><EFBFBD>Τ<EFBFBD> HTTP <20><><EFBFBD>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>
<20>֥<EFBFBD><D6A5>å<EFBFBD><C3A5><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>ͤ򤽤Τޤ<CEA4><DEA4>֤<EFBFBD><D6A4>ޤ<EFBFBD><DEA4><EFBFBD>
: get_print( uri )
: get_print( address, path, port = 80 )
uri <20>ޤ<EFBFBD><DEA4><EFBFBD> address path port <20>ǻ<EFBFBD><C7BB><EFBFBD>줿<EFBFBD><ECA4BF><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>ƥ<EFBFBD><C6A5><EFBFBD>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> stdout <20>˽<EFBFBD><CBBD>Ϥ<EFBFBD><CFA4>ޤ<EFBFBD><DEA4><EFBFBD>
Net::HTTP.get_print URI.parse('http://www.example.com')
: get( uri )
: get( address, path, port = 80 )
uri <20>ޤ<EFBFBD><DEA4><EFBFBD> address path port <20>ǻ<EFBFBD><C7BB><EFBFBD>줿<EFBFBD><ECA4BF><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>ƥ<EFBFBD><C6A5><EFBFBD>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>ޤ<EFBFBD><DEA4><EFBFBD>
print Net::HTTP.get(URI.parse('http://www.example.com'))
: get_response( uri )
: get_response( address, path, port = 80 )
uri <20>ޤ<EFBFBD><DEA4><EFBFBD> address path port <20>ǻ<EFBFBD><C7BB><EFBFBD>줿<EFBFBD><ECA4BF><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>ƥ<EFBFBD><C6A5><EFBFBD>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Net::HTTPResponse <20><><EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4>֤<EFBFBD><D6A4>ޤ<EFBFBD><DEA4><EFBFBD>
res = Net::HTTP.get_response(URI.parse('http://www.example.com'))
print res.body
: 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 )
:
proxy_class.start( 'www.ruby-lang.org' ) {|http|
# connecting proxy.foo.org:8080
:
}
: 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><C4A5> 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>
<20>ݻ<EFBFBD><DDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֥<EFBFBD><D6A5>å<EFBFBD><C3A5><EFBFBD>λ<EFBFBD>ȤȤ<C8A4><C8A4>˼<EFBFBD>ưŪ<C6B0>˥<EFBFBD><CBA5>å<EFBFBD><C3A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>
: started?
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 )
: 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><EFB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ȯ<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|
http.get( '/~foo/', nil ) do |str|
f.write str
end
}
: 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|
response = http.head( '/index.html' )
}
p response['content-type']
: post( path, data, header = nil )
: 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><EFBFB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FBD><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', 'query=subject&target=ruby' )
# version 1.2
response = http.post( '/cgi-bin/search.rb', 'query=subject&target=ruby' )
# compatible in both version
response , = http.post( '/cgi-bin/search.rb', 'query=subject&target=ruby' )
# using block
File.open( 'save.html', 'w' ) {|f|
http.post( '/cgi-bin/search.rb',
'query=subject&target=ruby' ) do |str|
f.write str
end
}
: request_get( path, header = nil )
: request_get( 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>åɤ<C3A5> HTTP <20>ץ<EFBFBD><D7A5>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>˴<EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E3B3B0>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD><EFBFBD><EFBFBD>
# example
response = http.request_get( '/index.html' )
p response['content-type']
puts response.body # body is already read
# using block
http.request_get( '/index.html' ) {|response|
p response['content-type']
response.read_body do |str| # read body now
print str
end
}
: request_post( path, data, header = nil )
: request_post( path, data, 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>åɤ<C3A5> HTTP <20>ץ<EFBFBD><D7A5>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD>˴<EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><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|
p response.status
p response['content-type']
response.read_body do |str| # read body now
print str
end
}
: request( request [, data] )
: request( request [, data] ) {|response| .... }
HTTPResquest <20><><EFBFBD>֥<EFBFBD><D6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> request <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>POST/PUT <20>λ<EFBFBD><CEBB><EFBFBD> data <20><>
Ϳ<><CDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD> (POST/PUT <20>ʳ<EFBFBD><CAB3><EFBFBD> data <20><>Ϳ<EFBFBD><CDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ArgumentError <20><>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD>)<29><>
<20>֥<EFBFBD><D6A5>å<EFBFBD><C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FBD>ޤ<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>ɤ<EFB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