Example #1
0
        public LinkCache(BindingSession session)
        {
            int repCount = session.GetValue(SessionParameter.CacheSizeRepositories, CacheSizeRepositories);
            if (repCount < 1)
            {
                repCount = CacheSizeRepositories;
            }

            int typeCount = session.GetValue(SessionParameter.CacheSizeTypes, CacheSizeTypes);
            if (typeCount < 1)
            {
                typeCount = CacheSizeTypes;
            }

            int objCount = session.GetValue(SessionParameter.CacheSizeLinks, CacheSizeLinks);
            if (objCount < 1)
            {
                objCount = CacheSizeLinks;
            }

            string dictionaryLevelName = typeof(DictionaryCacheLevel).FullName;
            string lruLevelName = typeof(LruCacheLevel).FullName;
            string contentTypeLevelName = typeof(DictionaryCacheLevel).FullName;

            linkCache = new Cache("Link Cache");
            linkCache.Initialize(new string[] {
                dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(), // repository
                lruLevelName + " " + LruCacheLevel.MaxEntries + "=" + objCount.ToString(), // id
                dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=16", // rel
                contentTypeLevelName + " " + DictionaryCacheLevel.Capacity + "=3,"
                        + DictionaryCacheLevel.SingleValue + "=true" // type
        });

            typeLinkCache = new Cache("Type Link Cache");
            typeLinkCache.Initialize(new string[] {
                dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(), // repository
                lruLevelName + " " + LruCacheLevel.MaxEntries + "=" + typeCount.ToString(), // id
                dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=16", // rel
                contentTypeLevelName + " " + DictionaryCacheLevel.Capacity + "=3,"
                        + DictionaryCacheLevel.SingleValue + "=true"// type
        });

            collectionLinkCache = new Cache("Collection Link Cache");
            collectionLinkCache.Initialize(new string[] {
                dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(), // repository
                dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=8" // collection
        });

            templateCache = new Cache("URI Template Cache");
            templateCache.Initialize(new string[] {
                dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(), // repository
                dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=6" // type
        });

            repositoryLinkCache = new Cache("Repository Link Cache");
            repositoryLinkCache.Initialize(new string[] {
                dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=" + repCount.ToString(), // repository
                dictionaryLevelName + " " + DictionaryCacheLevel.Capacity + "=6" // rel
        });
        }
Example #2
0
        public CmisBinding(IDictionary<string, string> sessionParameters, AbstractAuthenticationProvider authenticationProvider)
        {
            if (sessionParameters == null)
            {
                throw new ArgumentNullException("sessionParameters");
            }

            if (!sessionParameters.ContainsKey(SessionParameter.BindingSpiClass))
            {
                throw new ArgumentException("Session parameters do not contain a SPI class name!");
            }

            // initialize session
            session = new BindingSession();
            foreach (string key in sessionParameters.Keys)
            {
                session.PutValue(key, sessionParameters[key]);
            }

            // set up authentication provider
            if (authenticationProvider == null)
            {
                string authenticationProviderClass;
                if (sessionParameters.TryGetValue(SessionParameter.AuthenticationProviderClass, out authenticationProviderClass))
                {
                    try
                    {
                        Type authProvType = Type.GetType(authenticationProviderClass);
                        authenticationProvider = (AbstractAuthenticationProvider)Activator.CreateInstance(authProvType);
                        authenticationProvider.Session = session;
                        session.PutValue(BindingSession.AuthenticationProvider, authenticationProvider);
                    }
                    catch (Exception e)
                    {
                        throw new CmisRuntimeException("Could not load authentictaion provider: " + e.Message, e);
                    }
                }
            }
            else
            {
                authenticationProvider.Session = session;
                session.PutValue(BindingSession.AuthenticationProvider, authenticationProvider);
            }

            // initialize the SPI
            GetSpi();

            // set up caches
            ClearAllCaches();

            // set up repository service
            repositoryServiceWrapper = new BindingRepositoryService(session);
        }
