Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > net/httpライブラリ > Net::HTTPクラス

class Net::HTTP

クラスの継承リスト: Net::HTTP < Object < Kernel

要約

HTTP のクライアントのためのクラスです。

特異メソッド

定義 説明
Proxy(address, port = 80) -> Class

Proxy 経由で http サーバに接続するためのクラスを作成し返します。

http_default_port -> Integer
default_port -> Integer

HTTP のデフォルトポート (80) を返します。

get(uri) -> String
get(host, path, port = 80) -> String

指定した対象に GET リクエストを送り、そのボディを 文字列として返します。

get_print(uri) -> ()
get_print(host, path, port = 80) -> ()

指定した対象から HTTP でエンティティボディを取得し、 $stdout に出力します。

get_response(uri) -> Net::HTTPResponse
get_response(host, path = nil, port = nil) -> Net::HTTPResponse

指定した対象に GET リクエストを送り、そのレスポンスを Net::HTTPResponse として返します。

https_default_port -> Integer

HTTPS のデフォルトポート (443) を返します。

version_1_1? -> bool
is_version_1_1? -> bool

ライブラリの動作がバージョン1.1互換である場合に真を返します。

version_1_2? -> bool
is_version_1_2? -> bool

ライブラリの動作がバージョン1.2互換である場合に真を返します。

new(address, port = 80, proxy_addr = nil, proxy_port = nil, proxy_user=nil, proxy_pass=nil) -> Net::HTTP

新しい Net::HTTP オブジェクトを生成します。

post_form(uri, params) -> Net::HTTPResponse

URI で指定した対象に フォームのデータを HTTP で POST します。

proxy_address -> String|nil

自身が (Net::HTTP.Proxy によって作成された) プロクシ用のクラスならばプロクシのアドレスを返します。

proxy_class? -> bool

自身が (Net::HTTP.Proxy によって作成された) プロクシ用のクラスならば真を返し、そうでなければ偽を返します。

proxy_pass -> String|nil

自身が (Net::HTTP.Proxy によって作成された) プロクシ用のクラスならばプロクシ認証のパスワードを返します。

proxy_port -> Integer|nil

自身が (Net::HTTP.Proxy によって作成された) プロクシ用のクラスならばプロクシのポート番号を返します。

proxy_user -> String|nil

自身が (Net::HTTP.Proxy によって作成された) プロクシ用のクラスで、かつプロクシの認証を利用する場合は プロクシ認証のユーザ名を返します。

start(address, port = 80, proxy_addr = nil, proxy_port = nil, proxy_user=nil, proxy_pass=nil) -> Net::HTTP
start(address, port = 80, proxy_addr = nil, proxy_port = nil, proxy_user=nil, proxy_pass=nil) {|http| .... } -> object

新しい Net::HTTP オブジェクトを生成し、 TCP コネクション、 HTTP セッションを開始します。

version_1_1 -> ()

ライブラリの動作をバージョン1.1互換にします。

version_1_2 -> ()

ライブラリの動作をバージョン1.2互換、つまり 通常の動作にします。

インスタンスメソッド

定義 説明
started? -> bool
active? -> bool

HTTP セッションが開始されていたら真を返します。

address -> String

接続するアドレスを返します。

close_on_empty_response -> bool

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

close_on_empty_response=(bool)

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

copy(path, initheader = nil) -> Net::HTTPResponse

サーバの path に COPY リクエストを ヘッダを initheader として送ります。

delete(path, initheader = nil) -> Net::HTTPResponse

サーバの path に DELETE リクエストを ヘッダを initheader として送ります。

finish -> ()

HTTP セッションを終了します。セッション開始前にこのメソッドが 呼ばれた場合は例外 IOError を発生します。

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

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

request_get(path, header = nil) -> Net::HTTPResponse
request_get(path, header = nil) {|response| .... } -> Net::HTTPResponse
get2(path, header = nil) -> Net::HTTPResponse
get2(path, header = nil) {|response| .... } -> Net::HTTPResponse

サーバ上の path にあるエンティティを取得します。 Net::HTTPResponse オブジェクトを返します。

head(path, header = nil) -> Net::HTTPResponse

サーバ上の path にあるエンティティのヘッダのみを取得します。 Net::HTTPResponse のインスタンスを返します。

request_head(path, header = nil) -> Net::HTTPResponse
request_head(path, header = nil) {|response| .... } -> Net::HTTPResponse
head2(path, header = nil) -> Net::HTTPResponse
head2(path, header = nil) {|response| .... } -> Net::HTTPResponse

サーバ上の path にあるエンティティのヘッダのみを取得します。 Net::HTTPResponse オブジェクトを返します。

lock(path, body, initheader = nil) -> Net::HTTPResponse

サーバの path に LOCK リクエストを ヘッダを initheader, ボディを body として送ります。

mkcol(path, body, initheader = nil) -> Net::HTTPResponse

サーバの path に MKCOL リクエストを ヘッダが initheader, ボディを body として送ります。

move(path, body, initheader = nil) -> Net::HTTPResponse

サーバの path に MOVE リクエストを ヘッダが initheader, ボディを body として送ります。

open_timeout -> Integer

接続時に待つ最大秒数を返します。

open_timeout=(seconds)

接続時に待つ最大秒数を設定します。

options(path, initheader = nil) -> Net::HTTPResponse

サーバの path に OPTIONS リクエストを ヘッダが initheader として送り、 レスポンスを Net::HTTPResponse のオブジェクト で返します。

port -> Integer

接続するポート番号を返します。

