るりまサーチ

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

別のキーワード

  1. _builtin to_i
  2. fiddle to_i
  3. matrix elements_to_i
  4. csv to_i
  5. matrix i

ライブラリ

キーワード

検索結果

<< 1 2 > >>

Net::HTTPHeader#main_type -> String|nil (6219.0)

"text/html" における "text" のようなタイプを表す 文字列を返します。

...タイプを表す
文字列を返します。

Content-Type: ヘッダフィールドが存在しない場合には nil を返します。

//emlist[例][ruby]{
require 'net/http'

uri
= URI.parse('http://www.example.com/index.html')
res = Net::HTTP.get_response(uri)
res.main_type # => "text"
//}...

Net::HTTPHeader#basic_auth(account, password) -> [String] (6125.0)

Authorization: ヘッダを BASIC 認証用にセットします。

...Authorization: ヘッダを BASIC 認証用にセットします。

@param account アカウント名を文字列で与えます。
@param password パスワードを文字列で与えます。

//emlist[例][ruby]{
require 'net/http'

uri
= URI.parse('http://www.example.com/index.html')
req = Net:...
...:HTTP::Get.new(uri.request_uri)
req.basic_auth("user", "pass") # => ["Basic dXNlcjpwYXNz"]
//}...

Net::HTTPHeader#each_capitalized_name {|name| .... } -> () (6125.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#proxy_basic_auth(account, password) -> [String] (6125.0)

Proxy 認証のために Proxy-Authorization: ヘッダをセットします。

...thorization: ヘッダをセットします。

@param account アカウント名を文字列で与えます。
@param password パスワードを文字列で与えます。

//emlist[例][ruby]{
require 'net/http'

uri
= URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.re...
...quest_uri)
req.proxy_basic_auth("account", "password") # => ["Basic YWNjb3VudDpwYXNzd29yZA=="]
//}...

Net::HTTPHeader#get_fields(key) -> [String] (6119.0)

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::HTTPHeader#fetch(key) -> String (173.0)

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

...します。

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

該当するキーが登録されてい
ない時には、引数 default が与えられていればその値を、ブロッ
...
...ise IndexError 引数defaultもブロックも与えられてない時、キーの探索に 失敗すると発生します。

//emlist[例 key のみ指定。key が存在する][ruby]{
require 'net/http'

uri
= URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri...
...ri)
req.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 (173.0)

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

...します。

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

該当するキーが登録されてい
ない時には、引数 default が与えられていればその値を、ブロッ
...
...ise IndexError 引数defaultもブロックも与えられてない時、キーの探索に 失敗すると発生します。

//emlist[例 key のみ指定。key が存在する][ruby]{
require 'net/http'

uri
= URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri...
...ri)
req.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 (173.0)

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

...します。

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

該当するキーが登録されてい
ない時には、引数 default が与えられていればその値を、ブロッ
...
...ise IndexError 引数defaultもブロックも与えられてない時、キーの探索に 失敗すると発生します。

//emlist[例 key のみ指定。key が存在する][ruby]{
require 'net/http'

uri
= URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri...
...ri)
req.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#range -> Range|nil (149.0)

Range: ヘッダの示す範囲を Range オブジェクトで返します。

...ない場合は nil を返します。

@raise Net::HTTPHeaderSyntaxError Range:ヘッダの中身が規格通り
でない場合に発生します。

//emlist[例 正常な値][ruby]{
require 'net/http'

uri
= URI.parse('http://www.example.com/index.html')
req = N...
...t.new(uri.request_uri)
req['range'] = "bytes=1-5"
req.range # => [1..5]
//}

//emlist[例 Net::HTTPHeaderSyntaxError][ruby]{
require 'net/http'

uri
= URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req['range'] = "invalid"
req.range # => Net::HTTPHeaderSynta...

Net::HTTPHeader#[](key) -> String|nil (125.0)

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

...ような文字列が得られます。キーが存在しなければ nil を返します。

//emlist[例][ruby]{
require 'net/http'

uri
= URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req['user-agent'] # => Ruby
//}

一種類のヘッダフィールド...
...存在する
場合にはそれを全て ", " で連結した文字列を返します。
key は大文字小文字を区別しません。

@param key ヘッダフィール名を文字列で与えます。

@see Net::HTTPHeader#[]=,
Net::HTTPHeader
#add_field,
Net::HTTPHeader
#get_fields...

絞り込み条件を変える

<< 1 2 > >>