Example #3
0
        public CmisBinding(IDictionary <string, string> sessionParameters, AbstractAuthenticationProvider authenticationProvider)
        {
            if (sessionParameters == null)
            {
                throw new ArgumentNullException("sessionParameters");
            }

            if (!sessionParameters.ContainsKey(SessionParameter.BindingSpiClass))
            {
                throw new ArgumentException("Session parameters do not contain a SPI class name!");
            }

            // initialize session
            session = new BindingSession();
            foreach (string key in sessionParameters.Keys)
            {
                session.PutValue(key, sessionParameters[key]);
            }

            // set up authentication provider
            if (authenticationProvider == null)
            {
                string authenticationProviderClass;
                if (sessionParameters.TryGetValue(SessionParameter.AuthenticationProviderClass, out authenticationProviderClass))
                {
                    try
                    {
                        Type authProvType = Type.GetType(authenticationProviderClass);
                        authenticationProvider         = (AbstractAuthenticationProvider)Activator.CreateInstance(authProvType);
                        authenticationProvider.Session = session;
                        session.PutValue(BindingSession.AuthenticationProvider, authenticationProvider);
                    }
                    catch (Exception e)
                    {
                        throw new CmisRuntimeException("Could not load authentictaion provider: " + e.Message, e);
                    }
                }
            }
            else
            {
                authenticationProvider.Session = session;
                session.PutValue(BindingSession.AuthenticationProvider, authenticationProvider);
            }

            // initialize the SPI
            GetSpi();

            // set up caches
            ClearAllCaches();

            // set up repository service
            repositoryServiceWrapper = new BindingRepositoryService(session);
        }
Example #4
0
        public void initialize(BindingSession session)
        {
            PortProvider provider = new PortProvider(session);

            repositoryService = new RepositoryService(session, provider);
            navigationService = new NavigationService(session, provider);
            objectService = new ObjectService(session, provider);
            versioningService = new VersioningService(session, provider);
            discoveryService = new DiscoveryService(session, provider);
            multiFilingService = new MultiFilingService(session, provider);
            relationshipService = new RelationshipService(session, provider);
            policyService = new PolicyService(session, provider);
            aclService = new AclService(session, provider);
        }
Example #5
0
        public void Dispose()
        {
            CheckSession();

            session.Lock();
            try
            {
                GetSpi().Dispose();
            }
            finally
            {
                session.Unlock();
                session = null;
            }
        }
Example #6
0
        public TypeDefinitionCache(BindingSession session)
        {
            int repCount = session.GetValue(SessionParameter.CacheSizeRepositories, CacheSizeRepositories);
            if (repCount < 1)
            {
                repCount = CacheSizeRepositories;
            }

            int typeCount = session.GetValue(SessionParameter.CacheSizeTypes, CacheSizeTypes);
            if (typeCount < 1)
            {
                typeCount = CacheSizeTypes;
            }

            cache = new Cache("Type Definition Cache");
            cache.Initialize(new string[] {
                typeof(DictionaryCacheLevel).FullName + " " + DictionaryCacheLevel.Capacity + "=" + repCount, // repository
                typeof(LruCacheLevel).FullName + " " + LruCacheLevel.MaxEntries + "=" + typeCount // type
        });
        }
Example #7
0
 public static Response InvokeGET(UrlBuilder url, BindingSession session)
 {
     return Invoke(url, "GET", null, null, session, null, null, null);
 }
Example #8
0
 public static Response InvokePUT(UrlBuilder url, String contentType, IDictionary <string, string> headers, Output writer, BindingSession session)
 {
     return(Invoke(url, "PUT", contentType, writer, session, null, null, headers));
 }
