RadioDld.RssServer.GetContextCallback C# (CSharp) Method

GetContextCallback() private method

private GetContextCallback ( IAsyncResult result ) : void
result IAsyncResult
return void
        private void GetContextCallback(IAsyncResult result)
        {
            HttpListener listener = result.AsyncState as HttpListener;
            HttpListenerContext context = listener.EndGetContext(result);

            this.Start();

            switch (context.Request.Url.AbsolutePath)
            {
                case "/":
                    using (StreamWriter writer = new StreamWriter(context.Response.OutputStream))
                    {
                        writer.WriteLine("<!DOCTYPE html><html><head><title>Radio Downloader</title></head>" +
                                         "<body><h1>Radio Downloader</h1>" +
                                         "<p><a href=\"downloaded.rss\">Downloaded epiodes feed</a></p></body></html>");
                    }

                    break;
                case "/downloaded.rss":
                    this.RssFeed(context);
                    break;
                case "/feed-image":
                    this.FeedImageContent(context);
                    break;
                case "/episode-image":
                    this.EpisodeImageContent(context);
                    break;
                case "/file":
                    this.DownloadContent(context);
                    break;
                default:
                    this.ErrorPage404(context);
                    break;
            }

            try
            {
                context.Response.Close();
            }
            catch (InvalidOperationException)
            {
                // Trying to close the stream after a dropped connection
            }
        }