THRIFT-322 IHttpHandler for Thrift
Patch: Nils Huegelmann

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1164723 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/csharp/src/Transport/THttpHandler.cs b/lib/csharp/src/Transport/THttpHandler.cs
index 7fe750d..0a10d79 100644
--- a/lib/csharp/src/Transport/THttpHandler.cs
+++ b/lib/csharp/src/Transport/THttpHandler.cs
@@ -9,6 +9,8 @@
 
 using System;
 using System.Web;
+using System.Net;
+using System.IO;
 
 using Thrift.Protocol;
 
@@ -21,6 +23,9 @@
         protected TProtocolFactory inputProtocolFactory;
         protected TProtocolFactory outputProtocolFactory;
 
+        protected const string contentType = "application/x-thrift";
+        protected System.Text.Encoding encoding = System.Text.Encoding.UTF8;
+
         public THttpHandler(TProcessor processor)
             : this(processor, new TBinaryProtocol.Factory())
         {
@@ -40,12 +45,23 @@
             this.outputProtocolFactory = outputProtocolFactory;
         }
 
+        public void ProcessRequest(HttpListenerContext context)
+        {
+            context.Response.ContentType = contentType;
+            context.Response.ContentEncoding = encoding;
+            ProcessRequest(context.Request.InputStream, context.Response.OutputStream);
+        }
+
         public void ProcessRequest(HttpContext context)
         {
-            context.Response.ContentType = "application/x-thrift";
-            context.Response.ContentEncoding = System.Text.Encoding.UTF8;
+            context.Response.ContentType = contentType;
+            context.Response.ContentEncoding = encoding;
+            ProcessRequest(context.Request.InputStream, context.Response.OutputStream);
+        }
 
-            TTransport transport = new TStreamTransport(context.Request.InputStream, context.Response.OutputStream);
+        public void ProcessRequest(Stream input, Stream output)
+        {
+            TTransport transport = new TStreamTransport(input,output);
 
             TProtocol inputProtocol = null;
             TProtocol outputProtocol = null;