Ejemplo n.º 1
0
        SecureSocketStream(IntPtr tls, SocketInfo info, Manos.IO.Libev.IOLoop ioloop)
            : base(info, ioloop)
        {
            this.tls = tls;

            SetHandle (new IntPtr (info.fd));
        }
Ejemplo n.º 2
0
        public IOStream(Manos.IO.Libev.IOLoop ioloop)
        {
            this.ioloop = ioloop;

            TimeOut = TimeSpan.FromMinutes(1);
            Expires = DateTime.UtcNow + TimeOut;
        }
Ejemplo n.º 3
0
        public UdpReceiver( Manos.IO.Libev.IOLoop loop, int maxMessageSize )
        {
            this.loop = loop;

            readBuffer = new byte[maxMessageSize];
            this.maxMessageSize = maxMessageSize;
        }
Ejemplo n.º 4
0
        public Timers( Manos.IO.IOLoop loop, int initialSize = 2 )
        {
            this.loop = loop;
            freeList = new Queue<int>( initialSize );

            growWatchers( initialSize );
        }
Ejemplo n.º 5
0
 public override void OnPreProcessRequest(ManosApp app, Manos.Http.IHttpTransaction transaction, Action complete)
 {
     transaction.Response.ContentEncoding = Encoding.UTF8;
     //transaction.Response.Headers.SetHeader("Content-Type", "text/plain; charset=UTF-8");
     //transaction.Response.Headers.SetHeader("Content-Language", "en");
     transaction.Response.Headers.ContentEncoding = Encoding.UTF8;
     complete();
 }
Ejemplo n.º 6
0
Archivo: main.cs Proyecto: blucz/tood
        static void HandleRequest(Manos.Http.IHttpTransaction tx)
        {
            Console.WriteLine("request path " + tx.Request.Path);
            if (tx.Request.Path == "" || tx.Request.Path == "/") {
                tx.Request.Path = "/index.html";
                HandleRequest(tx);

            } else if (tx.Request.Path.StartsWith("/a/")) {
                HandleApi(tx);

            } else if (tx.Request.Path.StartsWith("/")) {
                HandleStaticFile(tx);

            } else {
                tx.Response.StatusCode = 404;
                tx.Response.End();
                tx.Response.Complete(tx.OnResponseFinished);
            }
        }
Ejemplo n.º 7
0
 public SocketStream(Manos.IO.Libev.IOLoop ioloop)
     : base(ioloop)
 {
 }
Ejemplo n.º 8
0
Archivo: main.cs Proyecto: blucz/tood
 private static void HandleStaticFile(Manos.Http.IHttpTransaction tx)
 {
     string fn = tx.Request.Path;
     while (fn.StartsWith("/"))
         fn = fn.Substring(1);
     string path = __staticdir;
     foreach (var part in fn.Split('/')) {
         if (part == "..") {
             tx.Response.StatusCode = 404;
             tx.Response.End("Not Found");
             tx.Response.Complete(tx.OnResponseFinished);
             return;
         }
         path = Path.Combine(path, part);
     }
     ThreadPool.QueueUserWorkItem(_ => {
         try {
             var bytes = File.ReadAllBytes(path);
             Manos.Threading.Boundary.Instance.ExecuteOnTargetLoop(() => {
                 tx.Response.StatusCode = 200;
                 tx.Response.Headers.SetHeader("Content-Type", _GetContentTypeFromExtension(Path.GetExtension(path)));
                 tx.Response.Headers.ContentLength = bytes.Length;
                 tx.Response.Write(bytes);
                 tx.Response.End();
                 tx.Response.Complete(tx.OnResponseFinished);
             });
         } catch (FileNotFoundException) {
             Manos.Threading.Boundary.Instance.ExecuteOnTargetLoop(() => {
                 tx.Response.StatusCode = 404;
                 tx.Response.End("Not Found");
                 tx.Response.Complete(tx.OnResponseFinished);
             });
         } catch (Exception e) {
             Console.WriteLine("Exception serving static file: " + e);
             Manos.Threading.Boundary.Instance.ExecuteOnTargetLoop(() => {
                 tx.Response.StatusCode = 500;
                 tx.Response.End("Internal Server Error");
                 tx.Response.Complete(tx.OnResponseFinished);
             });
         }
     });
 }
Ejemplo n.º 9
0
Archivo: main.cs Proyecto: blucz/tood
 private static void HandleApi(Manos.Http.IHttpTransaction tx)
 {
     tx.Response.StatusCode = 404;
     tx.Response.End();
     tx.Response.Complete(tx.OnResponseFinished);
 }
Ejemplo n.º 10
0
Archivo: main.cs Proyecto: blucz/tood
        static void _HandleRoot(Manos.Http.IHttpTransaction tx)
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            tx.Response.StatusCode = 200;
            StringBuilder sb = new StringBuilder();

            _conn.Insert("brian", new Cassandra.ColumnParent("users"), new Cassandra.Column("name", "Brian Luczkiewicz", DateTime.UtcNow.Ticks));
            _conn.Insert("brian", new Cassandra.ColumnParent("users"), new Cassandra.Column("email", "*****@*****.**", DateTime.UtcNow.Ticks));

            int count;
            if (!_conn.TryGet("brian", new Cassandra.ColumnPath("users", "visitcount"), out count))
                count = 0;

            count += 1;
            _conn.Insert("brian", new Cassandra.ColumnParent("users"), new Cassandra.Column("visitcount", count, DateTime.UtcNow.Ticks));

            var name = _conn.Get("brian", new Cassandra.ColumnPath("users", "name"));
            var email = _conn.Get("brian", new Cassandra.ColumnPath("users", "email"));

            sb.AppendLine("Name: " + name.Column.Value.ToString());
            sb.AppendLine("Email: " + email.Column.Value.ToString());
            sb.AppendLine("Visit Count: " + count);

            tx.Response.End(sb.ToString());
            tx.Response.Complete(tx.OnResponseFinished);
            sw.Stop();
            Console.WriteLine("services request in " + sw.ElapsedMilliseconds + "ms");
        }
Ejemplo n.º 11
0
 public UdpReceiver( Manos.IO.Libev.IOLoop loop)
     : this(loop, 128 * 1024)
 {
 }
Ejemplo n.º 12
0
 public HttpServer( Manos.Http.HttpConnectionCallback callback )
     : base( callback, Manos.IO.IOLoop.Instance.CreateSocketStream(), true )
 {
 }
Ejemplo n.º 13
0
 public HttpStream(HttpEntity entity, Manos.IO.IByteStream stream)
 {
     HttpEntity = entity;
     SocketStream = stream;
     AddHeaders = true;
 }