protected override void SendNextBlock() { stream.DisableWriting (); Libeio.Libeio.read (fd, transferBuffer, position, transferBuffer.Length, (len, buf, err) => { if (position == Length) { OnComplete (len, err); } if (len > 0) { position += len; currentPrefixBlock = new SendBytesOperation (new[] { new ByteBuffer (transferBuffer, 0, len) }, null); currentPrefixBlock.BeginWrite (stream); } else { OnComplete (len, err); } stream.EnableWriting (); }); }
protected override void SendNextBlock() { stream.DisableWriting(); Libeio.Libeio.read(fd, transferBuffer, position, transferBuffer.Length, (len, buf, err) => { if (position == Length) { OnComplete(len, err); } if (len > 0) { position += len; currentPrefixBlock = new SendBytesOperation(new[] { new ByteBuffer(transferBuffer, 0, len) }, null); currentPrefixBlock.BeginWrite(stream); } else { OnComplete(len, err); } stream.EnableWriting(); }); }
public bool Combine(IWriteOperation other) { SendBytesOperation send_op = other as SendBytesOperation; if (send_op == null) { return(false); } int offset = bytes.Count; foreach (var op in send_op.bytes) { bytes.Add(op); } if (send_op.callback != null) { if (callback == null && callbacks == null) { callback = send_op.callback; } else { if (callbacks == null) { callbacks = new List <CallbackInfo> (); callbacks.Add(new CallbackInfo(offset - 1, callback)); callback = null; } callbacks.Add(new CallbackInfo(bytes.Count - 1, send_op.callback)); } } return(true); }
private void Write(byte [] buffer, int offset, int count, bool chunked) { EnsureMetadata (); var bytes = new List<ByteBuffer> (); if (chunked) WriteChunk (bytes, count, false); length += (count - offset); bytes.Add (new ByteBuffer (buffer, offset, count)); if (chunked) WriteChunk (bytes, -1, false); var write_bytes = new SendBytesOperation (bytes, null); QueueWriteOperation (write_bytes); }
private void SendChunk(int l, bool last) { var bytes = new List<ByteBuffer> (); WriteChunk (bytes, l, last); var write_bytes = new SendBytesOperation (bytes, null); QueueWriteOperation (write_bytes); }
public void WriteMetadata(WriteCallback callback) { if (pending_length_cbs > 0) return; if (AddHeaders) { if (chunk_encode) { HttpEntity.Headers.SetNormalizedHeader ("Transfer-Encoding", "chunked"); } else { HttpEntity.Headers.ContentLength = Length; } } StringBuilder builder = new StringBuilder (); HttpEntity.WriteMetadata (builder); byte [] data = Encoding.ASCII.GetBytes (builder.ToString ()); metadata_written = true; var bytes = new List<ByteBuffer> (); bytes.Add (new ByteBuffer (data, 0, data.Length)); var write_bytes = new SendBytesOperation (bytes, callback); SocketStream.QueueWriteOperation (write_bytes); }
public void SendFinalChunk(WriteCallback callback) { EnsureMetadata (); if (!chunk_encode || final_chunk_sent) return; final_chunk_sent = true; var bytes = new List<ByteBuffer> (); WriteChunk (bytes, 0, true); var write_bytes = new SendBytesOperation (bytes, callback); QueueWriteOperation (write_bytes); }
public void Write(byte [] data, int offset, int count, WriteCallback callback) { var bytes = new List<ByteBuffer> (); bytes.Add (new ByteBuffer (data, offset, count)); var write_bytes = new SendBytesOperation (bytes, callback); QueueWriteOperation (write_bytes); }
public void Write(byte [] data, int offset, int count, WriteCallback callback) { var bytes = new List<ArraySegment<byte>> (); bytes.Add (new ArraySegment<byte> (data, offset, count)); var write_bytes = new SendBytesOperation (bytes, callback); QueueWriteOperation (write_bytes); }
public void Write(byte[] data, int offset, int count, IO.WriteCallback callback) { var write_bytes = new SendBytesOperation(new ByteBuffer[] {new ByteBuffer(data, offset, count)}, callback); QueueWriteOperation(write_bytes); }
public void WriteMetadata(WriteCallback callback) { StringBuilder builder = new StringBuilder (); HttpEntity.WriteMetadata (builder); byte [] data = Encoding.ASCII.GetBytes (builder.ToString ()); metadata_written = true; var bytes = new List<ArraySegment<byte>> (); bytes.Add (new ArraySegment<byte> (data, 0, data.Length)); var write_bytes = new SendBytesOperation (bytes, callback); SocketStream.QueueWriteOperation (write_bytes); }