当前位置: 首页>>代码示例>>C#>>正文


C# HttpResponseStream类代码示例

本文整理汇总了C#中HttpResponseStream的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseStream类的具体用法?C# HttpResponseStream怎么用?C# HttpResponseStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpResponseStream类属于命名空间,在下文中一共展示了HttpResponseStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Read_PastEndOfStream_ReturnsAmountRead

        public void Read_PastEndOfStream_ReturnsAmountRead()
        {
            var stream = new HttpResponseStream ();
            var buffer = new byte [10];

            stream.Write (buffer, 0, 10);

            stream.Seek (-1, SeekOrigin.End);
            int amount_read = stream.Read (buffer, 0, 2);

            Assert.AreEqual (1, amount_read);
        }
开发者ID:KevinT,项目名称:manos,代码行数:12,代码来源:HttpResponseStreamTest.cs

示例2: Insert_BeginningOfStream_SetsCorrectPosition

        public void Insert_BeginningOfStream_SetsCorrectPosition()
        {
            var stream = new HttpResponseStream ();
            var write_buffer = new byte [10];

            stream.Write (write_buffer, 0, 10);
            stream.Position = 0;

            stream.Insert (write_buffer, 0, 5);

            var position = stream.Position;
            Assert.AreEqual (5, position);
        }
开发者ID:vbatz258,项目名称:manos,代码行数:13,代码来源:HttpResponseStreamTest.cs

示例3: HttpResponse

        public HttpResponse(IHttpTransaction transaction, IOStream stream)
        {
            Transaction = transaction;
            IOStream = stream;

            StatusCode = 200;

            WriteHeaders = true;

            Headers = new HttpHeaders ();
            Stream = new HttpResponseStream (this, IOStream);
            Stream.Chunked = (transaction.Request.MajorVersion > 0 && transaction.Request.MinorVersion > 0);
        }
开发者ID:nickcanz,项目名称:manos,代码行数:13,代码来源:HttpResponse.cs

示例4: Read_ReadLastItem_UpdatesPosition

        public void Read_ReadLastItem_UpdatesPosition()
        {
            var stream = new HttpResponseStream ();
            var buffer = new byte [10];

            stream.Write (buffer, 0, 10);

            stream.Seek (-1, SeekOrigin.End);
            stream.Read (buffer, 0, 1);

            long position = stream.Position;
            Assert.AreEqual (10, position);
        }
开发者ID:KevinT,项目名称:manos,代码行数:13,代码来源:HttpResponseStreamTest.cs

示例5: Insert_BeginningOfStream_SetsCorrectLength

        public void Insert_BeginningOfStream_SetsCorrectLength()
        {
            var stream = new HttpResponseStream ();
            var write_buffer = new byte [10];

            stream.Write (write_buffer, 0, 10);
            stream.Position = 0;

            stream.Insert (write_buffer, 0, 10);

            var length = stream.Length;
            Assert.AreEqual (20, length);
        }
开发者ID:vbatz258,项目名称:manos,代码行数:13,代码来源:HttpResponseStreamTest.cs

示例6: HttpResponse

        public HttpResponse(IHttpTransaction transaction)
        {
            Transaction = transaction;

            StatusCode = 200;

            WriteHeaders = true;

            Headers = new HttpHeaders ();
            Stream = new HttpResponseStream ();
            Writer = new StreamWriter (Stream);
            Cookies = new Dictionary<string, HttpCookie> ();

            SetStandardHeaders ();
        }
开发者ID:davidalpert,项目名称:manos,代码行数:15,代码来源:HttpResponse.cs

示例7: Read_MultipleBuffers_UpdatesPosition

        public void Read_MultipleBuffers_UpdatesPosition()
        {
            var stream = new HttpResponseStream ();
            var buffer = new byte [10];

            stream.Write (buffer, 0, 10);
            stream.Write (buffer, 0, 10);
            stream.Write (buffer, 0, 10);

            stream.Seek (15, SeekOrigin.Begin);
            stream.Read (buffer, 0, 5);

            long position = stream.Position;
            Assert.AreEqual (20, position);
        }
开发者ID:KevinT,项目名称:manos,代码行数:15,代码来源:HttpResponseStreamTest.cs

示例8: Read_SingleBuffer_CorrectData

        public void Read_SingleBuffer_CorrectData()
        {
            var stream = new HttpResponseStream ();
            var write_buffer = new byte [3];
            var read_buffer = new byte [1];

            write_buffer [2] = 0xFA;

            stream.Write (write_buffer, 0, 3);

            stream.Seek (-1, SeekOrigin.End);
            stream.Read (read_buffer, 0, 1);

            byte read_byte = read_buffer [0];
            Assert.AreEqual (0xFA, read_byte);
        }
