るりまサーチ

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

別のキーワード

  1. tracer set_get_line_procs
  2. webrick/httpservlet do_get
  3. net/http get
  4. http get
  5. http get_response

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

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

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

...et::HTTPResponse として返します。

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

@param uri データの取得対象を URI で指定します。
@param host 接続先のホストを文字列で指定します。
@param path...
...データの存在するパスを文字列で指定します。
@param port 接続するポートを整数で指定します。
@see Net::HTTP#get...

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

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

...et::HTTPResponse として返します。

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

@param uri データの取得対象を URI で指定します。
@param host 接続先のホストを文字列で指定します。
@param path...
...データの存在するパスを文字列で指定します。
@param port 接続するポートを整数で指定します。
@see Net::HTTP#get...

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

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

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

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

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

uri = URI.parse('http:/...
...TP.start(uri.host, uri.port) do |http|
File.open("/path/to/big.file", "w") do |f|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
r
esponse.read_body do |s|
f.write(s)...
...ディを文字列として
返します。また一度ブロックを与えてこのメソッドを呼んだ場合には、
次からは Net::ReadAdapter のインスタンスが返ってきますが、
その場合はそのオブジェクトは使わないでください。

dest は obsolete で...

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

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

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

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

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

uri = URI.parse('http:/...
...TP.start(uri.host, uri.port) do |http|
File.open("/path/to/big.file", "w") do |f|
# Net::HTTP#request_get と Net::HTTPResponse#read_body で少しずつ読み書き。メモリ消費が少ない。
http.request_get(uri.path) do |response|
r
esponse.read_body do |s|
f.write(s)...
...ディを文字列として
返します。また一度ブロックを与えてこのメソッドを呼んだ場合には、
次からは Net::ReadAdapter のインスタンスが返ってきますが、
その場合はそのオブジェクトは使わないでください。

dest は obsolete で...

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

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

...レスポンスオブジェクトを返します。

//emlist[例][ruby]{
r
equire 'net/http'

uri = "http://www.example.com/invalid.html"
r
esponse = Net::HTTP.get_response(URI.parse(uri))
begin
r
esponse.value
r
escue => e
e.response # => #<Net::HTTPNotFound 404 Not Found readbody=true>
end
//}...

絞り込み条件を変える

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

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

...harset" => "iso-2022-jp"}
という形の Hash で返します。

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

//emlist[例][ruby]{
r
equire 'net/http'

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

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

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

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

//emlist[例][ruby]{
r
equire 'net/http'

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

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

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

...

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

//emlist[例][ruby]{
r
equire 'net/http'

uri = URI.parse('http://www.example.com/index.html')
r
es = Net::HTTP.get_response(uri)
r
es.get_fields('accept-ranges') # => ["none"]
//}

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

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

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

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

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

//emlist[例][ruby]{
r
equire 'net/http'

uri = URI.parse('http://www.example.com/index.html')
r
es = Net::HTTP.get_response(uri)
r
es.main_type # => "text"
//}...
<< 1 2 3 > >>