Example #9
0
        private static Response Invoke(UrlBuilder url, String method, String contentType, Output writer, BindingSession session,
                                       int?offset, int?length, IDictionary <string, string> headers)
        {
            try
            {
                // log before connect
                if (DotCMISDebug.DotCMISSwitch.TraceInfo)
                {
                    Trace.WriteLine(method + " " + url);
                }

                // create connection
                HttpWebRequest conn = (HttpWebRequest)WebRequest.Create(url.Url);
                conn.Method    = method;
                conn.UserAgent = "Apache Chemistry DotCMIS";

                // timeouts
                int connectTimeout = session.GetValue(SessionParameter.ConnectTimeout, -2);
                if (connectTimeout >= -1)
                {
                    conn.Timeout = connectTimeout;
                }

                int readTimeout = session.GetValue(SessionParameter.ReadTimeout, -2);
                if (readTimeout >= -1)
                {
                    conn.ReadWriteTimeout = readTimeout;
                }

                // set content type
                if (contentType != null)
                {
                    conn.ContentType = contentType;
                }

                // set additional headers
                if (headers != null)
                {
                    foreach (KeyValuePair <string, string> header in headers)
                    {
                        conn.Headers.Add(header.Key, header.Value);
                    }
                }

                // authenticate
                IAuthenticationProvider authProvider = session.GetAuthenticationProvider();
                if (authProvider != null)
                {
                    conn.PreAuthenticate = true;
                    authProvider.Authenticate(conn);
                }

                // range
                if (offset != null && length != null)
                {
                    conn.AddRange(offset ?? 0, offset + length - 1 ?? 0);
                }
                else if (offset != null)
                {
                    conn.AddRange(offset ?? 0);
                }

                // compression
                string compressionFlag = session.GetValue(SessionParameter.Compression) as string;
                if (compressionFlag != null && compressionFlag.ToLower().Equals("true"))
                {
                    conn.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                }

                // send data
                if (writer != null)
                {
                    conn.SendChunked = true;
                    Stream requestStream = conn.GetRequestStream();
                    writer(requestStream);
                    requestStream.Close();
                }

                // connect
                try
                {
                    HttpWebResponse response = (HttpWebResponse)conn.GetResponse();

                    if (authProvider != null)
                    {
                        authProvider.HandleResponse(response);
                    }

                    return(new Response(response));
                }
                catch (WebException we)
                {
                    return(new Response(we));
                }
            }
            catch (Exception e)
            {
                throw new CmisConnectionException("Cannot access " + url + ": " + e.Message, e);
            }
        }
Example #10
0
        private static Response Invoke(UrlBuilder url, String method, String contentType, Output writer, BindingSession session,
                long? offset, long? length, IDictionary<string, string> headers)
        {
            try
            {
                // log before connect
                if (DotCMISDebug.DotCMISSwitch.TraceInfo)
                {
                    Trace.WriteLine(method + " " + url);
                }

                // create connection           
                HttpWebRequest conn = (HttpWebRequest)WebRequest.Create(url.Url);
                conn.Method = method;
                conn.UserAgent = "Apache Chemistry DotCMIS";

                // timeouts
                int connectTimeout = session.GetValue(SessionParameter.ConnectTimeout, -2);
                if (connectTimeout >= -1)
                {
                    conn.Timeout = connectTimeout;
                }

                int readTimeout = session.GetValue(SessionParameter.ReadTimeout, -2);
                if (readTimeout >= -1)
                {
                    conn.ReadWriteTimeout = readTimeout;
                }

                // set content type
                if (contentType != null)
                {
                    conn.ContentType = contentType;
                }

                // set additional headers
                if (headers != null)
                {
                    foreach (KeyValuePair<string, string> header in headers)
                    {
                        conn.Headers.Add(header.Key, header.Value);
                    }
                }

                // authenticate
                IAuthenticationProvider authProvider = session.GetAuthenticationProvider();
                if (authProvider != null)
                {
                    conn.PreAuthenticate = true;
                    authProvider.Authenticate(conn);
                }

                // range
                if (offset != null && length != null)
                {
                    if (offset < Int32.MaxValue && offset + length - 1 < Int32.MaxValue)
                    {
                        conn.AddRange((int)offset, (int)offset + (int)length - 1);
                    }
                    else
                    {
                        try
                        {
                            MethodInfo mi = conn.GetType().GetMethod("AddRange", new Type[] { typeof(Int64), typeof(Int64) });
                            mi.Invoke(conn, new object[] { offset, offset + length - 1 });
                        }
                        catch (Exception e)
                        {
                            throw new CmisInvalidArgumentException("Offset or length too big!", e);
                        }
                    }
                }
                else if (offset != null)
                {
                    if (offset < Int32.MaxValue)
                    {
                        conn.AddRange((int)offset);
                    }
                    else
                    {
                        try
                        {
                            MethodInfo mi = conn.GetType().GetMethod("AddRange", new Type[] { typeof(Int64) });
                            mi.Invoke(conn, new object[] { offset });
                        }
                        catch (Exception e)
                        {
                            throw new CmisInvalidArgumentException("Offset too big!", e);
                        }
                    }
                }

                // compression
                string compressionFlag = session.GetValue(SessionParameter.Compression) as string;
                if (compressionFlag != null && compressionFlag.ToLower().Equals("true"))
                {
                    conn.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                }

                // send data
                if (writer != null)
                {
                    conn.SendChunked = true;
                    Stream requestStream = conn.GetRequestStream();
                    writer(requestStream);
                    requestStream.Close();
                }
                else
                {
#if __MonoCS__
                    //around for MONO HTTP DELETE issue
                    //http://stackoverflow.com/questions/11785597/monotouch-iphone-call-to-httpwebrequest-getrequeststream-connects-to-server
                    if (method == "DELETE")
                    {
                        conn.ContentLength = 0;
                        Stream requestStream = conn.GetRequestStream();
                        requestStream.Close();
                    }
#endif
                }

                // connect
                try
                {
                    HttpWebResponse response = (HttpWebResponse)conn.GetResponse();

                    if (authProvider != null)
                    {
                        authProvider.HandleResponse(response);
                    }

                    return new Response(response);
                }
                catch (WebException we)
                {
                    return new Response(we);
                }
            }
            catch (Exception e)
            {
                throw new CmisConnectionException("Cannot access " + url + ": " + e.Message, e);
            }
        }
