Esempio n. 1
0
        private void Init()
        {
            _sessionStore = _components.Get <IHttpSessionStore>();
            if (_sessionStore == null)
            {
                WriteLog(this, LogPrio.Info, "Defaulting to memory session store.");
                _sessionStore = new MemorySessionStore();
            }

            // add default decoders if none have been added.
            if (FormDecoderProviders.Count == 0)
            {
                WriteLog(
                    this, LogPrio.Info,
                    "Loading UrlDecoder, XmlDecoder and MultipartDecoder, since no decoders have been added.");
                _formDecodersProvider.Add(new UrlDecoder());
                _formDecodersProvider.Add(new MultipartDecoder());
                _formDecodersProvider.Add(new XmlDecoder());
            }

            // Components for building requests.
            if (!_components.Contains(typeof(IRequestParserFactory)))
            {
                _components.Add <IRequestParserFactory, RequestParserFactory>();
            }
            if (!_components.Contains(typeof(IHttpContextFactory)))
            {
                _components.AddInstance <IHttpContextFactory>(
                    new HttpContextFactory(
                        LogWriter, 16384,
                        _components.Get
                        <IRequestParserFactory>()));
            }

            // the special folder does not exist on mono
            string tempPath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);

            if (string.IsNullOrEmpty(tempPath))
            {
                tempPath = "/var/tmp/";
            }
            if (!Directory.Exists(tempPath))
            {
                WriteLog(this, LogPrio.Warning, "Temp path do not exist: " + tempPath);
                return;
            }
            DirectoryInfo info = new DirectoryInfo(tempPath);

            foreach (FileInfo file in info.GetFiles("*.tmp"))
            {
                file.Delete();
            }

            _requestQueue.Start();
        }