Module: Iudex::HTTPClient3

Defined in:
lib/iudex-httpclient-3.rb,
lib/iudex-httpclient-3/base.rb

Constant Summary collapse

VERSION =
'1.7.0'
LIB_DIR =

:nodoc:

File.dirname( __FILE__ )

Class Method Summary collapse

Class Method Details

.create_managerObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/iudex-httpclient-3.rb', line 32

def self.create_manager
  mgr = RJack::HTTPClient3::ManagerFacade.new

  # Sensible defaults:
  mgr.manager_params.max_total_connections = 100
  mgr.manager_params.default_max_connections_per_host = 3
  mgr.manager_params.stale_checking_enabled = false
  mgr.client_params.connection_manager_timeout = 3_000 #ms
  mgr.client_params.so_timeout = 5_000 #ms

  # Default no redirects
  mgr.client_params.set_int_parameter( "http.protocol.max-redirects", 0 )

  mgr.client_params.set_parameter(
      RJack::HTTPClient3::HttpMethodParams::RETRY_HANDLER,
      RJack::HTTPClient3::DefaultHttpMethodRetryHandler.new( 2, false ) )

  # FIXME: Use scoped per-session cookies?
  cp = Java::org.apache.commons.httpclient.cookie.CookiePolicy
  mgr.client_params.cookie_policy = cp::IGNORE_COOKIES

  Hooker.apply( [ :iudex, :http_client_3 ], mgr )

  mgr
end