Example #11
0
 public static Response InvokeGET(UrlBuilder url, BindingSession session, int?offset, int?length)
 {
     return(Invoke(url, "GET", null, null, session, offset, length, null));
 }
Example #12
0
 public MultiFilingService(BindingSession session, PortProvider provider)
 {
     Session = session;
     Provider = provider;
 }
Example #13
0
 public static Response InvokePUT(UrlBuilder url, String contentType, IDictionary<string, string> headers, Output writer, BindingSession session)
 {
     return Invoke(url, "PUT", contentType, writer, session, null, null, headers);
 }
Example #14
0
 public DiscoveryService(BindingSession session, PortProvider provider)
 {
     Session = session;
     Provider = provider;
 }
Example #15
0
 public PortProvider(BindingSession session)
 {
     this.session = session;
 }
Example #16
0
 public RelationshipService(BindingSession session, PortProvider provider)
 {
     Session = session;
     Provider = provider;
 }
Example #17
0
        private static Response Invoke(UrlBuilder url, String method, String contentType, Output writer, BindingSession session,
            long? offset, long? length, IDictionary<string, string> headers)
        {
            try
            {
                // log before connect
                if (DotCMISDebug.DotCMISSwitch.TraceInfo)
                {
                    Trace.WriteLine(method + " " + url);
                }

                // create connection
                HttpWebRequest conn = (HttpWebRequest)WebRequest.Create(url.Url);
                conn.Method = method;
                conn.UserAgent = "Apache Chemistry DotCMIS";

                // timeouts
                int connectTimeout = session.GetValue(SessionParameter.ConnectTimeout, -2);
                if (connectTimeout >= -1)
                {
                    conn.Timeout = connectTimeout;
                }

                int readTimeout = session.GetValue(SessionParameter.ReadTimeout, -2);
                if (readTimeout >= -1)
                {
                    conn.ReadWriteTimeout = readTimeout;
                }

                // set content type
                if (contentType != null)
                {
                    conn.ContentType = contentType;
                }

                // set additional headers
                if (headers != null)
                {
                    foreach (KeyValuePair<string, string> header in headers)
                    {
                        conn.Headers.Add(header.Key, header.Value);
                    }
                }

                // authenticate
                IAuthenticationProvider authProvider = session.GetAuthenticationProvider();
                if (authProvider != null)
                {
                    conn.PreAuthenticate = true;
                    authProvider.Authenticate(conn);
                }

                // range
                if (offset != null && length != null)
                {
                    if (offset < Int32.MaxValue && offset + length - 1 < Int32.MaxValue)
                    {
                        conn.AddRange((int)offset, (int)offset + (int)length - 1);
                    }
                    else
                    {
                        try
                        {
                            MethodInfo mi = conn.GetType().GetMethod("AddRange", new Type[] { typeof(Int64), typeof(Int64) });
                            mi.Invoke(conn, new object[] { offset, offset + length - 1 });
                        }
                        catch (Exception e)
                        {
                            throw new CmisInvalidArgumentException("Offset or length too big!", e);
                        }
                    }
                }
                else if (offset != null)
                {
                    if (offset < Int32.MaxValue)
                    {
                        conn.AddRange((int)offset);
                    }
                    else
                    {
                        try
                        {
                            MethodInfo mi = conn.GetType().GetMethod("AddRange", new Type[] { typeof(Int64) });
                            mi.Invoke(conn, new object[] { offset });
                        }
                        catch (Exception e)
                        {
                            throw new CmisInvalidArgumentException("Offset too big!", e);
                        }
                    }
                }

                // compression
                string compressionFlag = session.GetValue(SessionParameter.Compression) as string;
                if (compressionFlag != null && compressionFlag.ToLower().Equals("true"))
                {
                    conn.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                }

                // send data
                if (writer != null)
                {
                    conn.SendChunked = true;
                    Stream requestStream = conn.GetRequestStream();
                    writer(requestStream);
                    requestStream.Close();
                }
                else
                {
            #if __MonoCS__
                    //around for MONO HTTP DELETE issue
                    //http://stackoverflow.com/questions/11785597/monotouch-iphone-call-to-httpwebrequest-getrequeststream-connects-to-server
                    if (method == "DELETE")
                    {
                        conn.ContentLength = 0;
                        Stream requestStream = conn.GetRequestStream();
                        requestStream.Close();
                    }
            #endif
                }

                // connect
                try
                {
                    HttpWebResponse response = (HttpWebResponse)conn.GetResponse();

                    if (authProvider != null)
                    {
                        authProvider.HandleResponse(response);
                    }

                    return new Response(response);
                }
                catch (WebException we)
                {
                    return new Response(we);
                }
            }
            catch (Exception e)
            {
                throw new CmisConnectionException("Cannot access " + url + ": " + e.Message, e);
            }
        }
