るりまサーチ

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

別のキーワード

  1. uri build
  2. uri extract
  3. uri new
  4. open-uri open
  5. uri regexp

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Net::HTTPExceptions#response -> Net::HTTPResponse (18244.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 readbody=true>
end
//}...

WEBrick::HTTPResponse#request_uri=(uri) (9237.0)

リクエストの URI をセットします。 デフォルトは nil です。

...リクエストの URI をセットします。
デフォルトは nil です。

@param uri リクエストの URI URI オブジェクトで指定します。...

WEBrick::HTTPResponse#request_uri -> URI | nil (9219.0)

リクエストの URI を返します。

...リクエストの URI を返します。...

Net::HTTPGenericRequest#response_body_permitted? -> bool (6150.0)

サーバからのレスポンスにエンティティボディを含むことが許されている HTTP メソッド (GET, POST など)の場合真を返します。

...合真を返します。

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

uri
= URI.parse('http://www.example.com/index.html')
post = Net::HTTP::Post.new(uri.request_uri)
post.response_body_permitted? # => true

head = Net::HTTP::Head.new(uri.request_uri)
head.response_body_permitted? # => false
//}...

Net::HTTPResponse#read_body {|str| .... } -> () (3079.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.exampl...
...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|
response
.read_body do |s|...

絞り込み条件を変える

Net::HTTPResponse#read_body(dest=nil) -> String|nil (3079.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.exampl...
...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|
response
.read_body do |s|...

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

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

...et/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(uri))
begin...

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

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

...す。

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

entity は obsolete です。

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

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

Net::HTTPResponse#code -> String (3037.0)

HTTP のリザルトコードです。例えば '302' などです。

...スオブジェクトがどのクラスのインスタンスかを
見ることでもレスポンスの種類を判別できます。

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

uri
= "http://www.example.com/index.html"
response
= Net::HTTP.get_response(URI.parse(uri))
response
.code # => "200"
//}...

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

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

...す。

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

entity は obsolete です。

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

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

絞り込み条件を変える

<< 1 2 3 ... > >>