るりまサーチ

最速Rubyリファレンスマニュアル検索!
132件ヒット [1-100件を表示] (0.018秒)

別のキーワード

  1. _builtin file?
  2. _builtin file
  3. file path
  4. file open
  5. file size

キーワード

検索結果

<< 1 2 > >>

Net::HTTP#ca_file=(path) (6122.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 (6116.0)

信頼する CA 証明書ファイルのパスを返します。

...信頼する CA 証明書ファイルのパスを返します。

@see Net::HTTP#ca_file=, OpenSSL::SSL::SSLContext#ca_file...

Net::HTTPResponse#read_body {|str| .... } -> () (21.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 (21.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 (15.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) (15.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) (9.0)

接続相手の証明書の検証のために使う、信頼している CA 証明書を 含む証明書ストアを設定します。

...の証明書の検証のために使う、信頼している CA 証明書を
含む証明書ストアを設定します。

通常は Net::HTTP#ca_file= や Net::HTTP#ca_path= で
設定しますが、より詳細な設定をしたい場合にはこちらを用います。

デフォルトは nil (...

Net::HTTP#get(path, header = nil, dest = nil) -> Net::HTTPResponse (9.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 (9.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...
<< 1 2 > >>