Example #18
0
 public BindingRepositoryService(BindingSession session)
 {
     this.session = session;
 }
Example #19
0
 public static Response InvokeGET(UrlBuilder url, BindingSession session, long? offset, long? length)
 {
     return Invoke(url, "GET", null, null, session, offset, length, null);
 }
Example #20
0
        private static IDictionary<string, object> GetServiceDictionary(BindingSession session)
        {
            if (Services == null)
            {
                Services = new Dictionary<int, IDictionary<string, object>>();
            }

            IDictionary<string, object> serviceDict;
            if (Services.TryGetValue(session.GetHashCode(), out serviceDict))
            {
                return serviceDict;
            }

            serviceDict = new Dictionary<string, object>();
            Services[session.GetHashCode()] = serviceDict;

            return serviceDict;
        }
Example #21
0
 public static Response InvokePOST(UrlBuilder url, String contentType, Output writer, BindingSession session)
 {
     return Invoke(url, "POST", contentType, writer, session, null, null, null);
 }
Example #22
0
 public PolicyService(BindingSession session, PortProvider provider)
 {
     Session = session;
     Provider = provider;
 }
Example #23
0
 public static Response InvokeDELETE(UrlBuilder url, BindingSession session)
 {
     return Invoke(url, "DELETE", null, null, session, null, null, null);
 }
Example #24
0
 public RepositoryService(BindingSession session, PortProvider provider)
 {
     Session = session;
     Provider = provider;
 }
Example #25
0
 public static Response InvokeGET(UrlBuilder url, BindingSession session)
 {
     return(Invoke(url, "GET", null, null, session, null, null, null));
 }
Example #26
0
        public void Dispose()
        {
            CheckSession();

            session.Lock();
            try
            {
                GetSpi().Dispose();
            }
            finally
            {
                session.Unlock();
                session = null;
            }
        }
Example #27
0
 public static Response InvokePOST(UrlBuilder url, String contentType, Output writer, BindingSession session)
 {
     return(Invoke(url, "POST", contentType, writer, session, null, null, null));
 }
