るりまサーチ

最速Rubyリファレンスマニュアル検索!
360件ヒット [201-300件を表示] (0.122秒)

別のキーワード

  1. _builtin to_c
  2. etc sc_2_c_dev
  3. etc sc_2_c_bind
  4. tracer display_c_call
  5. tracer display_c_call=

検索結果

<< < 1 2 3 4 > >>

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

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

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

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

該当するキーが登録されてい
ない時には、引数 default が与えられてい...
...p://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")
rescue => e
e # => #<KeyError: key not found: "content-length">...
...le.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
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("con...

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

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

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

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

該当するキーが登録されてい
ない時には、引数 default が与えられてい...
...p://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")
rescue => e
e # => #<KeyError: key not found: "content-length">...
...le.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
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("con...

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

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

...@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.proxy_basic_auth("account", "pa...
...ssword") # => ["Basic YWNjb3VudDpwYXNzd29yZA=="]
//}...

Net::HTTPHeader#set_content_type(type, params = {}) (6102.0)

type と params から Content-Type: ヘッダフィールドの 値を設定します。

...から Content-Type: ヘッダフィールドの
値を設定します。

@param type メディアタイプを文字列で指定します。
@param params パラメータ属性をハッシュで指定します。

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

uri = URI.parse('http://www.example.com/ind...
...ex.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_type # => nil
req.content_type = 'multipart/form-data' # => "multipart/form-data"
req.content_type # => "multipart/form-data"
//}...

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

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

...文字列で与えます。
@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...
...["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#range -> Range|nil (18.0)

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

...は nil を返します。

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

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Ge...
...quest_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::HTTPHeaderSyntaxError
//}...

Net::HTTPHeader#type_params -> Hash (18.0)

Content-Type のパラメータを {"charset" => "iso-2022-jp"} という形の Hash で返します。

...Content-Type のパラメータを {"charset" => "iso-2022-jp"}
という形の Hash で返します。

C
ontent-Type: ヘッダフィールドが存在しない場合には
空のハッシュを返します。

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

uri = URI.parse('http://www.example.com/index.h...
...tml')
res = Net::HTTP.get_response(uri)
res.type_params # => {"charset"=>"UTF-8"}
//}...

Net::HTTPHeader#form_data=(params) (8.0)

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

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

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

@param params HTML のフォームデータの Hash を与えます。
@param sep データの...
...e('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.form_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=(n) (8.0)

範囲を指定してエンティティを取得するためのヘッダ Range: をセットします。

範囲を指定してエンティティを取得するためのヘッダ Range: をセットします。

以下は同じことを表しています。

//emlist[例][ruby]{
req.range = 0..1023
req.range = 0...1024
req.range = 1024
req.set_range(0, 1024)
req.set_range(0..1023)
req.set_range(0...1024)
req.set_range(1024)
//}

特別な場合として、
n に負数を与えた場合にnは最初から(-n)バイトまでの範囲を表します。
r を x..-1 とした場合には、x が...
<< < 1 2 3 4 > >>