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; }
public Request(Server server, Host host, Connection connection) : base(String.Empty, String.Empty, null) { _server = server; _host = host; _connection = connection; }
public bool StopWebServer() { bool stopped = false; if (_server != null) { try { _server.Stop(); stopped = true; } catch { } _server = null; } return stopped; }
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; }
internal Connection(Server server, Socket socket) { _server = server; _socket = socket; }