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 relPath = Uri.UnescapeDataString(p.http_url); string path = Path.Combine(_htDocsRoot, relPath.TrimStart(new[] { '/', '\\' })); if (File.Exists(path)) { using (Stream fs = File.Open(path, FileMode.Open)) { p.writeSuccess(GetMimeType(Path.GetExtension(path))); fs.CopyTo(p.outputStream.BaseStream); p.outputStream.BaseStream.Flush(); } } else { p.writeFailure(); } }