public writeSuccess ( string content_type = "text/html" ) : void | ||
content_type | string | |
return | void |
public override void handleGETRequest(HttpProcessor p) { string contextPath = p.ContextPath; Dictionary <String, String> properties = p.Properties; if (p.http_url.Equals("/Test.png")) { Stream fs = File.Open("../../Test.png", FileMode.Open); p.writeSuccess("image/png"); fs.CopyTo(p.outputStream.BaseStream); p.outputStream.BaseStream.Flush(); } Console.WriteLine("request: {0}", p.http_url); p.writeSuccess(); p.outputStream.WriteLine("<html><body><h1>test server</h1>"); p.outputStream.WriteLine("Current Time: " + DateTime.Now); p.outputStream.WriteLine("url : {0}", p.http_url); p.outputStream.WriteLine("<form method=post action=/form>"); p.outputStream.WriteLine("<input type=text name=foo value=foovalue>"); p.outputStream.WriteLine("<input type=submit name=bar value=barvalue>"); p.outputStream.WriteLine("</form>"); }
public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData) { Console.WriteLine("POST request: {0}", p.http_url); string data = inputData.ReadToEnd(); p.writeSuccess(); 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 ) { try { string contextPath = p.ContextPath; if ("/document".Equals( contextPath )) { processDocument( p ); } else if (contextPath.StartsWith( "/tsf" )) { processTSF( p ); } else { Dictionary<String, String> properties = p.Properties; p.writeSuccess(); p.outputStream.WriteLine( "<html><body><h1>Test Document Server (GET)</h1>" ); p.outputStream.WriteLine( "Current Time: " + DateTime.Now ); p.outputStream.WriteLine( "url : {0}", p.http_url ); p.outputStream.WriteLine( "context: {0}", contextPath ); p.outputStream.WriteLine( "<table>" ); foreach (string key in properties.Keys) { p.outputStream.WriteLine( "\t<tr>" ); p.outputStream.Write( "\t\t<td>" ); p.outputStream.Write( properties[key] ); p.outputStream.Write( "\t\t</td>" ); p.outputStream.WriteLine( "\t<;tr>" ); } p.outputStream.WriteLine( "</table>" ); } } catch (Exception e) { //p.writeFailure(); p.outputStream.WriteLine( "<html><body style=\"color:red\"><h1>Error</h1><p>" ); p.outputStream.WriteLine( e.Message ); p.outputStream.WriteLine( "</p></body></html>" ); } }
public override void handlePOSTRequest( HttpProcessor p, StreamReader inputData ) { Console.WriteLine( "POST request: {0}", p.http_url ); string data = inputData.ReadToEnd(); p.writeSuccess(); 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 ) { string contextPath = p.ContextPath; Dictionary<String, String> properties = p.Properties; if (p.http_url.Equals( "/Test.png" )) { Stream fs = File.Open( "../../Test.png", FileMode.Open ); p.writeSuccess( "image/png" ); fs.CopyTo( p.outputStream.BaseStream ); p.outputStream.BaseStream.Flush(); } Console.WriteLine( "request: {0}", p.http_url ); p.writeSuccess(); p.outputStream.WriteLine( "<html><body><h1>test server</h1>" ); p.outputStream.WriteLine( "Current Time: " + DateTime.Now ); p.outputStream.WriteLine( "url : {0}", p.http_url ); p.outputStream.WriteLine( "<form method=post action=/form>" ); p.outputStream.WriteLine( "<input type=text name=foo value=foovalue>" ); p.outputStream.WriteLine( "<input type=submit name=bar value=barvalue>" ); p.outputStream.WriteLine( "</form>" ); }