예제 #1
0
파일: HttpRequest.cs 프로젝트: koush/manos
 public HttpRequest(IHttpTransaction transaction, SocketStream stream)
 {
     Transaction = transaction;
     Socket = stream;
     RemoteAddress = stream.Address;
     RemotePort = stream.Port;
 }
예제 #2
0
 public HttpRequest(IHttpTransaction transaction, SocketStream stream)
 {
     Transaction   = transaction;
     Socket        = stream;
     RemoteAddress = stream.Address;
     RemotePort    = stream.Port;
 }
예제 #3
0
 public HttpRequest(IHttpTransaction transaction, Socket stream)
     : base(transaction.Context)
 {
     Transaction = transaction;
     Socket = stream;
     RemoteAddress = stream.Address;
     RemotePort = stream.Port;
 }
예제 #4
0
 public HttpRequest(IHttpTransaction transaction, ITcpSocket stream)
     : base(transaction.Context)
 {
     Transaction   = transaction;
     Socket        = stream;
     RemoteAddress = stream.RemoteEndpoint.Address.ToString();
     RemotePort    = stream.RemoteEndpoint.Port;
 }
예제 #5
0
 public HttpRequest(IHttpTransaction transaction, ITcpSocket stream)
     : base(transaction.Context)
 {
     Transaction = transaction;
     Socket = stream;
     RemoteAddress = stream.RemoteEndpoint.Address.ToString();
     RemotePort = stream.RemoteEndpoint.Port;
 }
예제 #6
0
파일: HttpRequest.cs 프로젝트: kersny/manos
 public HttpRequest(IHttpTransaction transaction, Socket stream)
     : base(transaction.Context)
 {
     Transaction   = transaction;
     Socket        = stream;
     RemoteAddress = stream.Address;
     RemotePort    = stream.Port;
 }
예제 #7
0
파일: Pipeline.cs 프로젝트: vbatz258/manos
        public Pipeline(ManosApp app, IHttpTransaction transaction)
        {
            this.app = app;
            this.transaction = transaction;

            pending = AppHost.Pipes == null ? 1 : AppHost.Pipes.Count;
            step = PipelineStep.PreProcess;
            handle = GCHandle.Alloc (this);

            transaction.Response.OnEnd += HandleEnd;
        }
예제 #8
0
파일: ManosApp.cs 프로젝트: KevinT/manos
 public void OnPostProcessRequest(ManosApp app, IHttpTransaction transaction)
 {
     foreach (IManosPipe pipe in AppHost.Pipes) {
         try {
             pipe.OnPostProcessRequest (this, transaction);
         } catch (Exception e) {
             Console.Error.WriteLine ("Exception in {0}::OnPostProcessRequest.", pipe);
             Console.Error.WriteLine (e);
         }
     }
 }
예제 #9
0
        public HttpRequest(IHttpTransaction transaction, HttpHeaders headers, string method, string resource, bool support_1_1)
        {
            Transaction = transaction;
            Headers = headers;
            Method = method;
            ResourceUri = resource;
            Http_1_1_Supported = support_1_1;

            SetEncoding ();
            SetPathAndQuery ();
        }
예제 #10
0
파일: Pipeline.cs 프로젝트: txdv/manos
        public Pipeline(ManosApp app, IHttpTransaction transaction)
        {
            this.app         = app;
            this.transaction = transaction;

            pending = AppHost.Pipes == null ? 1 : AppHost.Pipes.Count;
            step    = PipelineStep.PreProcess;
            handle  = GCHandle.Alloc(this);

            transaction.Response.OnEnd += HandleEnd;
        }
예제 #11
0
        public HttpResponse(IHttpTransaction transaction, SocketStream stream)
        {
            Transaction = transaction;
            Socket      = stream;

            StatusCode = 200;

            WriteHeaders = true;

            Stream         = new HttpStream(this, stream);
            Stream.Chunked = (transaction.Request.MajorVersion > 0 && transaction.Request.MinorVersion > 0);
        }
