るりまサーチ

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

別のキーワード

  1. kernel require
  2. getoptlong require_order
  3. rubygems/custom_require require
  4. irb/ext/use-loader irb_require
  5. kernel require_relative

ライブラリ

キーワード

検索結果

Net::HTTPGenericRequest#body -> String (24433.0)

サーバに送るリクエストのエンティティボディを返します。

...クエストのエンティティボディを返します。

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

uri = URI.parse('http://www.example.com/index.html')
r
eq = Net::HTTP::Post.new(uri.request_uri)
r
eq.body = "Test Post Data"
r
eq.body # => "Test Post Data"
//}

@see Net::HTTPGenericRequest#body=...

Net::HTTPResponse#body -> String | () | nil (24428.0)

エンティティボディを返します。

...す。

Net::HTTPResponse#read_body をブロック付きで呼んだ場合には
このメソッドはNet::ReadAdapter のインスタンスを返しますが、
これは使わないでください。

entity は obsolete です。

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

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

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

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

...t[例1 ブロックを与えずに一度に結果取得][ruby]{
require
'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...
...{
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 で少しずつ読み書き。メモリ消費が少ない。
htt...
...p.request_get(uri.path) do |response|
r
esponse.read_body do |s|
f.write(s)
end
end
end
end
//}

一度ブロックを与えずにこのメソッドを呼んだ場合には、
次からはすでに読みだしたボディを文字列として
返します。また一度ブ...

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

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

...t[例1 ブロックを与えずに一度に結果取得][ruby]{
require
'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...
...{
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 で少しずつ読み書き。メモリ消費が少ない。
htt...
...p.request_get(uri.path) do |response|
r
esponse.read_body do |s|
f.write(s)
end
end
end
end
//}

一度ブロックを与えずにこのメソッドを呼んだ場合には、
次からはすでに読みだしたボディを文字列として
返します。また一度ブ...

Net::HTTPResponse#entity -> String | () | nil (12328.0)

エンティティボディを返します。

...す。

Net::HTTPResponse#read_body をブロック付きで呼んだ場合には
このメソッドはNet::ReadAdapter のインスタンスを返しますが、
これは使わないでください。

entity は obsolete です。

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

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

絞り込み条件を変える