るりまサーチ

最速Rubyリファレンスマニュアル検索!
1354件ヒット [1-100件を表示] (0.033秒)
トップページ > ライブラリ:net/http[x] > クエリ:net/http[x] > クラス:Net::HTTP[x]

別のキーワード

  1. net/smtp start
  2. net/http get
  3. net/imap name
  4. net/imap param
  5. net/http start

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

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

header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という...
...、返り値が [レスポンスオブジェクト, そのボディ] となります。

//emlist[例][ruby]{
# 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 |str|
f.write str
end
}
//}

@see Net::HTTP#request_get...

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

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

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

header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*', ... } という...
...、返り値が [レスポンスオブジェクト, そのボディ] となります。

//emlist[例][ruby]{
# 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 |str|
f.write str
end
}
//}

@see Net::HTTP#request_get...

Net::HTTP.Proxy(address, port = 80) -> Class (8015.0)

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

...ラスは Net::HTTP を継承しているので Net::HTTP と全く
同じように使えます。指定されたプロクシを常に経由して http サーバ
に接続します。

address が nil のときは Net::HTTP クラスをそのまま返します。

//emlist[例1: Net::HTTP.new を使...
...uire 'net/http'
proxy_class = Net::HTTP::Proxy('proxy.example.com', 8080)
http = proxy_class.new('www.example.org')
http.start {|h|
h.get('/ja/') # proxy.example.com 経由で接続します。
}
//}

//emlist[例2: Net::HTTP.start を使う][ruby]{
require 'net/http'
proxy_class = Net::HTTP::Prox...

Net::HTTP.get_print(host, path, port = 80) -> () (8015.0)

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

...ポートを整数で指定します。
@see Net::HTTP.get

=== 例

//emlist[][ruby]{
require 'net/http'
require 'uri'
Net::HTTP
.get_print URI.parse('http://www.example.com/index.html')
//}

もしくは

//emlist[][ruby]{
require 'net/http'
Net::HTTP
.get_print 'www.example.com', '/index.html'
//}...

Net::HTTP.get_print(uri) -> () (8015.0)

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

...ポートを整数で指定します。
@see Net::HTTP.get

=== 例

//emlist[][ruby]{
require 'net/http'
require 'uri'
Net::HTTP
.get_print URI.parse('http://www.example.com/index.html')
//}

もしくは

//emlist[][ruby]{
require 'net/http'
Net::HTTP
.get_print 'www.example.com', '/index.html'
//}...

絞り込み条件を変える

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

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

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

header が nil
でなければ、リクエストを送るときにその内容を HTTP ヘッダとして
送ります。 header は { 'Accept' = > '*/*...
...

1.1 互換モードの場合は、レスポンスに応じて例外が発生します。

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

response = nil
Net::HTTP
.start('some.www.server', 80) {|http|
response = http.head('/index.html')
}
p response['content-type']
//}

@see Net::HTTP#request_head...

Net::HTTP#local_host=(host) (8009.0)

接続に用いるローカルホスト名を指定します。

...ost ホスト名、もしくはアドレスを示す文字列

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

http = Net::HTTP.new("www.example.com")
http.local_host = "192.168.0.5"
http.local_port = "53043"

http.start do |h|
p h.get("/").body
end
//}

@see Net::HTTP#local_host=, Net::HTTP#local_port...

Net::HTTP#local_port=(port) (8009.0)

接続に用いるローカルポートを設定します。

...、もしくはサービス名文字列)

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

http = Net::HTTP.new("www.example.com")
http.local_host = "192.168.0.5"
http.local_port = "53043"

http.start do |h|
p h.get("/").body
end
//}

@see Net::HTTP#local_port=, Net::HTTP#local_host


@see Net::HTTP.new...

Net::HTTP#post(path, data, header = nil, dest = nil) -> Net::HTTPResponse (8009.0)

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

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

返り値は Net::HTTPResponse のインスタンスです。

ブロックと一緒に呼びだされたときはエンティティボディを少しずつ文字列として
ブロックに与え...
...例外が発生します。
また、返り値が [レスポンスオブジェクト, そのボディ] となります。

//emlist[例][ruby]{
# net/http version 1.1
response, body = http.post('/cgi-bin/search.rb', 'query=subject&target=ruby')

# version 1.2
response = http.post('/cgi-bin/search.rb...
...', 'query=subject&target=ruby')

# using block
File.open('save.html', 'w') {|f|
http.post('/cgi-bin/search.rb', 'query=subject&target=ruby') do |str|
f.write str
end
}
//}

@see Net::HTTP#request_post...

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

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

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

返り値は Net::HTTPResponse のインスタンスです。

ブロックと一緒に呼びだされたときはエンティティボディを少しずつ文字列として
ブロックに与え...
...例外が発生します。
また、返り値が [レスポンスオブジェクト, そのボディ] となります。

//emlist[例][ruby]{
# net/http version 1.1
response, body = http.post('/cgi-bin/search.rb', 'query=subject&target=ruby')

# version 1.2
response = http.post('/cgi-bin/search.rb...
...', 'query=subject&target=ruby')

# using block
File.open('save.html', 'w') {|f|
http.post('/cgi-bin/search.rb', 'query=subject&target=ruby') do |str|
f.write str
end
}
//}

@see Net::HTTP#request_post...

絞り込み条件を変える

<< 1 2 3 ... > >>