예제 #12
0
        public HttpResponse(IHttpTransaction transaction, SocketStream stream)
        {
            Transaction = transaction;
            Socket = stream;

            StatusCode = 200;

            WriteHeaders = true;

            Stream = new HttpStream (this, stream);
            Stream.Chunked = (transaction.Request.MajorVersion > 0 && transaction.Request.MinorVersion > 0);
        }
예제 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpRequest"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        internal HttpRequest(IHttpTransaction source)
        {
            if (source is HttpClient)
                this.client = (HttpClient)source;
            else
                this.connection = (HttpConnection)source;

            this.headers = new HttpHeaderCollection();
            this.query = new Dictionary<string, string>();
            this.version = "";
            this.path = "";
        }
예제 #14
0
파일: ManosApp.cs 프로젝트: debackerl/manos
        public void HandleTransaction(ManosApp app, IHttpTransaction con)
        {
            bool end = false;

            if (con == null)
                throw new ArgumentNullException ("con");

            OnPreProcessRequest (this, con);
            if (con.Aborted)
                goto cleanup;

            var ctx = new ManosContext (con);

            var handler = OnPreProcessTarget (ctx);
            if (handler == null)
                handler = Routes.Find (con.Request);

            if (handler == null) {
                Console.WriteLine ("no handler found for: '{0}'", ctx.Request.LocalPath);
                con.Response.StatusCode = 404;
                con.Response.End ();
                return;
            }

            con.Response.StatusCode = 200;

            OnPostProcessTarget (ctx, handler);

            try {
                handler.Invoke (app, new ManosContext (con));
            } catch (Exception e) {
                Console.Error.WriteLine ("Exception in transaction handler:");
                Console.Error.WriteLine (e);
                con.Response.StatusCode = 500;
                //
                // TODO: Maybe the cleanest thing to do is
                // have a HandleError, HandleException thing
                // on HttpTransaction, along with an UnhandledException
                // method/event on ManosModule.
                //
                end = true;
            }

            if (con.Response.StatusCode == 404)
                con.Response.End ();

            cleanup:
            OnPostProcessRequest (this, con);

            if (end)
                con.Response.End ();
        }
예제 #15
0
파일: HttpResponse.cs 프로젝트: emiaj/manos
        public HttpResponse(IHttpTransaction transaction, Encoding encoding)
        {
            Transaction = transaction;
            Encoding = encoding;

            StatusCode = 200;

            WriteHeaders = true;
            WriteStatusLine = true;

            Headers = new HttpHeaders ();
            SetStandardHeaders ();
        }
예제 #16
0
        public HttpResponse(IHttpTransaction transaction)
        {
            Transaction = transaction;

            StatusCode = 200;

            WriteHeaders = true;

            Headers = new HttpHeaders ();
            Stream = new HttpResponseStream ();
            Writer = new StreamWriter (Stream);
            Cookies = new Dictionary<string, HttpCookie> ();

            SetStandardHeaders ();
        }
예제 #17
0
        public HttpResponse(IHttpTransaction transaction, IOStream stream)
        {
            Transaction = transaction;
            IOStream = stream;

            StatusCode = 200;

            WriteHeaders = true;

            Headers = new HttpHeaders ();
            Stream = new HttpResponseStream (this, IOStream);
            Stream.Chunked = (transaction.Request.MajorVersion > 0 && transaction.Request.MinorVersion > 0);

            end_watcher = new AsyncWatcher (IOLoop.Instance.EventLoop, OnEnd);
            end_watcher.Start ();
        }
