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; } }
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>"); }
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; } } }
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); }
/// <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);
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); } }
public abstract void handlePOSTRequest(HttpProcessor p, StreamReader inputData);
public abstract void handleGETRequest(HttpProcessor p);
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); }
public override void handleGETRequest(HttpProcessor p) { Console.WriteLine("[MINI-HTTP] Request: {0}", p.http_url); p.writeSuccess(); this.m_GTSHTTPRequestRouter.ProcessRequest(p); }