public override void HandlePostRequest(HttpProcessor p, StreamReader inputData)
 {
     p.WriteSuccess();
 }
 public abstract void HandlePostRequest(HttpProcessor p, StreamReader inputData);
        public override void HandleGetRequest(HttpProcessor p)
        {
            p.WriteSuccess();
            if (p.HttpUrl == "/favicon.ico")
            {
                return;
            }

            Thread t;

            if (_type == AuthType.Authorization)
            {
                string url = p.HttpUrl;
                url = url.Substring(2, url.Length - 2);
                NameValueCollection col = HttpUtility.ParseQueryString(url);
                if (col.Keys.Get(0) != "code")
                {
                    p.OutputStream.WriteLine("<html><body><h1>Spotify Auth canceled!</h1></body></html>");
                    t = new Thread(o =>
                    {
                        OnAuth?.Invoke(new AuthEventArgs()
                        {
                            State = col.Get(1),
                            Error = col.Get(0),
                        });
                    });
                }
                else
                {
                    p.OutputStream.WriteLine("<html><body><h1>Spotify Auth successful!</h1><script>window.close();</script></body></html>");
                    t = new Thread(o =>
                    {
                        OnAuth?.Invoke(new AuthEventArgs()
                        {
                            Code  = col.Get(0),
                            State = col.Get(1)
                        });
                    });
                }
            }
            else
            {
                if (p.HttpUrl == "/")
                {
                    p.OutputStream.WriteLine("<html><body>" +
                                             "<script>" +
                                             "" +
                                             "var hashes = window.location.hash;" +
                                             "hashes = hashes.replace('#','&');" +
                                             "window.location = hashes" +
                                             "</script>" +
                                             "<h1>Spotify Auth successful!<br>Please copy the URL and paste it into the application</h1></body></html>");
                    p.OutputStream.Flush();
                    p.OutputStream.Close();
                    return;
                }
                string url = p.HttpUrl;
                url = url.Substring(2, url.Length - 2);
                NameValueCollection col = HttpUtility.ParseQueryString(url);
                if (col.Keys.Get(0) != "access_token")
                {
                    p.OutputStream.WriteLine("<html><body><h1>Spotify Auth canceled!</h1></body></html>");
                    t = new Thread(o =>
                    {
                        OnAuth?.Invoke(new AuthEventArgs()
                        {
                            Error = col.Get(0),
                            State = col.Get(1)
                        });
                    });
                }
                else
                {
                    p.OutputStream.WriteLine("<html><body><h1>Spotify Auth successful!</h1><script>window.close();</script></body></html>");
                    t = new Thread(o =>
                    {
                        OnAuth?.Invoke(new AuthEventArgs()
                        {
                            Code      = col.Get(0),
                            TokenType = col.Get(1),
                            ExpiresIn = Convert.ToInt32(col.Get(2)),
                            State     = col.Get(3)
                        });
                    });
                    p.OutputStream.Flush();
                    p.OutputStream.Close();
                }
            }


            t.Start();
        }
 public abstract void HandleGetRequest(HttpProcessor p);