Ejemplo n.º 1
0
 /// <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();
     }
 }
Ejemplo n.º 2
0
 public virtual bool ReadAsync(ProducerEventArgs e)
 {
     e.Buffer = Read();
     if (e.Buffer != null)
     {
         e.ByteCount = e.Buffer.Length;
     }
     else
     {
         e.ByteCount = 0;
     }
     return(false);
 }
Ejemplo n.º 3
0
 /// <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);
     }
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 public override bool ReadAsync(ProducerEventArgs e)
 {
     backingStream.BeginRead(readBuffer, 0, readBuffer.Length, new AsyncCallback(ReadCallback), e);
     return(true);
 }
Ejemplo n.º 6
0
 public override bool ReadAsync(ProducerEventArgs e)
 {
     backingStream.BeginRead(readBuffer, 0, readBuffer.Length, new AsyncCallback(ReadCallback), e);
     return true;
 }
Ejemplo n.º 7
0
 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;
 }
Ejemplo n.º 8
0
 public virtual bool ReadAsync(ProducerEventArgs e)
 {
     e.Buffer = Read();
     if (e.Buffer != null)
         e.ByteCount = e.Buffer.Length;
     else
         e.ByteCount = 0;
     return false;
 }
Ejemplo n.º 9
0
 /// <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);
 }
Ejemplo n.º 10
0
 /// <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();
     }
 }