Beispiel #1
0
 /// <summary>
 /// Construct server with given port.
 /// </summary>
 /// <param name="path">Directory path to serve.</param>
 /// <param name="port">Port of the server.</param>
 public SimpleHTTPServer(IPrimaryHostWindow primaryHost, Settings settings,
                         string path, int port, MimeTypeMappings mappings)
 {
     _primaryHost = primaryHost;
     _settings    = settings;
     _mappings    = mappings;
     this.Initialize(path, port);
 }
Beispiel #2
0
        /// <summary>
        /// Construct server with suitable port.
        /// </summary>
        /// <param name="path">Directory path to serve.</param>
        public SimpleHTTPServer(IPrimaryHostWindow primaryHost, Settings settings,
                                string path, MimeTypeMappings mappings)
        {
            _mappings = mappings;

            //get an empty port
            TcpListener l = new TcpListener(IPAddress.Loopback, 0);

            l.Start();
            int port = ((IPEndPoint)l.LocalEndpoint).Port;

            l.Stop();
            this.Initialize(path, port);
        }
        public static MimeTypeMappings Load(string filename)
        {
            MimeTypeMappings mappings = new MimeTypeMappings();

            if (File.Exists(filename))
            {
                XmlSerializer s = new XmlSerializer(typeof(MimeTypeMappings));
                TextReader    r = new StreamReader(filename);
                mappings = (MimeTypeMappings)s.Deserialize(r);
                r.Close();
            }
            else
            {
                mappings.Save(filename);
            }

            return(mappings);
        }