173件ヒット
[1-100件を表示]
(0.108秒)
別のキーワード
種類
- インスタンスメソッド (84)
- 文書 (65)
- ライブラリ (12)
- モジュール (12)
ライブラリ
-
net
/ http (96)
クラス
-
Net
:: HTTPResponse (12)
モジュール
-
Net
:: HTTPExceptions (12) -
Net
:: HTTPHeader (60)
キーワード
-
1
. 6 . 8から1 . 8 . 0への変更点(まとめ) (12) - HTTPExceptions (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 4 . 0 (9) -
NEWS for Ruby 2
. 5 . 0 (8) -
canonical
_ each (12) - each (12)
-
each
_ capitalized (12) -
each
_ header (12) -
each
_ value (12) - response (12)
-
ruby 1
. 8 . 3 feature (12) -
ruby 1
. 9 feature (12)
検索結果
先頭5件
-
net
/ http (38072.0) -
汎用データ転送プロトコル HTTP を扱うライブラリです。 実装は 2616 に基きます。
...y]{
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 'ur......{
require 'net/http'
url = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
puts res.body
//}
==== フォームの情報を送信する (POST)
//emlist[例][ruby]{
require 'net/http'
require '......})
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
case res
when Net::HTTPSuccess, Net::HTTPRedirection
# OK
else
res.value
end
//}
==== プロクシ経由のアクセス
Net::HTTP は http_proxy 環境変数が存在するならば自動的に
その URI を利用し... -
Net
:: HTTPResponse # value -> nil (26131.0) -
レスポンスが 2xx(成功)でなかった場合に、対応する 例外を発生させます。
...スが 2xx(成功)でなかった場合に、対応する
例外を発生させます。
@raise HTTPError レスポンスが 1xx であるか、 net/http が知らない
種類のレスポンスである場合に発生します。
@raise HTTPRetriableError レスポンスが 3xx......レスポンスが 2xx(成功)][ruby]{
require 'net/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"
respo......nse = Net::HTTP.get_response(URI.parse(uri))
begin
response.value
rescue => e
e.class # => Net::HTTPServerException
e.message # => 404 "Not Found"
end
//}... -
Net
:: HTTPHeader # each _ value {|value| . . . . } -> () (14226.0) -
保持しているヘッダの値をブロックに渡し、呼びだします。
...れる文字列は ", " で連結したものです。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_value { |value| puts value }
# => gzip;q=1.0,deflate;q=0.6,identity;q=0.3
# => */*
# => Ruby
//}... -
Net
:: HTTPHeader # canonical _ each {|name , value| . . . . } -> () (8102.0) -
ヘッダフィールドの正規化名とその値のペアを ブロックに渡し、呼びだします。
ヘッダフィールドの正規化名とその値のペアを
ブロックに渡し、呼びだします。
正規化名は name に対し
name.downcase.split(/-/).capitalize.join('-')
で求まる文字列です。 -
Net
:: HTTPHeader # each _ capitalized {|name , value| . . . . } -> () (8102.0) -
ヘッダフィールドの正規化名とその値のペアを ブロックに渡し、呼びだします。
ヘッダフィールドの正規化名とその値のペアを
ブロックに渡し、呼びだします。
正規化名は name に対し
name.downcase.split(/-/).capitalize.join('-')
で求まる文字列です。 -
Net
:: HTTPHeader # each {|name , val| . . . . } -> () (8018.0) -
保持しているヘッダ名とその値をそれぞれ ブロックに渡して呼びだします。
...列がブロックに渡されます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_header { |key,value| puts "#{key} = #{value}" }
# => accept-encoding = gzip;q=1.0,deflate;q=0.6,identity;q=0.3
#... -
Net
:: HTTPHeader # each _ header {|name , val| . . . . } -> () (8018.0) -
保持しているヘッダ名とその値をそれぞれ ブロックに渡して呼びだします。
...列がブロックに渡されます。
//emlist[例][ruby]{
require 'net/http'
uri = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(uri.request_uri)
req.each_header { |key,value| puts "#{key} = #{value}" }
# => accept-encoding = gzip;q=1.0,deflate;q=0.6,identity;q=0.3
#... -
Net
:: HTTPExceptions # response -> Net :: HTTPResponse (8012.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
//}... -
Net
:: HTTPExceptions (8006.0) -
HTTP 例外クラスです。
...実際にはこれを include した以下のサブクラスの
例外が発生します。
* Net::HTTPError
* Net::HTTPRetriableError
* Net::HTTPServerException
* Net::HTTPFatalError
また、例外を発生させるためには Net::HTTPResponse#value を
呼ぶ必要があります。...