开发者ID:KevinT,项目名称:manos,代码行数:16,代码来源:HttpResponseStreamTest.cs

示例9: HttpResponse

        public HttpResponse(IHttpTransaction transaction, Encoding encoding)
        {
            Transaction = transaction;
            Encoding = encoding;

            StatusCode = 200;

            WriteHeaders = true;
            WriteStatusLine = true;

            Headers = new HttpHeaders ();
            Stream = new HttpResponseStream ();
            Cookies = new Dictionary<string, HttpCookie> ();

            SetStandardHeaders ();
        }
开发者ID:silk,项目名称:manos,代码行数:16,代码来源:HttpResponse.cs

示例10: HttpResponse

        public HttpResponse(IHttpTransaction transaction, IOStream stream)
        {
            Transaction = transaction;
            IOStream = stream;

            StatusCode = 200;

            WriteHeaders = true;

            Headers = new HttpHeaders ();
            Stream = new HttpResponseStream (this, IOStream);
            Stream.Chunked = (transaction.Request.MajorVersion > 0 && transaction.Request.MinorVersion > 0);

            end_watcher = new AsyncWatcher (IOLoop.Instance.EventLoop, OnEnd);
            end_watcher.Start ();
        }
开发者ID:debackerl,项目名称:manos,代码行数:16,代码来源:HttpResponse.cs

示例11: Insert_BeginningOfStream_SetsCorrectData

        public void Insert_BeginningOfStream_SetsCorrectData()
        {
            var stream = new HttpResponseStream ();
            var write_buffer = new byte [10];
            var write_buffer2 = new byte [10];

            stream.Write (write_buffer, 0, 10);
            stream.Position = 0;

            write_buffer2 [2] = 0xFA;
            stream.Insert (write_buffer2, 0, 10);

            stream.Position = 2;
            var data = stream.ReadByte ();
            Assert.AreEqual (0xFA, data);
        }
开发者ID:vbatz258,项目名称:manos,代码行数:16,代码来源:HttpResponseStreamTest.cs

示例12: Read_MultipleBuffers_CorrectData

        public void Read_MultipleBuffers_CorrectData()
        {
            var stream = new HttpResponseStream ();
            var write_buffer1 = new byte [3];
            var write_buffer2 = new byte [3];
            var read_buffer = new byte [6];

            stream.Write (write_buffer1, 0, 3);

            write_buffer2 [0] = 0xFA;
            stream.Write (write_buffer2, 0, 3);

            stream.Seek (0, SeekOrigin.Begin);
            stream.Read (read_buffer, 0, 6);

            byte read_byte = read_buffer [3];
            Assert.AreEqual (0xFA, read_byte);
        }
开发者ID:KevinT,项目名称:manos,代码行数:18,代码来源:HttpResponseStreamTest.cs

示例13: WebSocketHttpListenerDuplexStream

        public WebSocketHttpListenerDuplexStream(HttpRequestStream inputStream,
            HttpResponseStream outputStream,
            HttpListenerContext context)
        {
            Debug.Assert(inputStream != null, "'inputStream' MUST NOT be NULL.");
            Debug.Assert(outputStream != null, "'outputStream' MUST NOT be NULL.");
            Debug.Assert(context != null, "'context' MUST NOT be NULL.");
            Debug.Assert(inputStream.CanRead, "'inputStream' MUST support read operations.");
            Debug.Assert(outputStream.CanWrite, "'outputStream' MUST support write operations.");

            _inputStream = inputStream;
            _outputStream = outputStream;
            _context = context;

            if (NetEventSource.IsEnabled)
            {
                NetEventSource.Associate(inputStream, this);
                NetEventSource.Associate(outputStream, this);
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:20,代码来源:WebSocketHttpListenerDuplexStream.cs

示例14: Seek_FromCurrentBackwards_SetsPosition

        public void Seek_FromCurrentBackwards_SetsPosition()
        {
            var stream = new HttpResponseStream ();
            var buffer = new byte [10];

            stream.Write (buffer, 0, 10);
            stream.Write (buffer, 0, 10);

            stream.Seek (-5, SeekOrigin.Current);

            long pos = stream.Position;
            Assert.AreEqual (15, pos);
        }
开发者ID:vbatz258,项目名称:manos,代码行数:13,代码来源:HttpResponseStreamTest.cs

示例15: Write_TwoSegments_SetsPosition

        public void Write_TwoSegments_SetsPosition()
        {
            var stream = new HttpResponseStream ();
            var buffer = new byte [10];

            stream.Write (buffer, 0, 10);
            stream.Write (buffer, 0, 10);

            long pos = stream.Position;
            Assert.AreEqual (20, pos);
        }
开发者ID:vbatz258,项目名称:manos,代码行数:11,代码来源:HttpResponseStreamTest.cs


注:本文中的HttpResponseStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。