public void Execute() { Socket = AppHost.Context.CreateSocket (); Socket.Connect (RemoteAddress, RemotePort, delegate { Stream = new HttpStream (this, Socket.GetSocketStream ()); Stream.Chunked = false; Stream.AddHeaders = false; byte [] body = GetBody (); if (body != null) { Headers.ContentLength = body.Length; Stream.Write (body, 0, body.Length); } Stream.End (() => { HttpResponse response = new HttpResponse (Context, this, Socket); // response.OnCompleted += () => { // if (OnResponse != null) // OnResponse (response); // }; response.Read (() => { if (OnResponse != null) OnResponse (response); }); }); }); }
public void OnRequestReady() { try { Response = new HttpResponse (Request, Stream); Server.RunTransaction (this); } catch (Exception e) { Console.WriteLine ("Exception while running transaction"); Console.WriteLine (e); } }
public void Execute() { Socket = new SocketStream (AppHost.IOLoop); Socket.Connect (RemoteAddress, RemotePort); Socket.Connected += delegate { Stream = new HttpStream (this, Socket); Stream.WriteMetadata (() => { HttpResponse response = new HttpResponse (Socket); if (Connected != null) Connected (response); }); }; }
public void Execute() { var remote = new IPEndPoint(IPAddress.Parse (RemoteAddress), RemotePort); Socket = this.Context.CreateTcpSocket (remote.AddressFamily); Socket.Connect (remote, delegate { Stream = new HttpStream (this, Socket.GetSocketStream ()); Stream.Chunked = false; Stream.AddHeaders = false; byte [] body = GetBody (); if (body != null) { Headers.ContentLength = body.Length; Stream.Write (body, 0, body.Length); } Stream.End (() => { HttpResponse response = new HttpResponse (Context, this, Socket); // response.OnCompleted += () => { // if (OnResponse != null) // OnResponse (response); // }; response.Read (() => { if (OnResponse != null) OnResponse (response); }); }); }, ex => { // TODO: figure out what to do here }); }
private void OnFinishedReading() { if (body_handler != null) body_handler.Finish (this); try { IOStream.DisableReading (); Response = new HttpResponse (this); Server.RunTransaction (this); } catch (Exception e) { Console.WriteLine ("Exception while running transaction"); Console.WriteLine (e); } }
public void OnRequestReady() { try { Response = new HttpResponse (Request, Stream); ResponseReady = true; if( closeOnEnd ) Response.OnEnd += () => Response.Complete( OnResponseFinished ); Server.RunTransaction (this); } catch (Exception e) { Console.WriteLine ("Exception while running transaction"); Console.WriteLine (e); } }
public HttpResponseStream(HttpResponse response, IOStream stream) { Response = response; IOStream = stream; }