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


C# Internal.CopyTo方法代码示例

本文整理汇总了C#中Internal.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# Internal.CopyTo方法的具体用法?C# Internal.CopyTo怎么用?C# Internal.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Internal的用法示例。


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

示例1: ProcessHtmlPostBody

        void ProcessHtmlPostBody(int readpos, Internal.RecvIO recvIO)
        {
            //parse body
            int transferedBytes = recvIO.BytesTransferred;
            int remaining = transferedBytes - readpos;
            if (!IsMsgBodyComplete)
            {
                int wantBytes = ContentLength - contentByteCount;
                if (wantBytes <= remaining)
                {
                    //complete here 
                    byte[] buff = new byte[wantBytes];
                    recvIO.CopyTo(readpos, buff, wantBytes);
                    //add to req  
                    AddMsgBody(buff, 0, wantBytes);
                    //complete 
                    this.parseState = HttpParsingState.Complete;
                    return;
                }
                else
                {
                    //continue read             
                    if (remaining > 0)
                    {
                        byte[] buff = new byte[remaining];
                        recvIO.CopyTo(readpos, buff, remaining);
                        //add to req  
                        AddMsgBody(buff, 0, remaining);
                    }

                    return;
                }
            }
            this.parseState = HttpParsingState.Complete;

        }
开发者ID:SharpConnect,项目名称:SharpConnect.WebServer,代码行数:36,代码来源:HttpRequest.cs

示例2: ParseHttpRequestHeader

 int ParseHttpRequestHeader(Internal.RecvIO recvIO)
 {
     //start from pos0
     int readpos = 0;
     int lim = recvIO.BytesTransferred - 1;
     int i = 0;
     for (; i <= lim; ++i)
     {
         //just read 
         if (recvIO.ReadByte(i) == '\r' &&
             recvIO.ReadByte(i + 1) == '\n')
         {
             //each line
             //translate
             if (i - readpos < 512)
             {
                 //copy     
                 recvIO.CopyTo(readpos, tmpReadBuffer, i - readpos);
                 //translate
                 string line = Encoding.UTF8.GetString(tmpReadBuffer, 0, i - readpos);
                 readpos = i + 2;
                 i++; //skip \n            
                 //translate header ***
                 if (line == "")
                 {
                     //complete http header                           
                     parseState = HttpParsingState.Body;
                     return readpos;
                 }
                 else
                 {
                     //parse header line
                     AddReqHeader(line);
                 }
             }
             else
             {
                 //just skip?
                 //skip too long line
                 readpos = i + 2;
                 i++; //skip \n 
             }
         }
     }
     return readpos;
 }
开发者ID:SharpConnect,项目名称:SharpConnect.WebServer,代码行数:46,代码来源:HttpRequest.cs


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