Class: HTTPClient::SessionManager
- Inherits:
-
Object
- Object
- HTTPClient::SessionManager
- Defined in:
- lib/httpclient.rb
Overview
HTTPClient::SessionManager – manage several sessions.
Instance Attribute Summary collapse
-
#agent_name ⇒ Object
:nodoc:.
-
#chunk_size ⇒ Object
Chunk size for chunked request.
-
#connect_retry ⇒ Object
Maximum retry count.
-
#connect_timeout ⇒ Object
These parameters are not used now…
-
#debug_dev ⇒ Object
Device for dumping log for debugging.
-
#from ⇒ Object
Owner of this client.
-
#protocol_version ⇒ Object
Requested protocol version.
-
#read_block_size ⇒ Object
Returns the value of attribute read_block_size.
-
#receive_timeout ⇒ Object
Returns the value of attribute receive_timeout.
-
#send_timeout ⇒ Object
Returns the value of attribute send_timeout.
-
#socket_sync ⇒ Object
Boolean value for Socket#sync.
-
#ssl_config ⇒ Object
Returns the value of attribute ssl_config.
-
#test_loopback_http_response ⇒ Object
readonly
Returns the value of attribute test_loopback_http_response.
Instance Method Summary collapse
-
#initialize ⇒ SessionManager
constructor
A new instance of SessionManager.
- #keep(sess) ⇒ Object
- #proxy=(proxy) ⇒ Object
- #query(req, proxy) ⇒ Object
- #reset(uri) ⇒ Object
- #reset_all ⇒ Object
Constructor Details
#initialize ⇒ SessionManager
Returns a new instance of SessionManager.
806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 |
# File 'lib/httpclient.rb', line 806 def initialize @proxy = nil @agent_name = nil @from = nil @protocol_version = nil @debug_dev = nil @socket_sync = true @chunk_size = 4096 @connect_timeout = 60 @connect_retry = 1 @send_timeout = 120 @receive_timeout = 60 # For each read_block_size bytes @read_block_size = 8192 @ssl_config = nil @test_loopback_http_response = [] @sess_pool = [] @sess_pool_mutex = Mutex.new end |
Instance Attribute Details
#agent_name ⇒ Object
:nodoc:
787 788 789 |
# File 'lib/httpclient.rb', line 787 def agent_name @agent_name end |
#chunk_size ⇒ Object
Chunk size for chunked request
791 792 793 |
# File 'lib/httpclient.rb', line 791 def chunk_size @chunk_size end |
#connect_retry ⇒ Object
Maximum retry count. 0 for infinite.
797 798 799 |
# File 'lib/httpclient.rb', line 797 def connect_retry @connect_retry end |
#connect_timeout ⇒ Object
These parameters are not used now…
796 797 798 |
# File 'lib/httpclient.rb', line 796 def connect_timeout @connect_timeout end |
#debug_dev ⇒ Object
Device for dumping log for debugging
792 793 794 |
# File 'lib/httpclient.rb', line 792 def debug_dev @debug_dev end |
#from ⇒ Object
Owner of this client.
788 789 790 |
# File 'lib/httpclient.rb', line 788 def from @from end |
#protocol_version ⇒ Object
Requested protocol version
790 791 792 |
# File 'lib/httpclient.rb', line 790 def protocol_version @protocol_version end |
#read_block_size ⇒ Object
Returns the value of attribute read_block_size.
800 801 802 |
# File 'lib/httpclient.rb', line 800 def read_block_size @read_block_size end |
#receive_timeout ⇒ Object
Returns the value of attribute receive_timeout.
799 800 801 |
# File 'lib/httpclient.rb', line 799 def receive_timeout @receive_timeout end |
#send_timeout ⇒ Object
Returns the value of attribute send_timeout.
798 799 800 |
# File 'lib/httpclient.rb', line 798 def send_timeout @send_timeout end |
#socket_sync ⇒ Object
Boolean value for Socket#sync
793 794 795 |
# File 'lib/httpclient.rb', line 793 def socket_sync @socket_sync end |
#ssl_config ⇒ Object
Returns the value of attribute ssl_config.
802 803 804 |
# File 'lib/httpclient.rb', line 802 def ssl_config @ssl_config end |
#test_loopback_http_response ⇒ Object (readonly)
Returns the value of attribute test_loopback_http_response.
804 805 806 |
# File 'lib/httpclient.rb', line 804 def test_loopback_http_response @test_loopback_http_response end |
Instance Method Details
#keep(sess) ⇒ Object
865 866 867 |
# File 'lib/httpclient.rb', line 865 def keep(sess) add_cached_session(sess) end |
#proxy=(proxy) ⇒ Object
830 831 832 833 834 835 836 |
# File 'lib/httpclient.rb', line 830 def proxy=(proxy) if proxy.nil? @proxy = nil else @proxy = Site.new(proxy) end end |
#query(req, proxy) ⇒ Object
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 |
# File 'lib/httpclient.rb', line 838 def query(req, proxy) req.body.chunk_size = @chunk_size dest_site = Site.new(req.header.request_uri) proxy_site = if proxy Site.new(proxy) else @proxy end sess = open(dest_site, proxy_site) begin sess.query(req) rescue sess.close raise end sess end |
#reset(uri) ⇒ Object
856 857 858 859 |
# File 'lib/httpclient.rb', line 856 def reset(uri) site = Site.new(uri) close(site) end |
#reset_all ⇒ Object
861 862 863 |
# File 'lib/httpclient.rb', line 861 def reset_all close_all end |