WriteEntireResponseFromFile() public méthode

public WriteEntireResponseFromFile ( String fileName, bool keepAlive ) : void
fileName String
keepAlive bool
Résultat void
Exemple #1
0
        public void Process() {
            // read the request
            if (!TryParseRequest()) {
                return;
            }

            // 100 response to POST
            if (_verb == "POST" && _contentLength > 0 && _preloadedContentLength < _contentLength) {
                _connection.Write100Continue();
            }

            // 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);
        }
Exemple #2
0
        public void Process()
        {
            ReadAllHeaders();

            if (_headerBytes == null || _endHeadersOffset < 0 ||
                _headerByteStrings == null || _headerByteStrings.Count == 0)
            {
                _conn.WriteErrorAndClose(400);
                return;
            }

            ParseRequestLine();

            // Check for bad path
            if (IsBadPath())
            {
                _conn.WriteErrorAndClose(400);
                return;
            }

            // Check if the path is not well formed or is not for the current app
            bool   isClientScriptPath = false;
            String clientScript       = null;

            if (!_host.IsVirtualPathInApp(_path, out isClientScriptPath, out clientScript))
            {
                _conn.WriteErrorAndClose(404);
                return;
            }

            ParseHeaders();

            ParsePostedContent();

            if (_verb == "POST" && _contentLength > 0 && _preloadedContentLength < _contentLength)
            {
                _conn.Write100Continue();
            }

            // special case for client script
            if (isClientScriptPath)
            {
                _conn.WriteEntireResponseFromFile(_host.PhysicalClientScriptPath + clientScript, false);
                return;
            }

            // special case for directory listing
            if (ProcessDirectoryListingRequest())
            {
                return;
            }

            PrepareResponse();

            // Hand the processing over to HttpRuntime

            HttpRuntime.ProcessRequest(this);
        }
Exemple #3
0
        /// <summary>
        /// 01/06/10 sky: added RequestInfo construction
        /// </summary>
        public void Process()
        {
            // read the request
            if (!TryParseRequest())
            {
                return;
            }


            _requestInfo.LocalIP        = GetLocalAddress();
            _requestInfo.RemoteIP       = GetRemoteAddress();
            _requestInfo.RemoteName     = GetRemoteName();
            _requestInfo.Verb           = _verb;
            _requestInfo.Url            = _url;
            _requestInfo.Protocol       = _prot;
            _requestInfo.Path           = _path;
            _requestInfo.FilePath       = _filePath;
            _requestInfo.PathInfo       = _pathInfo;
            _requestInfo.PathTranslated = _pathTranslated;
            _requestInfo.QueryString    = _queryString;
            _requestInfo.ContentLength  = _contentLength;
            _requestInfo.ResponseStatus = _responseStatus;
            int userAgentIndex = GetKnownRequestHeaderIndex("User-Agent");

            if (userAgentIndex > -1)
            {
                _requestInfo.UserAgent = _knownRequestHeaders[userAgentIndex];
            }

            _server.OnRequestBegin(new RequestEventArgs(_requestInfo));

            // 100 response to POST
            if (_verb == "POST" && _contentLength > 0 && _preloadedContentLength < _contentLength)
            {
                _connection.Write100Continue();
            }

            // 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);
        }