public void HandleConnectProtocol(HTTP2ConnectProtocolInfo info)
 {
     HTTPManager.Logger.Information(typeof(HostDefinition).Name, string.Format("Received HandleConnectProtocol message. Connect protocol for host {0}. Enabled: {1}", info.Host, info.Enabled));
 }
Beispiel #2
0
        internal static void ProcessQueue()
        {
#if !BESTHTTP_DISABLE_COOKIES
            bool saveCookieLibrary = false;
#endif

#if !BESTHTTP_DISABLE_CACHING
            bool saveCacheLibrary = false;
#endif

            PluginEventInfo pluginEvent;
            while (pluginEvents.TryDequeue(out pluginEvent))
            {
                if (HTTPManager.Logger.Level == Loglevels.All)
                {
                    HTTPManager.Logger.Information("PluginEventHelper", "Processing plugin event: " + pluginEvent.ToString());
                }

                if (OnEvent != null)
                {
                    try
                    {
                        OnEvent(pluginEvent);
                    }
                    catch (Exception ex)
                    {
                        HTTPManager.Logger.Exception("PluginEventHelper", "ProcessQueue", ex);
                    }
                }

                switch (pluginEvent.Event)
                {
#if !BESTHTTP_DISABLE_COOKIES
                case PluginEvents.SaveCookieLibrary:
                    saveCookieLibrary = true;
                    break;
#endif

#if !BESTHTTP_DISABLE_CACHING
                case PluginEvents.SaveCacheLibrary:
                    saveCacheLibrary = true;
                    break;
#endif

                case PluginEvents.AltSvcHeader:
                    AltSvcEventInfo altSvcEventInfo = pluginEvent.Payload as AltSvcEventInfo;
                    HostManager.GetHost(altSvcEventInfo.Host)
                    .HandleAltSvcHeader(altSvcEventInfo.Response);
                    break;

                case PluginEvents.HTTP2ConnectProtocol:
                    HTTP2ConnectProtocolInfo info = pluginEvent.Payload as HTTP2ConnectProtocolInfo;
                    HostManager.GetHost(info.Host)
                    .HandleConnectProtocol(info);
                    break;
                }
            }

#if !BESTHTTP_DISABLE_COOKIES
            if (saveCookieLibrary)
            {
                PlatformSupport.Threading.ThreadedRunner.RunShortLiving(Cookies.CookieJar.Persist);
            }
#endif

#if !BESTHTTP_DISABLE_CACHING
            if (saveCacheLibrary)
            {
                PlatformSupport.Threading.ThreadedRunner.RunShortLiving(Caching.HTTPCacheService.SaveLibrary);
            }
#endif
        }