예제 #1
0
        public void WriteMetadata()
        {
            if (metadata_written)
                return;

            SetStandardHeaders ();

            StringBuilder builder = new StringBuilder ();
            WriteStatusLine (builder);

            if (WriteHeaders)
                Headers.Write (builder, cookies == null ? null : Cookies.Values, Encoding.ASCII);

            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));
            WriteBytesOperation write_bytes = new WriteBytesOperation (bytes, null);

            IOStream.QueueWriteOperation (write_bytes);
        }
예제 #2
0
        private void SendChunk(int l, bool last)
        {
            var bytes = new List<ArraySegment<byte>> ();

            WriteChunk (bytes, l, last);

            WriteBytesOperation write_bytes = new WriteBytesOperation (bytes, null);
            QueueWriteOperation (write_bytes);
        }
예제 #3
0
        private void Write(byte [] buffer, int offset, int count, bool chunked)
        {
            EnsureMetadata ();

            var bytes = new List<ArraySegment<byte>> ();

            if (chunked)
                WriteChunk (bytes, count, false);

            length += (count - offset);

            bytes.Add (new ArraySegment<byte> (buffer, offset, count));
            if (chunked)
                WriteChunk (bytes, -1, false);

            WriteBytesOperation write_bytes = new WriteBytesOperation (bytes, null);
            QueueWriteOperation (write_bytes);
        }
예제 #4
0
        public void SendFinalChunk(WriteCallback callback)
        {
            EnsureMetadata ();

            if (!chunk_encode || final_chunk_sent)
                return;
            final_chunk_sent = true;

            var bytes = new List<ArraySegment<byte>> ();

            WriteChunk (bytes, 0, true);

            WriteBytesOperation write_bytes = new WriteBytesOperation (bytes, callback);
            QueueWriteOperation (write_bytes);
        }