예제 #18
0
파일: HttpResponse.cs 프로젝트: silk/manos
        public HttpResponse(IHttpTransaction transaction, Encoding encoding)
        {
            Transaction = transaction;
            Encoding = encoding;

            StatusCode = 200;

            WriteHeaders = true;
            WriteStatusLine = true;

            Headers = new HttpHeaders ();
            Stream = new HttpResponseStream ();
            Cookies = new Dictionary<string, HttpCookie> ();

            SetStandardHeaders ();
        }
예제 #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpRequest"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        internal HttpRequest(IHttpTransaction source)
        {
            if (source is HttpClient)
            {
                this.client = (HttpClient)source;
            }
            else
            {
                this.connection = (HttpConnection)source;
            }

            this.headers = new HttpHeaderCollection();
            this.query   = new Dictionary <string, string>();
            this.version = "";
            this.path    = "";
        }
예제 #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpResponse"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        internal HttpResponse(IHttpTransaction source)
        {
            if (source is HttpClient)
                this.client = (HttpClient)source;
            else
                this.connection = (HttpConnection)source;

            this.status = HttpStatus.OK;
            this.buffer = new MemoryStream();
            this.headers = new HttpHeaderCollection();

            if (source is HttpConnection) {
                headers["Content-Type"] = "text/html";
                headers["X-Frame-Options"] = "deny";
            }
        }
예제 #21
0
        public void OnPostProcessRequest(ManosApp app, IHttpTransaction transaction)
        {
            if (AppHost.Pipes == null)
            {
                return;
            }

            foreach (IManosPipe pipe in AppHost.Pipes)
            {
                try {
                    pipe.OnPostProcessRequest(this, transaction);
                } catch (Exception e) {
                    Console.Error.WriteLine("Exception in {0}::OnPostProcessRequest.", pipe);
                    Console.Error.WriteLine(e);
                }
            }
        }
예제 #22
0
파일: HttpRequest.cs 프로젝트: KevinT/manos
        public HttpRequest(IHttpTransaction transaction, HttpHeaders headers, string method, string resource, bool support_1_1)
        {
            Transaction = transaction;
            Headers = headers;
            Method = method;
            ResourceUri = resource;
            Http_1_1_Supported = support_1_1;

            Data = new DataDictionary ();
            UriData = new DataDictionary ();
            QueryData = new DataDictionary ();
            PostData = new DataDictionary ();

            Data.Children.Add (UriData);
            Data.Children.Add (QueryData);
            Data.Children.Add (PostData);

            SetEncoding ();
            SetPathAndQuery ();
        }
예제 #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HttpResponse"/> class.
        /// </summary>
        /// <param name="source">The source.</param>
        internal HttpResponse(IHttpTransaction source)
        {
            if (source is HttpClient)
            {
                this.client = (HttpClient)source;
            }
            else
            {
                this.connection = (HttpConnection)source;
            }

            this.status  = HttpStatus.OK;
            this.buffer  = new MemoryStream();
            this.headers = new HttpHeaderCollection();

            if (source is HttpConnection)
            {
                headers["Content-Type"]    = "text/html";
                headers["X-Frame-Options"] = "deny";
            }
        }
예제 #24
0
파일: AccessLogger.cs 프로젝트: koush/manos
        public override void OnPostProcessRequest(ManosApp app, IHttpTransaction transaction)
        {
            // LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
            // %h - Remote host       -- DONT HAVE
            // %l - Remote log name   -- DONT HAVE
            // %u - Remote user       -- DONT HAVE
            // %t - Date+Time
            // %r - Request path
            // %s - Status Code
            // %b - Bytes sent
            // %Referer -
            // %User Agent -

            string line = String.Format ("- - - [{0}] \"{1}\" {2} {3} - -\n",
                    DateTime.Now.ToString ("dd/MMM/yyyy:HH:mm:ss K"),
                    transaction.Request.Path,
                    transaction.Response.StatusCode,
                    transaction.Response.Headers.ContentLength);

            byte [] data = Encoding.Default.GetBytes (line);
            stream.BeginWrite (data, 0, data.Length, null, null);
        }
