毕业论文

打赏
当前位置: 毕业论文 > 计算机论文 >

HTTP服务器软件系统的设计与实现(13)

时间:2017-02-21 13:09来源:毕业论文
/// req.CompleteRequest = new String(Encoding.UTF8.GetChars(e.RawData)); string[] groups = req.CompleteRequest.Split(new string[] { \r\n }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i


                ///
                req.CompleteRequest = new String(Encoding.UTF8.GetChars(e.RawData));
                
                string[] groups = req.CompleteRequest.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                for (int i = 0; i < groups.Length; i++)
                {
                    string headerblock = groups[i];

                    if (i > 0 && headerblock.Contains(":"))
                    {
                        //从所述第二块,我们也fileds模式<name:value>与
                        string[] block = headerblock.Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
                        req.Requests.Add(block[0], block[1]);
                    }
                    else
                    {
                        ///
                        /// 第一个块总是包括请求的路径,方法和协议HTTP。
                        /// ex. GET /path/resource.ext HTTP/1.1
                        ///

                        
                        string[] subparts = headerblock.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                        //复制路径
                        req.CompletePath = subparts[1];                        
                        if (subparts[0] == "GET") req.Method = HttpMethodType.Get; HTTP服务器软件系统的设计与实现(13):http://www.751com.cn/jisuanji/lunwen_3170.html
------分隔线----------------------------
推荐内容