public void OnProcessRequest(ref RequestInfoArgs e)
 {
     EventHandler<RequestInfoArgs> handler = ProcessRequest;
     if (handler != null)
     {
         handler(null, e);
     }
 }
        public void Process()
        {
            // read the request
            if (!TryParseRequest())
            {
                return;
            }

            // #TODO: hook for InterceptRequest - this is a total hack #HACK i say

            var args = new RequestInfoArgs
                           {
                               Body = _body,
                               Url = _url,
                               Verb = _verb,
                               ProcessUser = GetProcessUser(),
                               Protocol = _protocol,
                               QueryString = _queryString
                           };

            _server.OnProcessRequest(ref args);

            string extraHeaders = args.ExtraHeaders;
            if (!string.IsNullOrEmpty(extraHeaders) && !extraHeaders.EndsWith("\r\n"))
            {
                extraHeaders = extraHeaders + "\r\n";
            }

            if (!args.Continue)
            {
                //#TODO: keepalive needs to be determined
                _connection.WriteEntireResponseFromString(200, extraHeaders, args.Response, false);
                return;
            }

            if (!string.IsNullOrEmpty(extraHeaders))
            {
                _responseHeadersBuilder.Append(extraHeaders);
            }

            // 100 response to POST););
            if (_verb == "POST" && _contentLength > 0 && _bodyLength < _contentLength)
            {
                _connection.Write100Continue();
            }
            if (!_host.RequireAuthentication || TryNtlmAuthenticate())
            {
                // special case for client script
                if (_isClientScriptPath)
                {
                    _connection.WriteEntireResponseFromFile(
                        _host.PhysicalClientScriptPath + _path.Substring(_host.NormalizedClientScriptPath.Length), false);
                    return;
                }

                // deny access to code, bin, etc.
                if (IsRequestForRestrictedDirectory())
                {
                    _connection.WriteErrorAndClose(403);
                    return;
                }

                // special case for a request to a directory (ensure / at the end and process default documents)
                if (ProcessDirectoryRequest())
                {
                    return;
                }

                PrepareResponse();

                // Hand the processing over to HttpRuntime
                HttpRuntime.ProcessRequest(this);
            }
        }
        public void Process()
        {
            // read the request
            if (!TryParseRequest())
            {
                return;
            }


            // #TODO: hook for InterceptRequest - this is a total hack #HACK i say

            var args = new RequestInfoArgs
            {
                Body        = _body,
                Url         = _url,
                Verb        = _verb,
                ProcessUser = GetProcessUser(),
                Protocol    = _protocol,
                QueryString = _queryString
            };

            _server.OnProcessRequest(ref args);


            string extraHeaders = args.ExtraHeaders;

            if (!string.IsNullOrEmpty(extraHeaders) && !extraHeaders.EndsWith("\r\n"))
            {
                extraHeaders = extraHeaders + "\r\n";
            }

            if (!args.Continue)
            {
                //#TODO: keepalive needs to be determined
                _connection.WriteEntireResponseFromString(200, extraHeaders, args.Response, false);
                return;
            }



            if (!string.IsNullOrEmpty(extraHeaders))
            {
                _responseHeadersBuilder.Append(extraHeaders);
            }


            // 100 response to POST););
            if (_verb == "POST" && _contentLength > 0 && _bodyLength < _contentLength)
            {
                _connection.Write100Continue();
            }
            if (!_host.RequireAuthentication || TryNtlmAuthenticate())
            {
                // special case for client script
                if (_isClientScriptPath)
                {
                    _connection.WriteEntireResponseFromFile(
                        _host.PhysicalClientScriptPath + _path.Substring(_host.NormalizedClientScriptPath.Length), false);
                    return;
                }

                // deny access to code, bin, etc.
                if (IsRequestForRestrictedDirectory())
                {
                    _connection.WriteErrorAndClose(403);
                    return;
                }

                // special case for a request to a directory (ensure / at the end and process default documents)
                if (ProcessDirectoryRequest())
                {
                    return;
                }


                PrepareResponse();

                // Hand the processing over to HttpRuntime
                HttpRuntime.ProcessRequest(this);
            }
        }