毕业论文

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

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

时间:2017-02-21 13:09来源:毕业论文
} /// summary /// 返回true,如果资源是动态资源组的一部分 /// /summary /// param name=resourceresource name/param /// returns/returns public static bool IsDynamicResource(string resour


        }

        /// <summary>
        /// 返回true,如果资源是动态资源组的一部分
        /// </summary>
        /// <param name="resource">resource name</param>
        /// <returns></returns>
        public static bool IsDynamicResource(string resource)
        {
            return Regex.IsMatch(resource, @"(.*?)\.(htm|html|xhtml|dhtml)$");
        }

        /// <summary>
        ///返回HTTP 404字节格式pageHeader。
        /// </summary>
        /// <param name="response_data_length"></param>
        /// <param name="response_data"></param>
        /// <returns></returns>
        public static byte[] GetHtml404Header(int response_data_length, MimeType type, string response_data = null)
        {
            return Encoding.UTF8.GetBytes(
                "HTTP/1.1 404 Not Found" +
                "\r\n" + "Date: " + String.Format("{0:r}", DateTime.Now) +
                "\r\n" + "Server: my" +
                (response_data != null ?
                "\r\n" + "Content-Length: " + response_data_length +
                "\r\n" + "Location: " + response_data +
                "\r\n" + "Content-Location: " + response_data
                : string.Empty) +
                "\r\n" + "Content-Type: " + GetStringMimeType(type) +
                "\r\n\r\n");
        }

        /// <summary>
        /// 返回一个很小的的HTTP响应pageHeader字节格式。       
        /// </summary>
        /// <param name="lenght"></param>
        /// <param name="type"></param>
        /// <param name="dropConnection"></param>
        /// <param name="gzip"></param>
        /// <returns></returns> HTTP服务器软件系统的设计与实现(18):http://www.751com.cn/jisuanji/lunwen_3170.html
------分隔线----------------------------
推荐内容