/// <summary> /// Response producer callback. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ProducerCallback(object sender, ProducerEventArgs e) { if (e.Buffer != null) { AsyncSend(e.Buffer, e.ByteCount); } else { Close(); } }
public virtual bool ReadAsync(ProducerEventArgs e) { e.Buffer = Read(); if (e.Buffer != null) { e.ByteCount = e.Buffer.Length; } else { e.ByteCount = 0; } return(false); }
/// <summary> /// Sends the next part of the HTTP response body. /// </summary> void SendBody() { if (!response.Producer.Connected) { response.Producer.Connect(request); produceAsyncArgs = new ProducerEventArgs(); produceAsyncArgs.Completed += ProducerCallback; } if (!response.Producer.ReadAsync(produceAsyncArgs)) { ProducerCallback(response.Producer, produceAsyncArgs); } }
public override bool ReadAsync(ProducerEventArgs e) { if (endOffset - currentOffset < 1) { e.Buffer = null; e.ByteCount = 0; return(false); } if (currentOffset + chunkSize >= endOffset) { readBuffer = new byte[endOffset - currentOffset]; } stream.BeginRead(readBuffer, 0, readBuffer.Length, new AsyncCallback(ReadCallback), e); return(true); }
public override bool ReadAsync(ProducerEventArgs e) { backingStream.BeginRead(readBuffer, 0, readBuffer.Length, new AsyncCallback(ReadCallback), e); return(true); }
public override bool ReadAsync(ProducerEventArgs e) { backingStream.BeginRead(readBuffer, 0, readBuffer.Length, new AsyncCallback(ReadCallback), e); return true; }
public override bool ReadAsync(ProducerEventArgs e) { if (endOffset - currentOffset < 1) { e.Buffer = null; e.ByteCount = 0; return false; } if (currentOffset + chunkSize >= endOffset) readBuffer = new byte[endOffset - currentOffset]; stream.BeginRead(readBuffer, 0, readBuffer.Length, new AsyncCallback(ReadCallback), e); return true; }
public virtual bool ReadAsync(ProducerEventArgs e) { e.Buffer = Read(); if (e.Buffer != null) e.ByteCount = e.Buffer.Length; else e.ByteCount = 0; return false; }
/// <summary> /// Sends the next part of the HTTP response body. /// </summary> void SendBody() { if (!response.Producer.Connected) { response.Producer.Connect(request); produceAsyncArgs = new ProducerEventArgs(); produceAsyncArgs.Completed += ProducerCallback; } if (!response.Producer.ReadAsync(produceAsyncArgs)) ProducerCallback(response.Producer, produceAsyncArgs); }