public void Handle(HttpListenerContext context, HproseHttpListenerMethods methods)
 {
     currentContext = context;
     try {
         string method = currentContext.Request.HttpMethod;
         if ((method == "GET") && getEnabled)
         {
             DoFunctionList(methods);
         }
         else if (method == "POST")
         {
             base.Handle(methods);
         }
         else
         {
             currentContext.Response.StatusCode = 405;
         }
         if (istream != null)
         {
             istream.Close();
         }
         if (ostream != null)
         {
             ostream.Close();
         }
         currentContext.Response.Close();
     }
     finally {
         istream        = null;
         ostream        = null;
         currentContext = null;
     }
 }
        protected void Handle(HttpListenerContext httpListenerContext, HproseHttpListenerMethods methods)
        {
            HproseHttpListenerContext context = new HproseHttpListenerContext(httpListenerContext);

            SendHeader(context);
            string method = context.Request.HttpMethod;

            if (method == "GET")
            {
                if (getEnabled)
                {
                    MemoryStream            data         = DoFunctionList(methods, context);
                    NonBlockingWriteContext writeContext = new NonBlockingWriteContext();
                    writeContext.currentContext = context;
                    writeContext.ostream        = GetOutputStream(context);
                    writeContext.ostream.BeginWrite(data.GetBuffer(), 0, (int)data.Length,
                                                    new AsyncCallback(NonBlockingWriteCallback), writeContext);
                }
                else
                {
                    context.Response.StatusCode = 403;
                    context.Response.Close();
                }
            }
            else if (method == "POST")
            {
                NonBlockingHandle(context, methods);
            }
            else
            {
                context.Response.Close();
            }
        }
        private void NonBlockingHandle(HttpListenerContext currentContext, HproseHttpListenerMethods methods)
        {
            NonBlockingReadContext context = new NonBlockingReadContext();

            context.currentContext = currentContext;
            context.methods        = methods;
            context.istream        = currentContext.Request.InputStream;
            int len = (int)currentContext.Request.ContentLength64;

            context.data         = (len > 0) ? new MemoryStream(len) : new MemoryStream();
            context.bufferlength = (len > 81920 || len < 0) ? 81920 : len;
            context.buffer       = new byte[context.bufferlength];
            context.istream.BeginRead(context.buffer, 0, context.bufferlength, new AsyncCallback(NonBlockingReadCallback), context);
        }
        protected void Handle(HttpListenerContext httpListenerContext, HproseHttpListenerMethods methods)
        {
            HproseHttpListenerContext context = new HproseHttpListenerContext(httpListenerContext);

            SendHeader(context);
            string method = context.Request.HttpMethod;

            if (method == "GET")
            {
                if (getEnabled)
                {
                    MemoryStream data = DoFunctionList(methods, context);
                    data.WriteTo(GetOutputStream(context));
                }
                else
                {
                    context.Response.StatusCode = 403;
                    context.Response.Close();
                }
            }
            else if (method == "POST")
            {
                int          len    = (int)context.Request.ContentLength64;
                Stream       stream = context.Request.InputStream;
                MemoryStream data   = new MemoryStream();
                int          length = (len > 4096 || len < 0) ? 4096 : len;
                byte[]       buffer = new byte[length];
                for (;;)
                {
                    int n = stream.Read(buffer, 0, length);
                    if (n > 0)
                    {
                        data.Write(buffer, 0, n);
                    }
                    else
                    {
                        break;
                    }
                }
                Handle(data, methods, context).WriteTo(GetOutputStream(context));
            }
            else
            {
                context.Response.Close();
            }
        }
 public void Handle(HttpListenerContext context, HproseHttpListenerMethods methods)
 {
     currentContext = context;
     try {
         string method = currentContext.Request.HttpMethod;
         if ((method == "GET") && getEnabled) {
             DoFunctionList(methods);
         }
         else if (method == "POST") {
             base.Handle(methods);
         }
         else {
             currentContext.Response.StatusCode = 405;
         }
         if (istream != null) istream.Close();
         if (ostream != null) ostream.Close();
         currentContext.Response.Close();
     }
     finally {
         istream = null;
         ostream = null;
         currentContext = null;
     }
 }
 protected void Handle(HttpListenerContext httpListenerContext, HproseHttpListenerMethods methods) {
     HproseHttpListenerContext context = new HproseHttpListenerContext(httpListenerContext);
     SendHeader(context);
     string method = context.Request.HttpMethod;
     if (method == "GET") {
         if (getEnabled) {
             MemoryStream data = DoFunctionList(methods, context);
             NonBlockingWriteContext writeContext = new NonBlockingWriteContext();
             writeContext.currentContext = context;
             writeContext.ostream = GetOutputStream(context);
             writeContext.ostream.BeginWrite(data.GetBuffer(), 0, (int)data.Length,
                 new AsyncCallback(NonBlockingWriteCallback), writeContext);
         }
         else {
             context.Response.StatusCode = 403;
             context.Response.Close();
         }
     }
     else if (method == "POST") {
         NonBlockingHandle(context, methods);
     }
     else {
         context.Response.Close();
     }
 }
 private void NonBlockingHandle(HproseHttpListenerContext currentContext, HproseHttpListenerMethods methods) {
     NonBlockingReadContext context = new NonBlockingReadContext();
     context.currentContext = currentContext;
     context.methods = methods;
     context.istream = currentContext.Request.InputStream;
     int len = (int)currentContext.Request.ContentLength64;
     context.data = (len > 0) ? new MemoryStream(len) : new MemoryStream();
     context.bufferlength = (len > 81920 || len < 0) ? 81920 : len;
     context.buffer = new byte[context.bufferlength];
     context.istream.BeginRead(context.buffer, 0, context.bufferlength, new AsyncCallback(NonBlockingReadCallback), context);
 }