public HttpRequest(IHttpTransaction transaction, SocketStream stream) { Transaction = transaction; Socket = stream; RemoteAddress = stream.Address; RemotePort = stream.Port; }
public HttpRequest(IHttpTransaction transaction, Socket stream) : base(transaction.Context) { Transaction = transaction; Socket = stream; RemoteAddress = stream.Address; RemotePort = stream.Port; }
public HttpRequest(IHttpTransaction transaction, ITcpSocket stream) : base(transaction.Context) { Transaction = transaction; Socket = stream; RemoteAddress = stream.RemoteEndpoint.Address.ToString(); RemotePort = stream.RemoteEndpoint.Port; }
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; }
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); } } }
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 (); }
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; }
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); }
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); }
/// <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 = ""; }
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 (); }
public HttpResponse(IHttpTransaction transaction, Encoding encoding) { Transaction = transaction; Encoding = encoding; StatusCode = 200; WriteHeaders = true; WriteStatusLine = true; Headers = new HttpHeaders (); SetStandardHeaders (); }
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 (); }
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 (); }
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 (); }
/// <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 = ""; }
/// <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"; } }
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); } } }
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 (); }
/// <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"; } }
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); }
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); }
public void HandleTransaction(ManosApp app, IHttpTransaction con) { Pipeline pipeline = new Pipeline (app, con); pipeline.Begin (); }
public virtual void OnPostProcessRequest(ManosApp app, IHttpTransaction transaction, Action complete) { complete(); }
/// <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; }
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(); } }
public ManosContext(IHttpTransaction transaction) { Transaction = transaction; }
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); } } }
/// <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; }
public static void HandleTransaction(IHttpTransaction con) { app.HandleTransaction (app, con); }
/// <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; }
public virtual void OnPreProcessRequest(ManosApp app, IHttpTransaction transaction, Action complete) { complete (); }
public virtual void OnPreProcessRequest(ManosApp app, IHttpTransaction transaction) { }
public static void HandleTransaction(IHttpTransaction con) { app.HandleTransaction(app, con); }
public MockHttpResponse(IHttpTransaction txn) { this.Headers = new HttpHeaders (); this.Transaction = txn; }
/// <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; }
public void HandleTransaction(ManosApp app, IHttpTransaction con) { Pipeline pipeline = new Pipeline(app, con); pipeline.Begin(); }
public virtual void OnPostProcessRequest(ManosApp app, IHttpTransaction transaction) { }
public MockHttpResponse(IHttpTransaction txn) { this.Headers = new HttpHeaders(); this.Transaction = txn; }
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); } }