private void OnBeforeResponse(RawContext context, SessionEventArgs e) { if (context == null) { return; } BeforeResponse?.Invoke(context, e); }
/// <summary> /// Override OnReceiveResponse to read response data /// </summary> protected override void OnReceiveResponse() { #region Nekoxy Code AfterReadResponseHeaders?.Invoke(new HttpResponse(this.ResponseStatusLine, this.ResponseHeaders, null)); if (this.ResponseStatusLine.StatusCode != 200) { return; } var response = this.ResponseHeaders.IsUnknownLength() ? this.GetContentWhenUnknownLength() : this.GetContent(); this.State.NextStep = null; using (var ms = new MemoryStream()) { var stream = this.GetResponseMessageStream(response); stream.CopyTo(ms); var content = ms.ToArray(); this.currentSession.Response = new HttpResponse(this.ResponseStatusLine, this.ResponseHeaders, content); } #endregion if (BeforeResponse != null) { response = BeforeResponse?.Invoke(this.currentSession, this.currentSession.Response.Body); this.ResponseHeaders.ContentEncoding = null; // remove gzip and chunked... } #region Nekoxy Code this.ResponseHeaders.TransferEncoding = null; this.ResponseHeaders.ContentLength = (uint)response.Length; this.SendResponseStatusAndHeaders(); // Send HTTP status & head to client this.SocketBP.TunnelDataTo(this.TunnelBP, response); // Send response body to client if (!this.State.bPersistConnectionPS) { this.SocketPS?.CloseSocket(); this.SocketPS = null; } AfterSessionComplete?.Invoke(this.currentSession); #endregion }
/// <summary> /// Invocator for BeforeResponse event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> protected virtual void OnBeforeResponse(object sender, SessionEventArgs e) { BeforeResponse?.Invoke(sender, e); }
public void OnBeforeResponse(Session session) { BeforeResponse?.Invoke(session); }
private int onBeforeResponse(long handle) { BeforeResponse?.Invoke(new Session(handle, new Request(handle), new Response(handle))); return(0); }
private void onBeforeResponse(long handle) { BeforeResponse?.Invoke(new Session(handle, new Request(handle), new Response(handle))); }