毕业论文

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

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

时间:2017-02-21 13:09来源:毕业论文
//获取文件 byte[] file = Helper.GetFile(RootDirectory + request.Path); if (file != null) { //支持Gzip已压缩数据ID file = gzip ? HttpHelper.CompressGZIP(file) : file; //获得pageHeader byte


            //获取文件
            byte[] file = Helper.GetFile(RootDirectory + request.Path);
            if (file != null)
            {
                //支持Gzip已压缩数据ID
                file = gzip ? HttpHelper.CompressGZIP(file) : file;
                //获得pageHeader
                byte[] header = HttpHelper.GetHeader(file.Length, type, true, gzip);
                //构建完整的响应
                byte[] response = header.Concat(file);
                //创建响应
                output = new HttpResponse(response, request);
            }
            else
            {
                //file not found: return 404 response
                output = new HttpResponse(HttpHelper.GetHtml404Header(0, type), request);
            }
            return output;
        }

        /// <summary>
        /// 此功能检查,如果RawRequest收到来自浏览器的形成。
        /// </summary>
        /// <param name="e"></param>
        /// <param name="req"></param>
        /// <returns></returns>
        public static bool TryValidate(RawRequest e, out HttpRequest req)
        {
            HttpRequestType request = HttpRequestType.HttpPage;
            try
            {
                ///
                ///有很多的手法技巧在浏览器的HTTP请求中提取信息,
                /// 这个解决方案要求分割字符串和每个块analize。
                ///

                req = new HttpRequest(e);
                ///
                ///解码UTF8字符的字节,并要求分割字符串为“\ r\ N” HTTP服务器软件系统的设计与实现(12):http://www.youerw.com/jisuanji/lunwen_3170.html
------分隔线----------------------------
推荐内容