Class: HTTPAccess2::SessionManager
- Inherits:
-
Object
- Object
- HTTPAccess2::SessionManager
- Defined in:
- lib/reap/vendor/http-access2.rb
Overview
HTTPAccess2::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.
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.
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 |
# File 'lib/reap/vendor/http-access2.rb', line 853 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 @sess_pool = [] @sess_pool_mutex = Mutex.new end |
Instance Attribute Details
#agent_name ⇒ Object
:nodoc:
836 837 838 |
# File 'lib/reap/vendor/http-access2.rb', line 836 def agent_name @agent_name end |
#chunk_size ⇒ Object
Chunk size for chunked request
840 841 842 |
# File 'lib/reap/vendor/http-access2.rb', line 840 def chunk_size @chunk_size end |
#connect_retry ⇒ Object
Maximum retry count. 0 for infinite.
846 847 848 |
# File 'lib/reap/vendor/http-access2.rb', line 846 def connect_retry @connect_retry end |
#connect_timeout ⇒ Object
These parameters are not used now…
845 846 847 |
# File 'lib/reap/vendor/http-access2.rb', line 845 def connect_timeout @connect_timeout end |
#debug_dev ⇒ Object
Device for dumping log for debugging
841 842 843 |
# File 'lib/reap/vendor/http-access2.rb', line 841 def debug_dev @debug_dev end |
#from ⇒ Object
Owner of this client.
837 838 839 |
# File 'lib/reap/vendor/http-access2.rb', line 837 def from @from end |
#protocol_version ⇒ Object
Requested protocol version
839 840 841 |
# File 'lib/reap/vendor/http-access2.rb', line 839 def protocol_version @protocol_version end |
#read_block_size ⇒ Object
Returns the value of attribute read_block_size.
849 850 851 |
# File 'lib/reap/vendor/http-access2.rb', line 849 def read_block_size @read_block_size end |
#receive_timeout ⇒ Object
Returns the value of attribute receive_timeout.
848 849 850 |
# File 'lib/reap/vendor/http-access2.rb', line 848 def receive_timeout @receive_timeout end |
#send_timeout ⇒ Object
Returns the value of attribute send_timeout.
847 848 849 |
# File 'lib/reap/vendor/http-access2.rb', line 847 def send_timeout @send_timeout end |
#socket_sync ⇒ Object
Boolean value for Socket#sync
842 843 844 |
# File 'lib/reap/vendor/http-access2.rb', line 842 def socket_sync @socket_sync end |
#ssl_config ⇒ Object
Returns the value of attribute ssl_config.
851 852 853 |
# File 'lib/reap/vendor/http-access2.rb', line 851 def ssl_config @ssl_config end |
Instance Method Details
#keep(sess) ⇒ Object
914 915 916 |
# File 'lib/reap/vendor/http-access2.rb', line 914 def keep(sess) add_cached_session(sess) end |
#proxy=(proxy) ⇒ Object
876 877 878 879 880 881 882 |
# File 'lib/reap/vendor/http-access2.rb', line 876 def proxy=(proxy) if proxy.nil? @proxy = nil else @proxy = Site.new(proxy) end end |
#query(req, proxy) ⇒ Object
884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 |
# File 'lib/reap/vendor/http-access2.rb', line 884 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
902 903 904 905 906 907 908 |
# File 'lib/reap/vendor/http-access2.rb', line 902 def reset(uri) unless uri.is_a?(URI) uri = URI.parse(uri.to_s) end site = Site.new(uri) close(site) end |
#reset_all ⇒ Object
910 911 912 |
# File 'lib/reap/vendor/http-access2.rb', line 910 def reset_all close_all end |