るりまサーチ

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

別のキーワード

  1. net/http get
  2. net/http start
  3. http get
  4. http start
  5. net/http set_range

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 > >>

net/http (38054.0)

汎用データ転送プロトコル HTTP を扱うライブラリです。 実装は 2616 に基きます。

...y]{
require 'net/http'
print Net::HTTP.get('www.example.com', '/index.html')
//}

//emlist[例2: URI を使う][ruby]{
require 'net/http'
require 'uri'
print Net::HTTP.get(URI.parse('http://www.example.com/index.html'))
//}

//emlist[例3: より汎用的な例][ruby]{
require 'net/http'
require 'ur...
...{
require 'net/http'

url = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
puts res.body
//}

==== フォームの情報を送信する (POST)

//emlist[例][ruby]{
require 'net/http'
require '...
...ラーにします。

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

def fetch(uri_str, limit = 10)
# You should choose better exception.
raise ArgumentError, 'HTTP redirect too deep' if limit == 0

response = Net::HTTP.get_response(URI.parse(uri_str))
case response
when Net::HTT...

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

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

指定した対象に GET リクエストを送り、そのレスポンスを
Net::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 (26102.0)

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

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

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

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

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

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

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

@raise HTTPError レスポンスが 1xx であるか、 net/http が知らない
種類のレスポンスである場合に発生します。
@raise HTTPRetriableError レスポンスが 3xx...
...{
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"
response = Net::HTTP.get_response(URI.parse...

Net::HTTPResponse#read_body {|str| .... } -> () (8018.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 (8018.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::HTTPExceptions#response -> Net::HTTPResponse (8012.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 read...

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

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#key?(key) -> bool (8012.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-header') # => false
//}...
<< 1 2 3 > >>