Пример #1
0
        public void Configure(Server server, int port, string virtualPath, string physicalPath)
        {
            _server = server;

            _port = port;
            _installPath = null;
            _virtualPath = virtualPath;

            _lowerCasedVirtualPath = CultureInfo.InvariantCulture.TextInfo.ToLower(_virtualPath);
            _lowerCasedVirtualPathWithTrailingSlash = virtualPath.EndsWith("/", StringComparison.Ordinal) ? virtualPath : virtualPath + "/";
            _lowerCasedVirtualPathWithTrailingSlash = CultureInfo.InvariantCulture.TextInfo.ToLower(_lowerCasedVirtualPathWithTrailingSlash);
            _physicalPath = physicalPath;
        }
Пример #2
0
 public Request(Server server, Host host, Connection connection)
     : base(String.Empty, String.Empty, null)
 {
     _server = server;
     _host = host;
     _connection = connection;
 }
Пример #3
0
        public bool StopWebServer()
        {
            bool stopped = false;

            if (_server != null) {
                try {
                    _server.Stop();
                    stopped = true;
                }
                catch {
                }
                _server = null;
            }
            return stopped;
        }
Пример #4
0
        public bool StartWebServer(string webRoot, int port)
        {
            if (_server != null) {
                throw new InvalidOperationException("The server has already been started.");
            }
            if (String.IsNullOrEmpty(webRoot)) {
                throw new ArgumentNullException("webRoot");
            }
            if (Directory.Exists(webRoot) == false) {
                throw new ArgumentException("Invalid directory specified as the web root.", "webRoot");
            }

            bool started = false;
            try {
                Server server = new Server(port, "/", webRoot);
                server.Start();

                _server = server;
                started = true;
            }
            catch (Exception e) {
                throw new InvalidOperationException("Failed to start server.", e);
            }

            if (started) {
                UriBuilder uriBuilder = new UriBuilder();
                uriBuilder.Scheme = "http";
                uriBuilder.Host = "localhost";
                uriBuilder.Port = port;

                _rootUri = uriBuilder.Uri;
            }

            return started;
        }
Пример #5
0
 internal Connection(Server server, Socket socket)
 {
     _server = server;
     _socket = socket;
 }