post(path, data, header = nil, dest = nil) -> Net::HTTPResponse
post(path, data, header = nil, dest = nil) {|body_segment| .... } -> Net::HTTPResponse

サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。

request_post(path, data, header = nil) -> Net::HTTPResponse
request_post(path, data, header = nil) {|response| .... } -> Net::HTTPResponse
post2(path, data, header = nil) -> Net::HTTPResponse
post2(path, data, header = nil) {|response| .... } -> Net::HTTPResponse

サーバ上の path にあるエンティティに対し文字列 data を POST で送ります。 返り値は Net::HTTPResponse のインスタンスです。

propfind(path, body, initheader = {'Depth' => '0'}) -> Net::HTTPResponse

サーバの path に PROPFIND リクエストを ヘッダを initheader, ボディを body として送ります。

proppatch(path, body, initheader = nil) -> Net::HTTPResponse

サーバの path に PROPPATCH リクエストを ヘッダを initheader, ボディを body として送ります。

proxy? -> bool

プロクシを介して接続するなら真を返します。

proxy_address -> String|nil
proxyaddr -> String|nil

プロクシ経由で接続する HTTP オブジェクトならプロクシのアドレス を返します。

proxy_pass -> String|nil

プロクシ経由で接続し、さらにプロクシのユーザ認証を する HTTP オブジェクトなら認証のパスワードを を返します。

proxy_port -> Integer|nil
proxyport -> Integer|nil

プロクシ経由で接続する HTTP オブジェクトならプロクシのポート番号 を返します。

proxy_user -> String|nil

プロクシ経由で接続し、さらにプロクシのユーザ認証を する HTTP オブジェクトなら認証のユーザ名を を返します。

put(path, data, initheader = nil) -> Net::HTTPResponse

サーバ上の path にあるエンティティに対し文字列 data を PUT で送ります。

request_put(path, data, initheader = nil) -> Net::HTTPResponse
request_put(path, data, initheader = nil) {|response| .... } -> Net::HTTPResponse
put2(path, data, initheader = nil) -> Net::HTTPResponse
put2(path, data, initheader = nil) {|response| .... } -> Net::HTTPResponse

サーバ上の path にあるエンティティに対し文字列 data を PUT で送ります。

read_timeout -> Integer

読みこみ(read(2)) 一回でブロックしてよい最大秒数 を返します。

read_timeout=(seconds)

読みこみ(read(2)) 一回でブロックしてよい最大秒数を 設定します。

request(request, data = nil) -> Net::HTTPResponse
request(request, data = nil) {|response| .... } -> Net::HTTPResponse

Net::HTTPRequest オブジェクト request をサーバに送信します。

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

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

set_debug_output(io) -> ()

デバッグ出力の出力先を指定します。 このメソッドは深刻なセキュリティホールの原因 になるため、デバッグ以外では決して使わないでください。

start -> self
start {|http| .... } -> object

TCP コネクションを張り、HTTP セッションを開始します。 すでにセッションが開始していたら例外 IOError を発生します。

trace(path, initheader = nil) -> Net::HTTPResponse

サーバの path に TRACE リクエストを ヘッダを initheader として送ります。

unlock(path, body, initheader = nil) -> Net::HTTPResponse

サーバの path に UNLOCK リクエストを ヘッダを initheader, ボディを body として送ります。

use_ssl? -> bool

SSLを利用して接続する場合に真を返します。

継承したメソッド

== === =~ __id__ __send__ _dump class clone dclone display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy inspect instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method method_missing methods nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_a to_ary to_hash to_int to_io to_proc to_regexp to_s to_str to_yaml to_yaml_properties to_yaml_style untaint

追加されるメソッド

定義 説明 ライブラリ
ca_file -> String | nil

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

net/https
ca_file=(path)

信頼する CA 証明書ファイルのパスを文字列で設定します。

net/https
ca_path -> String | nil

信頼する CA 証明書ファイルが存在するディレクトリを設定します。

net/https
ca_path=(path)

信頼する CA 証明書ファイルが存在するディレクトリを設定します。

net/https
cert -> OpenSSL::X509::Certificate | nil

クライアント証明書を返します。

net/https
cert=(certificate)

クライアント証明書を設定します。

net/https
cert_store -> OpenSSL::X509::Store | nil

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

net/https
cert_store=(store)

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

net/https
key -> OpenSSL::PKey::PKey | nil

クライアント証明書の秘密鍵を返します。

net/https
key=(key)

クライアント証明書の秘密鍵を設定します。

net/https
peer_cert -> OpenSSL::X509::Certificate | nil

サーバの証明書を返します。

net/https
ssl_timeout -> Integer | nil

SSL/TLS のタイムアウト秒数を返します。

net/https
ssl_timeout=(sec)
timeout=(sec)

SSL/TLS のタイムアウト秒数を設定します。

net/https
use_ssl=(bool)

HTTP で SSL/TLS を使うかどうかを設定します。

net/https
use_ssl? -> bool

HTTP で SSL/TLS を使うなら true を返します。

net/https
verify_callback -> Proc

自身に設定されている検証をフィルタするコールバックを 返します。

net/https
verify_callback=(proc)

検証をフィルタするコールバックを設定します。

net/https
verify_depth -> Integer

証明書チェイン上の検証する最大の深さを返します。

net/https
verify_depth=(depth)

証明書チェイン上の検証する最大の深さを設定します。

net/https
verify_mode -> Integer | nil

検証モードを返します。

net/https
verify_mode=(mode)

検証モードを設定します。

net/https