Class: Miby::HTTP
- Inherits:
-
Object
- Object
- Miby::HTTP
- Defined in:
- lib/http.rb
Overview
Mibyで利用するのhttpメソッドを提供します。 接続するホストのアドレスやプロキシの設定は Miby::Config で設定します。
使い方
実行したい処理をブロックで渡します。ブロック内で利用できるメソッドは Net::HTTPと同じです。
http_response = HTTP.new.connection {|http|
http.get(path)
...
}
Instance Attribute Summary collapse
-
#http_address ⇒ Object
readonly
Returns the value of attribute http_address.
-
#http_port ⇒ Object
readonly
Returns the value of attribute http_port.
-
#proxy_addr ⇒ Object
readonly
Returns the value of attribute proxy_addr.
-
#proxy_port ⇒ Object
readonly
Returns the value of attribute proxy_port.
Instance Method Summary collapse
-
#connection(&block) ⇒ Object
ホスト @http_address に接続しブロックをを実行します。 成功した場合は Net::HTTPResponse のインスタンスを返します。.
-
#initialize(config = Config.new) ⇒ HTTP
constructor
A new instance of HTTP.
Constructor Details
Instance Attribute Details
#http_address ⇒ Object (readonly)
Returns the value of attribute http_address.
23 24 25 |
# File 'lib/http.rb', line 23 def http_address @http_address end |
#http_port ⇒ Object (readonly)
Returns the value of attribute http_port.
23 24 25 |
# File 'lib/http.rb', line 23 def http_port @http_port end |
#proxy_addr ⇒ Object (readonly)
Returns the value of attribute proxy_addr.
23 24 25 |
# File 'lib/http.rb', line 23 def proxy_addr @proxy_addr end |
#proxy_port ⇒ Object (readonly)
Returns the value of attribute proxy_port.
23 24 25 |
# File 'lib/http.rb', line 23 def proxy_port @proxy_port end |
Instance Method Details
#connection(&block) ⇒ Object
ホスト @http_address に接続しブロックをを実行します。 成功した場合は Net::HTTPResponse のインスタンスを返します。
27 28 29 30 |
# File 'lib/http.rb', line 27 def connection(&block) puts "connection : #@http_address, #@http_port, #@proxy_addr, #@proxy_port" if $VERBOSE Net::HTTP.start(@http_address, @http_port, @proxy_addr, @proxy_port, &block) end |