クラス
-
Net
:: HTTP (84) -
Net
:: HTTPGenericRequest (24) -
Net
:: HTTPResponse (24)
キーワード
-
body
_ stream (12) -
body
_ stream= (12) -
ca
_ file (12) -
ca
_ file= (12) -
cert
_ store= (12) - get (24)
- post (24)
-
read
_ body (24)
検索結果
先頭5件
-
Net
:: HTTP # ca _ file=(path) (6121.0) -
信頼する CA 証明書ファイルのパスを文字列で設定します。
...ファイルには複数の証明書を含んでいても構いません。
詳しくは OpenSSL::SSL::SSLContext#ca_file= を見てください。
デフォルトは nil (指定なし)です。
@param path ファイルパス文字列
@see Net::HTTP#ca_file, OpenSSL::SSL::SSLContext#ca_file=... -
Net
:: HTTP # ca _ file -> String | nil (6115.0) -
信頼する CA 証明書ファイルのパスを返します。
...信頼する CA 証明書ファイルのパスを返します。
@see Net::HTTP#ca_file=, OpenSSL::SSL::SSLContext#ca_file... -
Net
:: HTTPResponse # read _ body {|str| . . . . } -> () (20.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:/....../www.example.com/path/to/big.file')
Net::HTTP.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... -
Net
:: HTTPResponse # read _ body(dest=nil) -> String|nil (20.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:/....../www.example.com/path/to/big.file')
Net::HTTP.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... -
Net
:: HTTPGenericRequest # body _ stream -> object (14.0) -
サーバに送るリクエストのエンティティボディを IO オブジェクトなどのストリームで設定します。 f は read(size) メソッドが定義されている必要があります。
...を得るストリームオブジェクトを与えます。
//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|
# 大きなファイルを扱う際にメモリ消費を......少なくできる
post.body_stream = f
post["Content-Length"] = f.size
end
post.body_stream # => #<File:/path/to/test (closed)>
//}... -
Net
:: HTTPGenericRequest # body _ stream=(f) (14.0) -
サーバに送るリクエストのエンティティボディを IO オブジェクトなどのストリームで設定します。 f は read(size) メソッドが定義されている必要があります。
...を得るストリームオブジェクトを与えます。
//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|
# 大きなファイルを扱う際にメモリ消費を......少なくできる
post.body_stream = f
post["Content-Length"] = f.size
end
post.body_stream # => #<File:/path/to/test (closed)>
//}... -
Net
:: HTTP # cert _ store=(store) (8.0) -
接続相手の証明書の検証のために使う、信頼している CA 証明書を 含む証明書ストアを設定します。
...の証明書の検証のために使う、信頼している CA 証明書を
含む証明書ストアを設定します。
通常は Net::HTTP#ca_file= や Net::HTTP#ca_path= で
設定しますが、より詳細な設定をしたい場合にはこちらを用います。
デフォルトは nil (... -
Net
:: HTTP # get(path , header = nil , dest = nil) -> Net :: HTTPResponse (8.0) -
サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。
...す。
//emlist[例][ruby]{
# net/http version 1.1
response, body = http.get( '/index.html' )
# net/http version 1.2
response = http.get('/index.html')
# compatible in both version
response , = http.get('/index.html')
response.body
# compatible, using block
File.open('save.txt', 'w') {|f|
http... -
Net
:: HTTP # get(path , header = nil , dest = nil) {|body _ segment| . . . . } -> Net :: HTTPResponse (8.0) -
サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。
...す。
//emlist[例][ruby]{
# net/http version 1.1
response, body = http.get( '/index.html' )
# net/http version 1.2
response = http.get('/index.html')
# compatible in both version
response , = http.get('/index.html')
response.body
# compatible, using block
File.open('save.txt', 'w') {|f|
http...