Example #1
0
        public virtual HttpClient GetHttpClient()
        {
            // workaround attempt for issue #81
            // it does not seem like _not_ using the ThreadSafeClientConnManager actually
            // caused any problems, but it seems wise to use it "just in case", since it provides
            // extra safety and there are no observed side effects.
            BasicHttpParams @params        = new BasicHttpParams();
            SchemeRegistry  schemeRegistry = new SchemeRegistry();

            schemeRegistry.Register(new Apache.Http.Conn.Scheme.Scheme("http", PlainSocketFactory
                                                                       .GetSocketFactory(), 80));
            SSLSocketFactory sslSocketFactory = SSLSocketFactory.GetSocketFactory();

            schemeRegistry.Register(new Apache.Http.Conn.Scheme.Scheme("https", this.sslSocketFactory
                                                                       == null ? sslSocketFactory : this.sslSocketFactory, 443));
            ClientConnectionManager cm = new ThreadSafeClientConnManager(@params, schemeRegistry
                                                                         );
            DefaultHttpClient client = new DefaultHttpClient(cm, @params);

            // synchronize access to the cookieStore in case there is another
            // thread in the middle of updating it.  wait until they are done so we get their changes.
            lock (this)
            {
                client.SetCookieStore(cookieStore);
            }
            return(client);
        }
		public virtual HttpClient GetHttpClient()
		{
			// workaround attempt for issue #81
			// it does not seem like _not_ using the ThreadSafeClientConnManager actually
			// caused any problems, but it seems wise to use it "just in case", since it provides
			// extra safety and there are no observed side effects.
			BasicHttpParams @params = new BasicHttpParams();
			SchemeRegistry schemeRegistry = new SchemeRegistry();
			schemeRegistry.Register(new Apache.Http.Conn.Scheme.Scheme("http", PlainSocketFactory
				.GetSocketFactory(), 80));
			SSLSocketFactory sslSocketFactory = SSLSocketFactory.GetSocketFactory();
			schemeRegistry.Register(new Apache.Http.Conn.Scheme.Scheme("https", this.sslSocketFactory
				 == null ? sslSocketFactory : this.sslSocketFactory, 443));
			ClientConnectionManager cm = new ThreadSafeClientConnManager(@params, schemeRegistry
				);
			DefaultHttpClient client = new DefaultHttpClient(cm, @params);
			// synchronize access to the cookieStore in case there is another
			// thread in the middle of updating it.  wait until they are done so we get their changes.
			lock (this)
			{
				client.SetCookieStore(cookieStore);
			}
			return client;
		}
 public virtual void SetBasicHttpParams(BasicHttpParams basicHttpParams)
 {
     this.basicHttpParams = basicHttpParams;
 }
        /// <exception cref="System.IO.IOException"></exception>
        public virtual Socket CreateSocket()
        {
            HttpParams @params = new BasicHttpParams();

            return(this.factory.CreateSocket(@params));
        }
Example #5
0
 public virtual void SetBasicHttpParams(BasicHttpParams basicHttpParams)
 {
     this.basicHttpParams = basicHttpParams;
 }