Exemplo n.º 1
0
        public override void ProcessRequest(GTSHTTPURL p_URL, HttpProcessor p)
        {
            Console.WriteLine("[GTSHTTPRequestInfo] Request SYACHI2DS worldexchange INFO");
            Console.WriteLine("[GTSHTTPRequestInfo] " + p_URL.FullURL);
            Console.WriteLine("[GTSHTTPRequestInfo] URLType = " + p_URL.URLType.ToString());

            string vResponse;
            switch (p_URL.URLType)
            {
                case URLType.TokenRequest:
                    // TODO: Return CRYPTO STRING
                    // http://projectpokemon.org/wiki/GTS_protocol
                    //
                    Console.WriteLine("[GTSHTTPRequestInfo] PID =" + p_URL.Parameters["pid"]);
                    vResponse = GTSCrypto.GTSGetToken(p_URL.Parameters["pid"]);
                    p.outputStream.Write(vResponse);
                    break;

                case URLType.Request:
                    // TODO: Return CRYPTO STRING
                    // http://projectpokemon.org/wiki/GTS_protocol
                    //
                    Console.WriteLine("[GTSHTTPRequestInfo] PID =" + p_URL.Parameters["pid"]);
                    vResponse = GTSCrypto.GTSGetToken(p_URL.Parameters["pid"]);
                    p.outputStream.Write(vResponse);
                    break;
                default:
                    Console.WriteLine("[GTSHTTPRequestInfo] ERROR! MALFORMED URL, NEED ONLY ONE PARAMETER");
                    GTSUtil.HTTPError("[GTSHTTPRequestInfo] ERROR! MALFORMED URL, NEED ONLY ONE PARAMETER", p);
                break;
            }
        }
Exemplo n.º 2
0
 public static void HTTPError(string p_Message, HttpProcessor p)
 {
     p.outputStream.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
     p.outputStream.WriteLine("<html>");
     p.outputStream.WriteLine("    ");
     p.outputStream.WriteLine("<head>");
     p.outputStream.WriteLine("		<title>Error Page</title>");
     p.outputStream.WriteLine("</head>");
     p.outputStream.WriteLine("");
     p.outputStream.WriteLine("<body bgcolor=\"#FFFFFF\">");
     p.outputStream.WriteLine(p_Message);
     p.outputStream.WriteLine("</body>");
     p.outputStream.WriteLine("    ");
     p.outputStream.WriteLine("</html>");
 }
Exemplo n.º 3
0
 public void ProcessRequest(HttpProcessor p)
 {
     GTSHTTPURL vURL = new GTSHTTPURL(p.http_url);
     if (vURL.URLType != URLType.Invalid)
     {
         switch (vURL.BaseURLString)
         {
             case "/syachi2ds/web/worldexchange/info.asp":
                 new GTSHTTPRequestInfo().ProcessRequest(vURL, p);
                 break;
             default:
                 new GTSHTTPRequestInvalid().ProcessRequest(vURL, p);
                 break;
         }
     }
 }
Exemplo n.º 4
0
 public override void ProcessRequest(GTSHTTPURL p_URL, HttpProcessor p)
 {
     Console.WriteLine("[GTSHTTPRequestInvalid] INVALID OR UNKNOWN REQUEST");
     Console.WriteLine("[GTSHTTPRequestInvalid] " + p_URL.FullURL);
     GTSUtil.HTTPError("[GTSHTTPRequestInvalid] INVALID OR UNKNOWN REQUEST", p);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Handles a parameter request and returns the http output string.
 /// </summary>
 /// <param name="p_FullURL">full URL String</param>
 /// <param name="p_params">Dictionary of URL Parameters</param>
 /// <param name="p_Router">GTSHTTPRequestRouter using this request</param>
 /// <returns></returns>
 public abstract void ProcessRequest(GTSHTTPURL p_URL, HttpProcessor p);
Exemplo n.º 6
0
 public void listen()
 {
     m_listener = new TcpListener(this.m_ipaddress, this.m_port);
     m_listener.Start();
     while (is_active)
     {
         TcpClient s = m_listener.AcceptTcpClient();
         HttpProcessor processor = new HttpProcessor(s, this);
         Thread thread = new Thread(new ThreadStart(processor.process));
         thread.Start();
         Thread.Sleep(1);
     }
 }
Exemplo n.º 7
0
 public abstract void handlePOSTRequest(HttpProcessor p, StreamReader inputData);
Exemplo n.º 8
0
 public abstract void handleGETRequest(HttpProcessor p);
Exemplo n.º 9
0
        public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
        {
            Console.WriteLine("[MINI-HTTP] POST request: {0}", p.http_url);
            string data = inputData.ReadToEnd();

            p.outputStream.WriteLine("<html><body><h1>test server</h1>");
            p.outputStream.WriteLine("<a href=/test>return</a><p>");
            p.outputStream.WriteLine("postbody: <pre>{0}</pre>", data);
        }
Exemplo n.º 10
0
        public override void handleGETRequest(HttpProcessor p)
        {
            Console.WriteLine("[MINI-HTTP] Request: {0}", p.http_url);
            p.writeSuccess();

            this.m_GTSHTTPRequestRouter.ProcessRequest(p);
        }