Class: HTTPAccess2::SessionManager
- Inherits:
-
Object
- Object
- HTTPAccess2::SessionManager
- Defined in:
- lib/rss-client/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.
1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 |
# File 'lib/rss-client/http-access2.rb', line 1286 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:
1269 1270 1271 |
# File 'lib/rss-client/http-access2.rb', line 1269 def agent_name @agent_name end |
#chunk_size ⇒ Object
Chunk size for chunked request
1273 1274 1275 |
# File 'lib/rss-client/http-access2.rb', line 1273 def chunk_size @chunk_size end |
#connect_retry ⇒ Object
Maximum retry count. 0 for infinite.
1279 1280 1281 |
# File 'lib/rss-client/http-access2.rb', line 1279 def connect_retry @connect_retry end |
#connect_timeout ⇒ Object
These parameters are not used now…
1278 1279 1280 |
# File 'lib/rss-client/http-access2.rb', line 1278 def connect_timeout @connect_timeout end |
#debug_dev ⇒ Object
Device for dumping log for debugging
1274 1275 1276 |
# File 'lib/rss-client/http-access2.rb', line 1274 def debug_dev @debug_dev end |
#from ⇒ Object
Owner of this client.
1270 1271 1272 |
# File 'lib/rss-client/http-access2.rb', line 1270 def from @from end |
#protocol_version ⇒ Object
Requested protocol version
1272 1273 1274 |
# File 'lib/rss-client/http-access2.rb', line 1272 def protocol_version @protocol_version end |
#read_block_size ⇒ Object
Returns the value of attribute read_block_size.
1282 1283 1284 |
# File 'lib/rss-client/http-access2.rb', line 1282 def read_block_size @read_block_size end |
#receive_timeout ⇒ Object
Returns the value of attribute receive_timeout.
1281 1282 1283 |
# File 'lib/rss-client/http-access2.rb', line 1281 def receive_timeout @receive_timeout end |
#send_timeout ⇒ Object
Returns the value of attribute send_timeout.
1280 1281 1282 |
# File 'lib/rss-client/http-access2.rb', line 1280 def send_timeout @send_timeout end |
#socket_sync ⇒ Object
Boolean value for Socket#sync
1275 1276 1277 |
# File 'lib/rss-client/http-access2.rb', line 1275 def socket_sync @socket_sync end |
#ssl_config ⇒ Object
Returns the value of attribute ssl_config.
1284 1285 1286 |
# File 'lib/rss-client/http-access2.rb', line 1284 def ssl_config @ssl_config end |
Instance Method Details
#keep(sess) ⇒ Object
1344 1345 1346 |
# File 'lib/rss-client/http-access2.rb', line 1344 def keep(sess) add_cached_session(sess) end |
#proxy=(proxy) ⇒ Object
1309 1310 1311 1312 1313 1314 1315 |
# File 'lib/rss-client/http-access2.rb', line 1309 def proxy=(proxy) if proxy.nil? @proxy = nil else @proxy = Site.new(proxy) end end |
#query(req, proxy) ⇒ Object
1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 |
# File 'lib/rss-client/http-access2.rb', line 1317 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
1335 1336 1337 1338 |
# File 'lib/rss-client/http-access2.rb', line 1335 def reset(uri) site = Site.new(uri) close(site) end |
#reset_all ⇒ Object
1340 1341 1342 |
# File 'lib/rss-client/http-access2.rb', line 1340 def reset_all close_all end |