THRIFT-3833 haxe http server implementation (by embeding into php web server)
Client: Haxe
Patch: Oleksii Prudkyi <Oleksii.Prudkyi@gmail.com> + some modifications by Jens Geyer

This closes #1013
This closes #1020
diff --git a/test/haxe/src/Main.hx b/test/haxe/src/Main.hx
index 30c04a6..9eb828f 100644
--- a/test/haxe/src/Main.hx
+++ b/test/haxe/src/Main.hx
@@ -31,6 +31,15 @@
 class Main
 {
     static function main() {
+        #if phpwebserver
+        initPhpWebServer();
+        //check method
+        if(php.Web.getMethod() != 'POST') {
+          Sys.println('http endpoint for thrift test server');
+          return;
+        }
+        #end
+
         try {
             var args = new Arguments();
 
@@ -48,4 +57,27 @@
         }
     }
 
+    #if phpwebserver
+    private static function initPhpWebServer()
+    {
+        //remap trace to error log
+        haxe.Log.trace = function(v:Dynamic, ?infos:haxe.PosInfos)
+        {
+          // handle trace
+          var newValue : Dynamic;
+          if (infos != null && infos.customParams!=null) {
+            var extra:String = "";
+            for( v in infos.customParams )
+              extra += "," + v;
+            newValue = v + extra;
+          }
+          else {
+            newValue = v;
+          }
+          var msg = infos != null ? infos.fileName + ':' + infos.lineNumber + ': ' : '';
+          Sys.stderr().writeString('${msg}${newValue}\n');
+        }
+    }
+    #end
+
 }