Example #28
0
        private static Response Invoke(UrlBuilder url, String method, String contentType, Output writer, BindingSession session,
                int? offset, int? length, IDictionary<string, string> headers)
        {
            try
            {
                // log before connect
                if (DotCMISDebug.DotCMISSwitch.TraceInfo)
                {
                    Trace.WriteLine(method + " " + url);
                }

                // create connection           
                HttpWebRequest conn = (HttpWebRequest)WebRequest.Create(url.Url);
                conn.Method = method;
                conn.UserAgent = "Apache Chemistry DotCMIS";

                // timeouts
                int connectTimeout = session.GetValue(SessionParameter.ConnectTimeout, -2);
                if (connectTimeout >= -1)
                {
                    conn.Timeout = connectTimeout;
                }

                int readTimeout = session.GetValue(SessionParameter.ReadTimeout, -2);
                if (readTimeout >= -1)
                {
                    conn.ReadWriteTimeout = readTimeout;
                }

                // set content type
                if (contentType != null)
                {
                    conn.ContentType = contentType;
                }

                // set additional headers
                if (headers != null)
                {
                    foreach (KeyValuePair<string, string> header in headers)
                    {
                        conn.Headers.Add(header.Key, header.Value);
                    }
                }

                // authenticate
                IAuthenticationProvider authProvider = session.GetAuthenticationProvider();
                if (authProvider != null)
                {
                    conn.PreAuthenticate = true;
                    authProvider.Authenticate(conn);
                }

                // range
                if (offset != null && length != null)
                {
                    conn.AddRange(offset ?? 0, offset + length - 1 ?? 0);
                }
                else if (offset != null)
                {
                    conn.AddRange(offset ?? 0);
                }

                // compression
                string compressionFlag = session.GetValue(SessionParameter.Compression) as string;
                if (compressionFlag != null && compressionFlag.ToLower().Equals("true"))
                {
                    conn.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                }

                // send data
                if (writer != null)
                {
                    conn.SendChunked = true;
                    Stream requestStream = conn.GetRequestStream();
                    writer(requestStream);
                    requestStream.Close();
                }

                // connect
                try
                {
                    HttpWebResponse response = (HttpWebResponse)conn.GetResponse();

                    if (authProvider != null)
                    {
                        authProvider.HandleResponse(response);
                    }

                    return new Response(response);
                }
                catch (WebException we)
                {
                    return new Response(we);
                }
            }
            catch (Exception e)
            {
                throw new CmisConnectionException("Cannot access " + url + ": " + e.Message, e);
            }
        }
Example #29
0
 public static Response InvokeDELETE(UrlBuilder url, BindingSession session)
 {
     return(Invoke(url, "DELETE", null, null, session, null, null, null));
 }
Example #30
0
 public ObjectService(BindingSession session, PortProvider provider)
 {
     Session = session;
     Provider = provider;
 }
Example #31
0
 public NavigationService(BindingSession session, PortProvider provider)
 {
     Session = session;
     Provider = provider;
 }
Example #32
0
        public RepositoryInfoCache(BindingSession session)
        {
            int repCount = session.GetValue(SessionParameter.CacheSizeRepositories, CacheSizeRepositories);
            if (repCount < 1)
            {
                repCount = CacheSizeRepositories;
            }

            cache = new Cache("Repository Info Cache");
            cache.Initialize(new string[] { 
                typeof(DictionaryCacheLevel).FullName + " " + DictionaryCacheLevel.Capacity + "=" + repCount });
        }
Example #33
0
 public BindingRepositoryService(BindingSession session)
 {
     this.session = session;
 }
