using System; using System.Net; using System.IO; using System.Net.Sockets; class X { static void Main () { HttpListener l = new HttpListener (); l.Prefixes.Add ("http://localhost:8081/"); l.Start (); l.BeginGetContext (callback, l); Console.WriteLine ("Now hit this with curl, like this: curl -H 'Content-Type: text/xml' -d @mindtouch.host/show-headers.startup.xml http://localhost:8081/"); Console.ReadLine (); } static void callback (IAsyncResult ar) { Console.WriteLine ("Got a connection"); HttpListener l = (HttpListener) ar.AsyncState; HttpListenerContext c = l.EndGetContext (ar); HttpListenerRequest request = c.Request; StreamReader r = new StreamReader (request.InputStream); r.ReadToEnd (); c.Response.OutputStream.WriteByte (65); c.Response.OutputStream.Flush (); c.Response.Close (); Console.WriteLine ("Done"); l.Close (); } }