るりまサーチ

最速Rubyリファレンスマニュアル検索!
345件ヒット [1-100件を表示] (0.091秒)
トップページ > クエリ:n[x] > クエリ:response=[x]

別のキーワード

  1. etc sc_xopen_enh_i18n
  2. rsa n=
  3. rsa n
  4. openssl n=
  5. pop n_bytes

ライブラリ

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

net/http (26012.0)

汎用データ転送プロトコル HTTP を扱うライブラリです。 実装は 2616 に基きます。

...[ruby]{
require 'net/http'
print Net::HTTP.get('www.example.com', '/index.html')
//}

//emlist[例2: URI を使う][ruby]{
require 'net/http'
require 'uri'
print Net::HTTP.get(URI.parse('http://www.example.com/index.html'))
//}

//emlist[例3: より汎用的な例][ruby]{
require 'net/http'
require...
...e.com/index.html')
res = Net::HTTP.start(url.host, url.port) {|http|
http.get('/index.html')
}
puts res.body
//}

//emlist[例4: 上の例よりさらに汎用的な例][ruby]{
require 'net/http'

url = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(url.path)
res = Net::HT...
...'net/http'
require 'uri'

def fetch(uri_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...

Net::IMAP::ResponseError#response=(resp) (24200.0)

エラーとなったレスポンスを表すオブジェクトを設定します。

エラーとなったレスポンスを表すオブジェクトを設定します。

@param resp 設定するレスポンスオブジェクト

Net::HTTP#close_on_empty_response=(bool) (12200.0)

レスポンスがボディを持っていない場合にコネクションを 閉じるかどうかを設定します。

...ンスがボディを持っていない場合にコネクションを
閉じるかどうかを設定します。


@param bool レスポンスがボディを持っていない場合にコネクションを
閉じるかどうか指定します。

@see Net::HTTP#close_on_empty_response...

Net::HTTPExceptions#response -> Net::HTTPResponse (6206.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
//}...

Data.define(*args) -> Class (6106.0)

Data クラスに新しいサブクラスを作って、それを返します。

...][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # => "Fred"
p fred.age # => 5
//}

メンバの値を書き換えることはできません。

//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}

メンバ...
...HTTPFetcher
Response =
Data.define(:body)
N
otFound = Data.define

def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
N
otFound.new
end
end
end

def fetch(url)
fetcher = HTTPFetcher.new
case f...
...etcher.get(url)
in HTTPFetcher::Response(body)
body
in HTTPFetcher::NotFound
:NotFound
end
end

p fetch("http://example.com/") # => "Current time is 2023-01-10 10:00:53 +0900"
p fetch("http://example.com/404") # => :NotFound
//}

@param args 値オブジェクトのクラスを定...

絞り込み条件を変える

Data.define(*args) {|subclass| block } -> Class (6106.0)

Data クラスに新しいサブクラスを作って、それを返します。

...][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # => "Fred"
p fred.age # => 5
//}

メンバの値を書き換えることはできません。

//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}

メンバ...
...HTTPFetcher
Response =
Data.define(:body)
N
otFound = Data.define

def get(url)
# ダミーの実装
if url == "http://example.com/"
Response.new(body: "Current time is #{Time.now}")
else
N
otFound.new
end
end
end

def fetch(url)
fetcher = HTTPFetcher.new
case f...
...etcher.get(url)
in HTTPFetcher::Response(body)
body
in HTTPFetcher::NotFound
:NotFound
end
end

p fetch("http://example.com/") # => "Current time is 2023-01-10 10:00:53 +0900"
p fetch("http://example.com/404") # => :NotFound
//}

@param args 値オブジェクトのクラスを定...

Net::HTTP#send_request(name, path, data = nil, header = nil) -> Net::HTTPResponse (6106.0)

HTTP リクエストをサーバに送り、そのレスポンスを Net::HTTPResponse のインスタンスとして返します。

...HTTP リクエストをサーバに送り、そのレスポンスを
N
et::HTTPResponse のインスタンスとして返します。

@param name リクエストのメソッド名を文字列で与えます。
@param path リクエストのパスを文字列で与えます。
@param data リクエ...
...ストのボディを文字列で与えます。
@param header リクエストのヘッダをハッシュで与えます。

//emlist[例][ruby]{
response =
http.send_request('GET', '/index.html')
puts response.body
//}

@see Net::HTTP#request...

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

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

...合には nil を返します。

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

entity は obsolete です。

//emlist[例][ruby]{
require 'net/http'...
...uri = "http://www.example.com/index.html"
response =
Net::HTTP.get_response(URI.parse(uri))
response.body[0..10] # => "<!doctype h"
//}...

Net::HTTPResponse#http_version -> String (6106.0)

サーバがサポートしている HTTP のバージョンを文字列で返します。

...サーバがサポートしている HTTP のバージョンを文字列で返します。

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

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

Net::HTTP#get(path, header = nil, dest = nil) -> Net::HTTPResponse (3206.0)

サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。

...サーバ上の path にあるエンティティを取得し、
N
et::HTTPResponse のインスタンスとして返します。

header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という...
...びだされたときは
エンティティボディを少しずつ文字列として
ブロックに与えます。このとき戻り値の
N
et::HTTPResponse オブジェクトは有効な body を
持ちません。

dest は時代遅れの引数です。利用しないでください。
dest を...
...uby]{
# 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.get('/~foo/', nil) do...

絞り込み条件を変える

Net::HTTP#get(path, header = nil, dest = nil) {|body_segment| .... } -> Net::HTTPResponse (3206.0)

サーバ上の path にあるエンティティを取得し、 Net::HTTPResponse のインスタンスとして返します。

...サーバ上の path にあるエンティティを取得し、
N
et::HTTPResponse のインスタンスとして返します。

header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という...
...びだされたときは
エンティティボディを少しずつ文字列として
ブロックに与えます。このとき戻り値の
N
et::HTTPResponse オブジェクトは有効な body を
持ちません。

dest は時代遅れの引数です。利用しないでください。
dest を...
...uby]{
# 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.get('/~foo/', nil) do...
<< 1 2 3 ... > >>