クラス
- BasicSocket (11)
-
Net
:: HTTP (110)
モジュール
-
Net
:: HTTPHeader (44)
キーワード
- each (11)
-
each
_ capitalized _ name (11) -
each
_ header (11) - get2 (22)
-
get
_ fields (11) - getsockopt (11)
- head2 (22)
-
request
_ get (22) -
request
_ head (22)
検索結果
先頭5件
- Net
:: HTTP # get(path , header = nil , dest = nil) -> Net :: HTTPResponse - Net
:: HTTP # get(path , header = nil , dest = nil) {|body _ segment| . . . . } -> Net :: HTTPResponse - Net
:: HTTPHeader # get _ fields(key) -> [String] - Net
:: HTTP # get2(path , header = nil) -> Net :: HTTPResponse - Net
:: HTTP # get2(path , header = nil) {|response| . . . . } -> Net :: HTTPResponse
-
Net
:: HTTP # get(path , header = nil , dest = nil) -> Net :: HTTPResponse (18239.0) -
サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。
...し、
Net::HTTPResponse のインスタンスとして返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブ......//emlist[例][ruby]{
# net/http version 1.1
response, body = http.get( '/index.html' )
# net/http version 1.2
response = http.get('/index.html')
# compatible in both version
response , = http.get('/index.html')
response.body
# compatible, using block
File.open('save.txt', 'w') {|f|
http.get('/~......foo/', nil) do |str|
f.write str
end
}
//}
@see Net::HTTP#request_get... -
Net
:: HTTP # get(path , header = nil , dest = nil) {|body _ segment| . . . . } -> Net :: HTTPResponse (18239.0) -
サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。
...し、
Net::HTTPResponse のインスタンスとして返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブ......//emlist[例][ruby]{
# net/http version 1.1
response, body = http.get( '/index.html' )
# net/http version 1.2
response = http.get('/index.html')
# compatible in both version
response , = http.get('/index.html')
response.body
# compatible, using block
File.open('save.txt', 'w') {|f|
http.get('/~......foo/', nil) do |str|
f.write str
end
}
//}
@see Net::HTTP#request_get... -
Net
:: HTTPHeader # get _ fields(key) -> [String] (12220.0) -
key ヘッダフィールドの値 (文字列) を配列で返します。
...key ヘッダフィールドの値 (文字列) を配列で返します。
たとえばキー 'content-length' に対しては ['2048'] のような
文字列が得られます。一種類のヘッダフィールドが一つのヘッダの中
に複数存在することがありえます。
key は......ール名を文字列で与えます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
res = Net::HTTP.get_response(uri)
res.get_fields('accept-ranges') # => ["none"]
//}
@see Net::HTTPHeader#[] , Net::HTTPHeader#[]=,
Net::HTTPHeader#add_field... -
Net
:: HTTP # get2(path , header = nil) -> Net :: HTTPResponse (6235.0) -
サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。
...得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブ......TP ヘッダをハッシュで指定します。
//emlist[例][ruby]{
# 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
}
//}
get2 は時代遅れなので使わないでください。
@see Net::HTTP#get, Net::HTTPResponse#read_body... -
Net
:: HTTP # get2(path , header = nil) {|response| . . . . } -> Net :: HTTPResponse (6235.0) -
サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。
...得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブ......TP ヘッダをハッシュで指定します。
//emlist[例][ruby]{
# 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
}
//}
get2 は時代遅れなので使わないでください。
@see Net::HTTP#get, Net::HTTPResponse#read_body... -
Net
:: HTTP # request _ get(path , header = nil) -> Net :: HTTPResponse (6235.0) -
サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。
...得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブ......TP ヘッダをハッシュで指定します。
//emlist[例][ruby]{
# 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
}
//}
get2 は時代遅れなので使わないでください。
@see Net::HTTP#get, Net::HTTPResponse#read_body... -
Net
:: HTTP # request _ get(path , header = nil) {|response| . . . . } -> Net :: HTTPResponse (6235.0) -
サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。
...得します。
Net::HTTPResponse オブジェクトを返します。
header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という
形のハッシュでなければいけません。
ブ......TP ヘッダをハッシュで指定します。
//emlist[例][ruby]{
# 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
}
//}
get2 は時代遅れなので使わないでください。
@see Net::HTTP#get, Net::HTTPResponse#read_body... -
BasicSocket
# getsockopt(level , optname) -> Socket :: Option (6207.0) -
ソケットのオプションを取得します。getsockopt(2) を参照してください。 取得したオプションのデータを Socket::Option で返します。
...プションを取得します。getsockopt(2)
を参照してください。
取得したオプションのデータを Socket::Option で返します。
level, optname には Socket::SOL_SOCKET や Socket::SO_REUSEADDR
といった整数値の他、文字列("SOL_SOCKET", prefixなしの "SOCKET......。
@param level getsockopt(2) の 第二引数のlevel
@param optname getsockopt(2) の 第三引数のoption_name
@see BasicSocket#setsockopt
例:
require 'socket'
serv = Socket.tcp_server_sockets("", 0)[0]
c = serv.local_address.connect
s = serv.accept
opt = c.getsockopt(Socke......t::IPPROTO_TCP, Socket::TCP_NODELAY)
# c.getsockopt("TCP", "NODELAY"), なども可能
p opt #=> #<Socket::Option: INET TCP NODELAY 0>
p opt.bool #=> false (Nagle アルゴリズム有効)
p opt.unpack("i")[0] #=> 0 (Socket::Option#unpack が互換性のために存在する)
# 整数値... -
Net
:: HTTPHeader # each _ capitalized _ name {|name| . . . . } -> () (6119.0) -
保持しているヘッダ名を正規化 ('x-my-header' -> 'X-My-Header') して、ブロックに渡します。
...er' -> 'X-My-Header')
して、ブロックに渡します。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_capitalized_name { |key| puts key }
# => Accept-Encoding
# => Accept
# => User-Agent
//}... -
Net
:: HTTPHeader # each {|name , val| . . . . } -> () (119.0) -
保持しているヘッダ名とその値をそれぞれ ブロックに渡して呼びだします。
...す。
val は ", " で連結した文字列がブロックに渡されます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_header { |key,value| puts "#{key} = #{value}" }
# => accept-encoding = g......zip;q=1.0,deflate;q=0.6,identity;q=0.3
# => accept = */*
# => user-agent = Ruby
//}...