コード例 #1
0
		private void InitClient()
		{
			lock(LOCK_OBJECT)
			{
				if((!_disableHttpConnectionPooling) && (_client == null))
				{
					_client = _sclient;
				}
				if(_client == null)
				{
					mainsoft.apache.commons.httpclient.MultiThreadedHttpConnectionManager manager =
						new mainsoft.apache.commons.httpclient.MultiThreadedHttpConnectionManager();
					manager.setConnectionStaleCheckingEnabled(false);
					manager.setMaxTotalConnections(200);
					//by some reasons RFC something - the default 
					//value will be 2 , so we need to change it ...
					manager.setMaxConnectionsPerHost(20);
					_client = new HttpClient(manager);
					_client.getParams().setIntParameter(HttpClientParams.MAX_REDIRECTS, _defaultMaxRedirectsNum);
					_client.getParams().setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, new java.lang.Boolean(true));
					_client.getParams().setParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT, new java.lang.Long(30000));
					_client.getParams().setParameter(HttpClientParams.USER_AGENT, 
							"VMW4J HttpClient (based on Jakarta Commons HttpClient)");
					_client.getParams ().setBooleanParameter (HttpClientParams.SINGLE_COOKIE_HEADER, true);
					java.util.ArrayList schemas = new java.util.ArrayList ();
					schemas.add ("Ntlm");
					schemas.add ("Digest");
					schemas.add ("Basic");
					schemas.add ("Negotiate");
					_client.getParams ().setParameter (AuthPolicy.AUTH_SCHEME_PRIORITY, schemas);
					if (!_disableHttpConnectionPooling) {
						_sclient = _client;
					}
				}
			}
		}
コード例 #2
0
 private void InitClient()
 {
     lock (LOCK_OBJECT)
     {
         if ((!_disableHttpConnectionPooling) && (_client == null))
         {
             _client = _sclient;
         }
         if (_client == null)
         {
             mainsoft.apache.commons.httpclient.MultiThreadedHttpConnectionManager manager =
                 new mainsoft.apache.commons.httpclient.MultiThreadedHttpConnectionManager();
             manager.setConnectionStaleCheckingEnabled(false);
             manager.setMaxTotalConnections(200);
             //by some reasons RFC something - the default
             //value will be 2 , so we need to change it ...
             manager.setMaxConnectionsPerHost(20);
             _client = new HttpClient(manager);
             _client.getParams().setIntParameter(HttpClientParams.MAX_REDIRECTS, _defaultMaxRedirectsNum);
             _client.getParams().setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, new java.lang.Boolean(true));
             _client.getParams().setParameter(HttpClientParams.CONNECTION_MANAGER_TIMEOUT, new java.lang.Long(30000));
             _client.getParams().setParameter(HttpClientParams.USER_AGENT,
                                              "VMW4J HttpClient (based on Jakarta Commons HttpClient)");
             _client.getParams().setBooleanParameter(HttpClientParams.SINGLE_COOKIE_HEADER, true);
             java.util.ArrayList schemas = new java.util.ArrayList();
             schemas.add("Ntlm");
             schemas.add("Digest");
             schemas.add("Basic");
             schemas.add("Negotiate");
             _client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, schemas);
             if (!_disableHttpConnectionPooling)
             {
                 _sclient = _client;
             }
         }
     }
 }