/// <summary> /// 请求上下文 构造函数,传入请求报文 /// </summary> /// <param name="strRequestContent"></param> public HttpContext(string strRequestContent) { //生成请求报文对象(实际就是 分析请求报文字符串,将数据封装到 请求报文对象中,方便调用) request = new HttpReqeust(strRequestContent); //生成相应报文对象 response = new HttpResponse(request); }
/// <summary> /// 根据请求的文件后缀, 返回一个 页面处理类 对象 /// </summary> /// <param name="request"></param> /// <returns></returns> public static IHttpHandler GetPageProcessInstance(HttpReqeust request) { IHttpHandler handler = null; //根据请求的文件后缀 switch (request.UrlExtention) { case ".jpg": case ".gif": case ".png": case ".mp3": handler = new HttpProcessImg(); //处理图片的 处理程序 break; case ".aspx": case ".jsp": case ".php": case ".gzitcast": handler = new HttpProcessDyn(); //处理动态 页面的 处理程序 break; case ".html": case ".htm": case ".css": case ".js": case ".txt": handler = new HttpProcessStatic(); //处理静态页面的处理程序 break; } return(handler); }
public HttpResponse(HttpReqeust request) { this.request = request; this.HttpVersion = request.HttpVersion; dictStatu.Add(200, "ok"); dictStatu.Add(403, "Forbidden"); dictStatu.Add(404, "File Not Found"); dictStatu.Add(500, "Internal Server Error"); }