Ejemplo n.º 1
0
 public override void CloseConnection()
 {
     if (requestBroker == null)
     {
         return;
     }
     // We check for headersSent as broken user code might call
     // CloseConnection at an early stage.
     requestBroker.Close(requestId, headersSent && keepAlive);
     requestBroker = null;
 }
Ejemplo n.º 2
0
        public XSPWorkerRequest(int requestId,
                                XSPRequestBroker requestBroker,
                                IApplicationHost appHost,
                                EndPoint localEP, EndPoint remoteEP,
                                string verb, string path,
                                string queryString, string protocol,
                                byte[] inputBuffer, IntPtr socket,
                                bool secure)
            : base(appHost)
        {
            this.socket        = socket;
            this.requestId     = requestId;
            this.requestBroker = requestBroker;
            this.remoteEP      = remoteEP;
            this.verb          = verb;
            rawUrl             = path;
            if (!String.IsNullOrEmpty(queryString))
            {
                rawUrl += "?" + queryString;
            }
            try {
                Paths.GetPathsFromUri(appHost, verb, path, out this.path, out pathInfo);
            } catch {
                CloseConnection();
                throw;
            }

            this.protocol = protocol;
            if (protocol == "HTTP/1.1")
            {
                if (!running_tests)
                {
                    this.protocol = "HTTP/1.0";
                }
                keepAlive = true;
            }

            this.queryString = queryString;
            this.inputBuffer = inputBuffer;
            inputLength      = inputBuffer.Length;
            position         = 0;
            this.secure      = secure;

            try {
                GetRequestHeaders();
            } catch {
                CloseConnection();
                throw;
            }

            var cncHeader = (string)headers ["Connection"];

            if (cncHeader != null)
            {
                cncHeader = cncHeader.ToLower();
                if (cncHeader.IndexOf("keep-alive") != -1)
                {
                    keepAlive = true;
                }

                if (cncHeader.IndexOf("close") != -1)
                {
                    keepAlive = false;
                }
            }

            if (secure)
            {
                keepAlive = false;                 //FIXME: until the NetworkStream don't own the socket for ssl streams.
            }
            responseHeaders   = new StringBuilder();
            statusCode        = 200;
            statusDescription = "OK";

            localPort    = ((IPEndPoint)localEP).Port;
            localAddress = ((IPEndPoint)localEP).Address.ToString();
        }