コード例 #1
0
        private void OnHttpServerRequest(HttpServerRequest httpRequest, HttpServerResponse httpResponse)
        {
            UrlData     urlData = Url.Parse(httpRequest.Url, /* parseQueryString */ true);
            ServerRoute route   = _router.Match(urlData.PathName);

            Action <Exception> errorHandler = delegate(Exception e) {
                httpResponse.WriteHead(HttpStatusCode.InternalServerError, e.Message);
                httpResponse.End();

                Runtime.TraceInfo("500 : %s %s", httpRequest.Method, httpRequest.Url);
                return;
            };

            ServerRequest         request      = new ServerRequest(httpRequest, urlData, route);
            Task <ServerResponse> responseTask = null;

            try {
                responseTask = _modules[0].ProcessRequest(request);
            }
            catch (Exception e) {
                errorHandler(e);
                return;
            }

            responseTask.Done(delegate(ServerResponse response) {
                response.Write(httpResponse);

                Runtime.TraceInfo("%d : %s %s", response.StatusCode, httpRequest.Method, httpRequest.Url);
            })
            .Fail(errorHandler);
        }
コード例 #2
0
        internal void Write(HttpServerResponse httpResponse)
        {
            httpResponse.WriteHead(_statusCode, _headers);

            if (_content != null)
            {
                httpResponse.Write(_content, Encoding.UTF8);
            }

            httpResponse.End();
        }
コード例 #3
0
ファイル: ServerRuntime.cs プロジェクト: nikhilk/simplecloud
        private void OnHttpServerRequest(HttpServerRequest httpRequest, HttpServerResponse httpResponse)
        {
            UrlData urlData = Url.Parse(httpRequest.Url, /* parseQueryString */ true);
            ServerRoute route = _router.Match(urlData.PathName);

            Action<Exception> errorHandler = delegate(Exception e) {
                httpResponse.WriteHead(HttpStatusCode.InternalServerError, e.Message);
                httpResponse.End();

                Runtime.TraceInfo("500 : %s %s", httpRequest.Method, httpRequest.Url);
                return;
            };

            ServerRequest request = new ServerRequest(httpRequest, urlData, route);
            Task<ServerResponse> responseTask = null;

            try {
                responseTask = _modules[0].ProcessRequest(request);
            }
            catch (Exception e) {
                errorHandler(e);
                return;
            }

            responseTask.Done(delegate(ServerResponse response) {
                response.Write(httpResponse);

                Runtime.TraceInfo("%d : %s %s", response.StatusCode, httpRequest.Method, httpRequest.Url);
            })
            .Fail(errorHandler);
        }
コード例 #4
0
ファイル: ServerResponse.cs プロジェクト: nikhilk/simplecloud
        internal void Write(HttpServerResponse httpResponse)
        {
            httpResponse.WriteHead(_statusCode, _headers);

            if (_content != null) {
                httpResponse.Write(_content, Encoding.UTF8);
            }

            httpResponse.End();
        }