Inheritance: Mono.WebServer.BaseApplicationHost
Beispiel #1
0
        void RunInternal(object state)
        {
            RequestData rdata = initial.RequestData;

            initial.FreeBuffer();
            string vhost = null;             // TODO: read the headers in InitialWorkerRequest
            int    port  = ((IPEndPoint)localEP).Port;

            VPathToHost        vapp = server.GetApplicationForPath(vhost, port, rdata.Path, true);
            XSPApplicationHost host = null;

            if (vapp != null)
            {
                host = (XSPApplicationHost)vapp.AppHost;
            }

            if (host == null)
            {
                byte [] nf = HttpErrors.NotFound(rdata.Path);
                Write(nf, 0, nf.Length);
                Close();
                return;
            }

            broker    = (XSPRequestBroker)vapp.RequestBroker;
            requestId = broker.RegisterRequest(this);

#if MONO
            if (ssl != null)
            {
                SslServerStream s = (stream as SslServerStream);
                ssl.KeySize       = s.CipherStrength;
                ssl.SecretKeySize = s.KeyExchangeStrength;
            }
#endif

            try {
                string redirect;
                vapp.Redirect(rdata.Path, out redirect);
                host.ProcessRequest(requestId, localEP.Address.Address, localEP.Port,
                                    remoteEP.Address.Address, remoteEP.Port, rdata.Verb,
                                    rdata.Path, rdata.QueryString,
                                    rdata.Protocol, rdata.InputBuffer, redirect, sock.Handle, ssl);
            } catch (FileNotFoundException fnf) {
                // We print this one, as it might be a sign of a bad deployment
                // once we require the .exe and Mono.WebServer in bin or the GAC.
                Console.Error.WriteLine(fnf);
            } catch (IOException) {
                // This is ok (including EndOfStreamException)
            } catch (Exception e) {
                Console.Error.WriteLine(e);
            }
        }