Example #34
0
        private static Response Invoke(UrlBuilder url, String method, String contentType, Output writer, BindingSession session,
                                       long?offset, long?length, IDictionary <string, string> headers)
        {
            try
            {
                // log before connect
                if (DotCMISDebug.DotCMISSwitch.TraceInfo)
                {
                    Trace.WriteLine(method + " " + url);
                }

                // create connection
                HttpWebRequest conn = (HttpWebRequest)WebRequest.Create(url.Url);
                conn.Method    = method;
                conn.UserAgent = "Apache Chemistry DotCMIS";

                // timeouts
                int connectTimeout = session.GetValue(SessionParameter.ConnectTimeout, -2);
                if (connectTimeout >= -1)
                {
                    conn.Timeout = connectTimeout;
                }

                int readTimeout = session.GetValue(SessionParameter.ReadTimeout, -2);
                if (readTimeout >= -1)
                {
                    conn.ReadWriteTimeout = readTimeout;
                }

                //KaliConseil addition start
                ServicePointManager.DefaultConnectionLimit = 1000;
                conn.ServicePoint.Expect100Continue        = false;
                conn.KeepAlive                 = true;
                conn.Timeout                   = System.Threading.Timeout.Infinite;
                conn.ProtocolVersion           = HttpVersion.Version10;
                conn.AllowWriteStreamBuffering = false;

                if (DotCMIS.ProxyParameters.GlbProxyMode == 0) //No proxy
                {
                    conn.Proxy = null;
                }
                else if (DotCMIS.ProxyParameters.GlbProxyMode == 1) //Autoproxy (IE)
                {
                    IWebProxy webProxy = WebRequest.DefaultWebProxy;
                    webProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
                    conn.Proxy           = webProxy;
                }
                else if (DotCMIS.ProxyParameters.GlbProxyMode == 2) //Custom proxy
                {
                    WebProxy webProxy2 = new WebProxy(DotCMIS.ProxyParameters.GlbProxyURL);
                    webProxy2.BypassProxyOnLocal = false;

                    if (DotCMIS.ProxyParameters.GlbProxyAuthentication)
                    {
                        webProxy2.Credentials = new NetworkCredential(DotCMIS.ProxyParameters.GlbProxyLogin, DotCMIS.ProxyParameters.GlbProxyPassword);
                    }

                    conn.Proxy = webProxy2;
                }
                ////KaliConseil addition end

                // set content type
                if (contentType != null)
                {
                    conn.ContentType = contentType;
                }

                // set additional headers
                if (headers != null)
                {
                    foreach (KeyValuePair <string, string> header in headers)
                    {
                        conn.Headers.Add(header.Key, header.Value);
                    }
                }

                // authenticate
                IAuthenticationProvider authProvider = session.GetAuthenticationProvider();
                if (authProvider != null)
                {
                    conn.PreAuthenticate = true;
                    authProvider.Authenticate(conn);
                }

                // range
                if (offset != null && length != null)
                {
                    if (offset < Int32.MaxValue && offset + length - 1 < Int32.MaxValue)
                    {
                        conn.AddRange((int)offset, (int)offset + (int)length - 1);
                    }
                    else
                    {
                        try
                        {
                            MethodInfo mi = conn.GetType().GetMethod("AddRange", new Type[] { typeof(Int64), typeof(Int64) });
                            mi.Invoke(conn, new object[] { offset, offset + length - 1 });
                        }
                        catch (Exception e)
                        {
                            throw new CmisInvalidArgumentException("Offset or length too big!", e);
                        }
                    }
                }
                else if (offset != null)
                {
                    if (offset < Int32.MaxValue)
                    {
                        conn.AddRange((int)offset);
                    }
                    else
                    {
                        try
                        {
                            MethodInfo mi = conn.GetType().GetMethod("AddRange", new Type[] { typeof(Int64) });
                            mi.Invoke(conn, new object[] { offset });
                        }
                        catch (Exception e)
                        {
                            throw new CmisInvalidArgumentException("Offset too big!", e);
                        }
                    }
                }

                // compression
                string compressionFlag = session.GetValue(SessionParameter.Compression) as string;
                if (compressionFlag != null && compressionFlag.ToLower().Equals("true"))
                {
                    conn.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                }

                // send data
                if (writer != null)
                {
                    conn.SendChunked = true;
                    System.IO.Stream requestStream = conn.GetRequestStream();
                    writer(requestStream);
                    requestStream.Close();
                }
                else
                {
#if __MonoCS__
                    //around for MONO HTTP DELETE issue
                    //http://stackoverflow.com/questions/11785597/monotouch-iphone-call-to-httpwebrequest-getrequeststream-connects-to-server
                    if (method == "DELETE")
                    {
                        conn.ContentLength = 0;
                        Stream requestStream = conn.GetRequestStream();
                        requestStream.Close();
                    }
#endif
                }

                // connect
                try
                {
                    HttpWebResponse response = (HttpWebResponse)conn.GetResponse();

                    if (authProvider != null)
                    {
                        authProvider.HandleResponse(response);
                    }

                    return(new Response(response));
                }
                catch (WebException we)
                {
                    return(new Response(we));
                }
            }
            catch (Exception e)
            {
                throw new CmisConnectionException("Cannot access " + url + ": " + e.Message, e);
            }
        }