るりまサーチ

最速Rubyリファレンスマニュアル検索!
33件ヒット [1-33件を表示] (0.042秒)
トップページ > クエリ:nil[x] > クエリ:end[x] > モジュール:Net::HTTPHeader[x]

別のキーワード

  1. _builtin nil?
  2. nilclass nil?
  3. object nil?
  4. _builtin nil
  5. object nil

ライブラリ

検索結果

Net::HTTPHeader#fetch(key) -> String (13.0)

key ヘッダフィールドを返します。

...します。

たとえばキー 'content-length' に対しては '2048'
のような文字列が得られます。キーが存在しなければ nil を返します。

該当するキーが登録されてい
ない時には、引数 default が与えられていればその値を、ブロッ
...
...が存在しない][ruby]{
require 'net/http'

begin
req.fetch("content-length")
rescue => e
e # => #<KeyError: key not found: "content-length">
end

//}

//emlist[例 key , default を指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new...
...q.fetch("content-length", "default") # => "default"
//}

//emlist[例 key とブロックを指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length") { |e| 99 } # => 99
//}

@see Net::HTTPHeader#[]...

Net::HTTPHeader#fetch(key) {|hash| .... } -> String (13.0)

key ヘッダフィールドを返します。

...します。

たとえばキー 'content-length' に対しては '2048'
のような文字列が得られます。キーが存在しなければ nil を返します。

該当するキーが登録されてい
ない時には、引数 default が与えられていればその値を、ブロッ
...
...が存在しない][ruby]{
require 'net/http'

begin
req.fetch("content-length")
rescue => e
e # => #<KeyError: key not found: "content-length">
end

//}

//emlist[例 key , default を指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new...
...q.fetch("content-length", "default") # => "default"
//}

//emlist[例 key とブロックを指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length") { |e| 99 } # => 99
//}

@see Net::HTTPHeader#[]...

Net::HTTPHeader#fetch(key, default) -> String (13.0)

key ヘッダフィールドを返します。

...します。

たとえばキー 'content-length' に対しては '2048'
のような文字列が得られます。キーが存在しなければ nil を返します。

該当するキーが登録されてい
ない時には、引数 default が与えられていればその値を、ブロッ
...
...が存在しない][ruby]{
require 'net/http'

begin
req.fetch("content-length")
rescue => e
e # => #<KeyError: key not found: "content-length">
end

//}

//emlist[例 key , default を指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new...
...q.fetch("content-length", "default") # => "default"
//}

//emlist[例 key とブロックを指定][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.fetch("content-length") { |e| 99 } # => 99
//}

@see Net::HTTPHeader#[]...