るりまサーチ (Ruby 2.3.0)

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

別のキーワード

  1. time parse
  2. csv parse
  3. ripper parse
  4. parser parse
  5. psych parse_stream

検索結果

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

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

...key が存在する][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...
...efault を指定][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", "default") # => "default"
//}

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

uri = URI.parse('http://www.exa...

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

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

...key が存在する][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...
...efault を指定][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", "default") # => "default"
//}

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

uri = URI.parse('http://www.exa...

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

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

...key が存在する][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...
...efault を指定][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", "default") # => "default"
//}

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

uri = URI.parse('http://www.exa...

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

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

...][ruby]{
require 'net/http'

uri = URI.parse('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...

Net::HTTPHeader#range -> Range|nil (46.0)

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

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

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

絞り込み条件を変える

Net::HTTPHeader#set_form_data(params, sep = '&') -> () (46.0)

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

...][ruby]{
require 'net/http'

uri = URI.parse('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...

Net::HTTPResponse#read_body {|str| .... } -> () (46.0)

ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。

...果取得][ruby]{
require 'net/http'

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}

//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'

uri = URI.parse('http:/...

Net::HTTPResponse#read_body(dest=nil) -> String|nil (46.0)

ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。

...果取得][ruby]{
require 'net/http'

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}

//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'

uri = URI.parse('http:/...

Net::HTTPResponse#value -> nil (46.0)

レスポンスが 2xx(成功)でなかった場合に、対応する 例外を発生させます。

...スが 2xx(成功)でなかった場合に、対応する
例外を発生させます。

@raise HTTPError レスポンスが 1xx であるか、 net/http が知らない
種類のレスポンスである場合に発生します。
@raise HTTPRetriableError レスポンスが 3xx...
...レスポンスが 2xx(成功)][ruby]{
require 'net/http'

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.value # => nil
//}

//emlist[例 レスポンスが 2xx以外][ruby]{
require 'net/http'

uri = "http://www.example.com/invalid.html"
respo...

Net::HTTPExceptions#response -> Net::HTTPResponse (28.0)

例外の原因となったレスポンスオブジェクトを返します。

...例外の原因となったレスポンスオブジェクトを返します。

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

uri = "http://www.example.com/invalid.html"
response = Net::HTTP.get_response(URI.parse(uri))
begin
response.value
rescue => e
e.response # => #<Net::HTTPNotFound 404 Not Fou...

絞り込み条件を変える

Net::HTTPGenericRequest#body -> String (28.0)

サーバに送るリクエストのエンティティボディを返します。

...サーバに送るリクエストのエンティティボディを返します。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Post.new(uri.request_uri)
req.body = "Test Post Data"
req.body # => "Test Post Data"
//}

@see Net::HTTPGe...

Net::HTTPGenericRequest#body=(body) (28.0)

サーバに送るリクエストのエンティティボディを文字列で設定します。

...ティボディを文字列で設定します。

@param body 設定するボディを文字列で与えます。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Post.new(uri.request_uri)
req.body = "Test Post Data" # => "Test Post Data...

Net::HTTPGenericRequest#body_stream -> object (28.0)

サーバに送るリクエストのエンティティボディを IO オブジェクトなどのストリームで設定します。 f は read(size) メソッドが定義されている必要があります。

...

@param f エンティティボディのデータを得るストリームオブジェクトを与えます。

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

uri = URI.parse('http://www.example.com/index.html')
post = Net::HTTP::Post.new(uri.request_uri)
File.open("/path/to/test", 'rb') do |f|
# 大...

Net::HTTPGenericRequest#body_stream=(f) (28.0)

サーバに送るリクエストのエンティティボディを IO オブジェクトなどのストリームで設定します。 f は read(size) メソッドが定義されている必要があります。

...

@param f エンティティボディのデータを得るストリームオブジェクトを与えます。

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

uri = URI.parse('http://www.example.com/index.html')
post = Net::HTTP::Post.new(uri.request_uri)
File.open("/path/to/test", 'rb') do |f|
# 大...

Net::HTTPGenericRequest#method -> String (28.0)

リクエストの HTTP メソッドを文字列で返します。

...リクエストの HTTP メソッドを文字列で返します。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Post.new(uri.request_uri)
req.method # => "POST"
req = Net::HTTP::Get.new(uri.request_uri)
req.method # => "GET"
//}...

絞り込み条件を変える

Net::HTTPGenericRequest#path -> String (28.0)

リクエストする path を文字列で返します。

...リクエストする path を文字列で返します。

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

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

Net::HTTPGenericRequest#request_body_permitted? -> bool (28.0)

リクエストにエンティティボディを一緒に送ることが許されている HTTP メソッド (POST など)の場合真を返します。

...ディを一緒に送ることが許されている
HTTP メソッド (POST など)の場合真を返します。

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

uri = URI.parse('http://www.example.com/index.html')
post = Net::HTTP::Post.new(uri.request_uri)
post.request_body_permitted? # => true

head...

Net::HTTPGenericRequest#response_body_permitted? -> bool (28.0)

サーバからのレスポンスにエンティティボディを含むことが許されている HTTP メソッド (GET, POST など)の場合真を返します。

...ボディを含むことが許されている
HTTP メソッド (GET, POST など)の場合真を返します。

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

uri = URI.parse('http://www.example.com/index.html')
post = Net::HTTP::Post.new(uri.request_uri)
post.response_body_permitted? # => true

head...

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

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

...しては '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
//}

一種類のヘ...

Net::HTTPHeader#[]=(key, val) (28.0)

key ヘッダフィールドに文字列 val をセットします。

...字列で与えます。
@param val keyで指定したフィールドにセットする文字列を与えます。

//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
req['user-agent'] =...

絞り込み条件を変える

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

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

...unt アカウント名を文字列で与えます。
@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 dXNl...

Net::HTTPHeader#chunked? -> bool (28.0)

Transfer-Encoding: ヘッダフィールドが "chunked" である 場合に真を返します。

...ヘッダフィールドが存在しなかったり、
"chunked" 以外である場合には偽を返します。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.chunked? # => false
req["Transfer-Encoding"]...

Net::HTTPHeader#content_length -> Integer|nil (28.0)

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

...rSyntaxError フィールドの値が不正である場合に
発生します。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_length # => nil
req.content_length...

Net::HTTPHeader#content_length=(len) (28.0)

Content-Length: ヘッダフィールドに値を設定します。

...tent-Length: ヘッダフィールドを
削除します。

@param len 設定する値を整数で与えます。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_length # => nil
req.content_len...

Net::HTTPHeader#content_range -> Range|nil (28.0)

Content-Range: ヘッダフィールドの値を Range で返します。 Range の表わす長さは Net::HTTPHeader#range_length で得られます。

...Header#range_length で得られます。

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

//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 # => nil
req['Content-Ran...

絞り込み条件を変える

Net::HTTPHeader#content_type -> String|nil (28.0)

"text/html" のような Content-Type を表す 文字列を返します。

...列を返します。

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

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

uri = URI.parse('http://www.example.com/comments.cgi?post=comment')
req = Net::HTTP::Post.new(uri.request_uri)
req.content_type # => nil
req.c...

Net::HTTPHeader#content_type=(type) (28.0)

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

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

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_type # => n...

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

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

...ます。
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.content_length = 10
req.content_length # =>...

Net::HTTPHeader#each {|name, val| .... } -> () (28.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} = #{va...

Net::HTTPHeader#each_capitalized_name {|name| .... } -> () (28.0)

保持しているヘッダ名を正規化 ('x-my-header' -> 'X-My-Header') して、ブロックに渡します。

...持しているヘッダ名を正規化
('x-my-header' -> '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 }

# =...

絞り込み条件を変える

Net::HTTPHeader#each_header {|name, val| .... } -> () (28.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} = #{va...

Net::HTTPHeader#each_key {|name| ... } -> () (28.0)

保持しているヘッダ名をブロックに渡して呼びだします。

...るヘッダ名をブロックに渡して呼びだします。

ヘッダ名は小文字で統一されます。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_name { |name| puts name }

# => accept-e...

Net::HTTPHeader#each_name {|name| ... } -> () (28.0)

保持しているヘッダ名をブロックに渡して呼びだします。

...るヘッダ名をブロックに渡して呼びだします。

ヘッダ名は小文字で統一されます。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_name { |name| puts name }

# => accept-e...

Net::HTTPHeader#each_value {|value| .... } -> () (28.0)

保持しているヘッダの値をブロックに渡し、呼びだします。

...値をブロックに渡し、呼びだします。

渡される文字列は ", " で連結したものです。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_value { |value| puts value }

# => gzip;...

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

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

...y は大文字小文字を区別しません。

@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#key?(key) -> bool (28.0)

key というヘッダフィールドがあれば真を返します。 key は大文字小文字を区別しません。

...字小文字を区別しません。

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

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

uri = URI.parse('http://www.example.com/index.html')
res = Net::HTTP.get_response(uri)
res.key?('content-type') # => true
res.key?('nonexist-...

Net::HTTPHeader#main_type -> String|nil (28.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#method -> String (28.0)

リクエストの HTTP メソッドを文字列で返します。

...リクエストの HTTP メソッドを文字列で返します。

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.method # => "GET"
//}...

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

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

...unt アカウント名を文字列で与えます。
@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", "password") # =>...

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

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.rang...

絞り込み条件を変える

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

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

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

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

uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.content_type # => n...

Net::HTTPHeader#sub_type -> String|nil (28.0)

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

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

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

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

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

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

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

...返します。

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

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

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

Net::HTTPResponse#body -> String | () | nil (28.0)

エンティティボディを返します。

...dapter のインスタンスを返しますが、
これは使わないでください。

entity は obsolete です。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.body[0..10] # => "<!doctype h"
//}...

Net::HTTPResponse#code -> String (28.0)

HTTP のリザルトコードです。例えば '302' などです。

...スオブジェクトがどのクラスのインスタンスかを
見ることでもレスポンスの種類を判別できます。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.code # => "200"
//}...

絞り込み条件を変える

Net::HTTPResponse#entity -> String | () | nil (28.0)

エンティティボディを返します。

...dapter のインスタンスを返しますが、
これは使わないでください。

entity は obsolete です。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.body[0..10] # => "<!doctype h"
//}...

Net::HTTPResponse#http_version -> String (28.0)

サーバがサポートしている HTTP のバージョンを文字列で返します。

...サーバがサポートしている HTTP のバージョンを文字列で返します。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.http_version # => "1.1"
//}...

Net::HTTPResponse#message -> String (28.0)

HTTP サーバがリザルトコードに付加して返すメッセージです。 例えば 'Not Found' などです。

...して返すメッセージです。
例えば 'Not Found' などです。

msg は obsolete です。使わないでください。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.message # => "OK"
//}...

Net::HTTPResponse#msg -> String (28.0)

HTTP サーバがリザルトコードに付加して返すメッセージです。 例えば 'Not Found' などです。

...して返すメッセージです。
例えば 'Not Found' などです。

msg は obsolete です。使わないでください。

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

uri = "http://www.example.com/index.html"
response = Net::HTTP.get_response(URI.parse(uri))
response.message # => "OK"
//}...