예제 #25
0
        public override void OnPostProcessRequest(ManosApp app, IHttpTransaction transaction)
        {
            // LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
            // %h - Remote host       -- DONT HAVE
            // %l - Remote log name   -- DONT HAVE
            // %u - Remote user       -- DONT HAVE
            // %t - Date+Time
            // %r - Request path
            // %s - Status Code
            // %b - Bytes sent
            // %Referer -
            // %User Agent -

            string line = String.Format("- - - [{0}] \"{1}\" {2} {3} - -\n",
                                        DateTime.Now.ToString("dd/MMM/yyyy:HH:mm:ss K"),
                                        transaction.Request.Path,
                                        transaction.Response.StatusCode,
                                        transaction.Response.Headers.ContentLength);

            byte [] data = Encoding.Default.GetBytes(line);
            stream.BeginWrite(data, 0, data.Length, null, null);
        }
예제 #26
0
파일: ManosApp.cs 프로젝트: headsling/manos
        public void HandleTransaction(ManosApp app, IHttpTransaction con)
        {
            Pipeline pipeline = new Pipeline (app, con);

            pipeline.Begin ();
        }
예제 #27
0
 public virtual void OnPostProcessRequest(ManosApp app, IHttpTransaction transaction, Action complete)
 {
     complete();
 }
예제 #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpFormatException"/> class.
 /// </summary>
 /// <param name="transaction">The transaction.</param>
 public HttpFormatException(IHttpTransaction transaction)
     : base()
 {
     this.transaction = transaction;
 }
예제 #29
0
        public void HandleTransaction(ManosApp app, IHttpTransaction con)
        {
            bool end = false;

            if (con == null)
            {
                throw new ArgumentNullException("con");
            }

            OnPreProcessRequest(this, con);
            if (con.Aborted)
            {
                goto cleanup;
            }

            var ctx = new ManosContext(con);

            var handler = OnPreProcessTarget(ctx);

            if (handler == null)
            {
                handler = Routes.Find(con.Request);
            }

            if (handler == null)
            {
                Console.WriteLine("no handler found for: '{0}'", ctx.Request.Path);
                con.Response.StatusCode = 404;
                con.Response.End();
                return;
            }

            con.Response.StatusCode = 200;

            OnPostProcessTarget(ctx, handler);

            try {
                handler.Invoke(app, new ManosContext(con));
            } catch (Exception e) {
                Console.Error.WriteLine("Exception in transaction handler:");
                Console.Error.WriteLine(e);
                con.Response.StatusCode = 500;
                //
                // TODO: Maybe the cleanest thing to do is
                // have a HandleError, HandleException thing
                // on HttpTransaction, along with an UnhandledException
                // method/event on ManosModule.
                //
                end = true;
            }

            if (con.Response.StatusCode == 404)
            {
                con.Response.End();
            }

cleanup:
            OnPostProcessRequest(this, con);

            if (end)
            {
                con.Response.End();
            }
        }
예제 #30
0
 public ManosContext(IHttpTransaction transaction)
 {
     Transaction = transaction;
 }
예제 #31
0
파일: ManosApp.cs 프로젝트: debackerl/manos
        public void OnPreProcessRequest(ManosApp app, IHttpTransaction transaction)
        {
            if (AppHost.Pipes == null)
                return;

            foreach (IManosPipe pipe in AppHost.Pipes) {
                try {
                    pipe.OnPreProcessRequest (app, transaction);

                    if (transaction.Aborted)
                        return;

                } catch (Exception e) {
                    Console.Error.WriteLine ("Exception in {0}::OnPreProcessRequest.", pipe);
                    Console.Error.WriteLine (e);
                }
            }
        }
예제 #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpFormatException"/> class.
 /// </summary>
 /// <param name="transaction">The transaction.</param>
 public HttpFormatException(IHttpTransaction transaction)
     : base()
 {
     this.transaction = transaction;
 }
