るりまサーチ

最速Rubyリファレンスマニュアル検索!
264件ヒット [1-100件を表示] (0.091秒)
トップページ > クエリ:ruby[x] > 種類:インスタンスメソッド[x] > クエリ:-[x] > クエリ:@[x] > モジュール:Net::HTTPHeader[x]

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

<< 1 2 3 > >>

Net::HTTPHeader#add_field(key, val) -> () (234.0)

key ヘッダフィールドに val を追加します。

...ます。

@
param key ヘッダフィール名を文字列で与えます。
@
param val keyで指定したフィールドに追加する文字列を与えます。
@
see Net::HTTPHeader#[] , Net::HTTPHeader#[]=,
Net::HTTPHeader
#get_fields

//emlist[例][ruby]{
request.add_field 'X-My-Header', 'a...
...p request['X-My-Header'] #=> "a"
p request.get_fields('X-My-Header') #=> ["a"]
request.add_field 'X-My-Header', 'b'
p request['X-My-Header'] #=> "a, b"
p request.get_fields('X-My-Header') #=> ["a", "b"]
request.add_field 'X-My-Header', 'c'
p request['X-My-Header']...
...#=> "a, b, c"
p request.get_fields('X-My-Header') #=> ["a", "b", "c"]
//}...

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

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

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

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

該当するキーが登録されてい
ない時には、引数 default が与えられてい...
...返します。
key は大文字小文字を区別しません。

@
param key ヘッダフィール名を文字列で与えます。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise IndexError 引数defaultもブロックも与えられてない...
...存在する][ruby]{
require 'net/http'

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

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

begin
req.fetch("content-length")
resc...

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

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

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

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

該当するキーが登録されてい
ない時には、引数 default が与えられてい...
...返します。
key は大文字小文字を区別しません。

@
param key ヘッダフィール名を文字列で与えます。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise IndexError 引数defaultもブロックも与えられてない...
...存在する][ruby]{
require 'net/http'

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

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

begin
req.fetch("content-length")
resc...

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

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

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

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

該当するキーが登録されてい
ない時には、引数 default が与えられてい...
...返します。
key は大文字小文字を区別しません。

@
param key ヘッダフィール名を文字列で与えます。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise IndexError 引数defaultもブロックも与えられてない...
...存在する][ruby]{
require 'net/http'

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

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

begin
req.fetch("content-length")
resc...

Net::HTTPHeader#set_form_data(params, sep = &#39;&&#39;) -> () (186.0)

HTMLのフォームのデータ params から ヘッダフィールドとボディを設定します。

...ダフィールド Content-Type: には
'application/x-www-form-urlencoded' が設定されます。

@
param params HTML のフォームデータの Hash を与えます。
@
param sep データのセパレータを文字列で与えます。

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

uri =...
...rm_data = {"q" => ["ruby", "perl"], "lang" => "en"} # => {"q"=>["ruby", "perl"], "lang"=>"en"}
//}

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.set_form_data({"q" => "ruby", "lang" => "en"},...
...';') # => "application/x-www-form-urlencoded"
//}...

絞り込み条件を変える

Net::HTTPHeader#range_length -> Integer|nil (148.0)

Content-Range: ヘッダフィールドの表している長さを整数で返します。

...Content-Range: ヘッダフィールドの表している長さを整数で返します。

ヘッダが設定されていない場合には nil を返します。

@
raise Net::HTTPHeaderSyntaxError Content-Range: ヘッダフィールド
の値が不正である...
...発生します。


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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req['Content-Range'] = "bytes 1-500/1000"
req.range_length # => 500
//}...

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

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

...tent-length' に対しては '2048'
のような文字列が得られます。キーが存在しなければ 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...

Net::HTTPHeader#proxy_basic_auth(account, password) -> [String] (136.0)

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

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

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

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

uri = URI.parse('http://www.example.com/index.html...

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

key ヘッダフィールドの値 (文字列) を配列で返します。

...たとえばキー 'content-length' に対しては ['2048'] のような
文字列が得られます。一種類のヘッダフィールドが一つのヘッダの中
に複数存在することがありえます。
key は大文字小文字を区別しません。

@
param 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...
<< 1 2 3 > >>