るりまサーチ

最速Rubyリファレンスマニュアル検索!
233件ヒット [1-100件を表示] (0.022秒)
トップページ > クエリ:response[x] > クエリ:get_response[x]

別のキーワード

  1. net/http get_response
  2. http get_response
  3. net/http response
  4. response new
  5. imap add_response_handler

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

Net::HTTP.get_response(host, path = nil, port = nil) -> Net::HTTPResponse (24304.0)

指定した対象に GET リクエストを送り、そのレスポンスを Net::HTTPResponse として返します。

...指定した対象に GET リクエストを送り、そのレスポンスを
Net::HTTPResponse として返します。

対象の指定方法は URI で指定するか、
(host, path, port) で指定するかのいずれかです。

@param uri データの取得対象を URI で指定します。...

Net::HTTP.get_response(uri) -> Net::HTTPResponse (24304.0)

指定した対象に GET リクエストを送り、そのレスポンスを Net::HTTPResponse として返します。

...指定した対象に GET リクエストを送り、そのレスポンスを
Net::HTTPResponse として返します。

対象の指定方法は URI で指定するか、
(host, path, port) で指定するかのいずれかです。

@param uri データの取得対象を URI で指定します。...

Net::HTTPExceptions#response -> Net::HTTPResponse (18231.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 Found readbody=true>
end
//}...

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

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

...mple.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"
response
= Net::HTTP.get_response(URI.parse(uri))
begin
response
.value
rescue => e...

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

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

...1 ブロックを与えずに一度に結果取得][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]{
re...
...e.open("/path/to/big.file", "w") do |f|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
response
.read_body do |s|
f.write(s)
end
end
end
end
//}

一度ブ...

絞り込み条件を変える

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

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

...1 ブロックを与えずに一度に結果取得][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]{
re...
...e.open("/path/to/big.file", "w") do |f|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
response
.read_body do |s|
f.write(s)
end
end
end
end
//}

一度ブ...

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

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

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

レスポンスにボディがない場合には nil を返します。

Net::HTTPResponse#read_body をブロック付きで呼んだ場合には
このメソッドはNet::ReadAdapter のインスタンスを返しますが、
これは使わないで...
...ください。

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 (3024.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 (3024.0)

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

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

レスポンスにボディがない場合には nil を返します。

Net::HTTPResponse#read_body をブロック付きで呼んだ場合には
このメソッドはNet::ReadAdapter のインスタンスを返しますが、
これは使わないで...
...ください。

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"
//}...
<< 1 2 3 > >>