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() { Socket = new SocketStream (AppHost.IOLoop); Socket.Connect (RemoteAddress, RemotePort); Socket.Connected += delegate { Stream = new HttpStream (this, Socket); 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 (this, Socket); response.OnCompleted += () => { if (OnResponse != null) OnResponse (response); }; response.Read (); }); }; }