55件ヒット
[1-55件を表示]
(0.050秒)
別のキーワード
種類
- 特異メソッド (22)
- インスタンスメソッド (22)
- ライブラリ (11)
ライブラリ
-
net
/ http (44)
クラス
-
Net
:: HTTP (22) -
Net
:: HTTPResponse (22)
検索結果
先頭5件
-
Net
:: HTTP . get _ response(host , path = nil , port = nil) -> Net :: HTTPResponse (18215.0) -
指定した対象に GET リクエストを送り、そのレスポンスを Net::HTTPResponse として返します。
...指定方法は URI で指定するか、
(host, path, port) で指定するかのいずれかです。
@param uri データの取得対象を URI で指定します。
@param host 接続先のホストを文字列で指定します。
@param path データの存在するパスを文字列で指定... -
Net
:: HTTP . get _ response(uri) -> Net :: HTTPResponse (18115.0) -
指定した対象に GET リクエストを送り、そのレスポンスを Net::HTTPResponse として返します。
...指定方法は URI で指定するか、
(host, path, port) で指定するかのいずれかです。
@param uri データの取得対象を URI で指定します。
@param host 接続先のホストを文字列で指定します。
@param path データの存在するパスを文字列で指定... -
Net
:: HTTPResponse # read _ body {|str| . . . . } -> () (24.0) -
ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。
....get_response(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}
//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/path/to/big.file')
Net::HTTP.start(uri.host, uri.port) do |http|
File.open("/path......|
# 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 (24.0) -
ブロックを与えなかった場合にはエンティティボディを 文字列で返します。 ブロックを与えた場合には エンティティボディを少しずつ取得して順次ブロックに 文字列で与えます。
....get_response(URI.parse(uri))
response.read_body[0..10] # => "<!doctype h"
//}
//emlist[例2 ブロックを与えて大きいファイルを取得][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/path/to/big.file')
Net::HTTP.start(uri.host, uri.port) do |http|
File.open("/path......|
# 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
/ http (18.0) -
汎用データ転送プロトコル HTTP を扱うライブラリです。 実装は 2616 に基きます。
...の例よりさらに汎用的な例][ruby]{
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)
//emli......=>'2005-03-31'})
puts res.body
#例3: より細かく制御する
url = URI.parse('http://www.example.com/todo.cgi')
req = Net::HTTP::Post.new(url.path)
req.basic_auth 'jack', 'pass'
req.set_form_data({'from'=>'2005-01-01', 'to'=>'2005-03-31'})
res = Net::HTTP.new(url.host, url.port).start {|http|......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::HTTPSuccess
response
when Net::HTTPRedirection
fetch(response['location'], limit - 1)...