예제 #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpReader"/> class.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="transaction">The transaction.</param>
 public HttpReader(Stream stream, IHttpTransaction transaction)
 {
     this.reader      = new StreamReader(stream);
     this.transaction = transaction;
 }
예제 #34
0
파일: AppHost.cs 프로젝트: restrepo/manos
 public static void HandleTransaction(IHttpTransaction con)
 {
     app.HandleTransaction (app, con);
 }
예제 #35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpWriter"/> class with the provided stream.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="transaction">The transaction.</param>
 public HttpWriter(Stream stream, IHttpTransaction transaction)
 {
     this.writer = new StreamWriter(stream);
     this.transaction = transaction;
 }
예제 #36
0
파일: ManosPipe.cs 프로젝트: vbatz258/manos
 public virtual void OnPreProcessRequest(ManosApp app, IHttpTransaction transaction, Action complete)
 {
     complete ();
 }
예제 #37
0
 public virtual void OnPreProcessRequest(ManosApp app, IHttpTransaction transaction)
 {
 }
예제 #38
0
 public static void HandleTransaction(IHttpTransaction con)
 {
     app.HandleTransaction(app, con);
 }
예제 #39
0
 public MockHttpResponse(IHttpTransaction txn)
 {
     this.Headers = new HttpHeaders ();
     this.Transaction = txn;
 }
예제 #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpFormatException"/> class.
 /// </summary>
 /// <param name="transaction">The transaction.</param>
 /// <param name="message">The message.</param>
 /// <param name="innerException">The inner exception.</param>
 public HttpFormatException(IHttpTransaction transaction, string message, Exception innerException)
     : base(message, innerException)
 {
     this.transaction = transaction;
 }
예제 #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpWriter"/> class with the provided stream.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="transaction">The transaction.</param>
 public HttpWriter(Stream stream, IHttpTransaction transaction)
 {
     this.writer      = new StreamWriter(stream);
     this.transaction = transaction;
 }
예제 #42
0
        public void HandleTransaction(ManosApp app, IHttpTransaction con)
        {
            Pipeline pipeline = new Pipeline(app, con);

            pipeline.Begin();
        }
예제 #43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpReader"/> class.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="transaction">The transaction.</param>
 public HttpReader(Stream stream, IHttpTransaction transaction)
 {
     this.reader = new StreamReader(stream);
     this.transaction = transaction;
 }
예제 #44
0
파일: ManosPipe.cs 프로젝트: Bhanditz/manos
 public virtual void OnPostProcessRequest(ManosApp app, IHttpTransaction transaction)
 {
 }
예제 #45
0
 public MockHttpResponse(IHttpTransaction txn)
 {
     this.Headers     = new HttpHeaders();
     this.Transaction = txn;
 }
예제 #46
0
파일: AppHost.cs 프로젝트: Hyperfair/manos
 public static void HandleTransaction(IHttpTransaction con)
 {
     try {
         Log.Debug ("HandleTransaction: START ({0}) \"{1}\"", con.Request.Socket.RemoteEndpoint.ToString(), con.Request.Path);
         app.HandleTransaction (app, con);
         Log.Debug ("HandleTransaction: END ({0}) \"{1}\"", con.Request.Socket.RemoteEndpoint.ToString(), con.Request.Path);
     } catch (Exception ex) {
         Log.Debug ("HandleTransactionException: {0}", ex);
     }
 }
예제 #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpFormatException"/> class.
 /// </summary>
 /// <param name="transaction">The transaction.</param>
 /// <param name="message">The message.</param>
 /// <param name="innerException">The inner exception.</param>
 public HttpFormatException(IHttpTransaction transaction, string message, Exception innerException)
     : base(message, innerException)
 {
     this.transaction = transaction;
 }
예제 #48
0
 public ManosContext(IHttpTransaction transaction)
 {
     Transaction = transaction;
 }