• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# HttpResponseStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: Write_TwoSegments_SetsLength

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

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

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


示例17: Write_TruncatedSegment_SetsLength

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

            stream.Write (buffer, 0, 5);

            long len = stream.Length;
            Assert.AreEqual (5, len);
        }
开发者ID:vbatz258,项目名称:manos,代码行数:10,代码来源:HttpResponseStreamTest.cs


示例18: Write_ShorterThanBufferInSingleBuffer_SetsCorrectLength

        public void Write_ShorterThanBufferInSingleBuffer_SetsCorrectLength()
        {
            var stream = new HttpResponseStream ();
            var write_buffer = new byte [5];

            stream.Write (write_buffer, 0, 5);

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

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


示例19: Write_SeekedBackPastLastSegmentWriteOverAll_SetsPosition

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

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

            stream.Seek (-15, SeekOrigin.Current);
                        Assert.AreEqual (5, stream.Position);

            stream.Write (buffer_big, 0, 25);

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


示例20: Seek_FromEnd_SetsPosition

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

            stream.Write (buffer, 0, 10);
            stream.Seek (-3, SeekOrigin.End);

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# HttpResult类代码示例发布时间:2022-05-24
下一篇:
C# HttpResponseMessage类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap