// レスポンスを取得し、書き出します。 private void SendResponse(HttpContext context){ HatomaruResponse hr = myManager.GetResponse(context.Request); if(hr == null) throw new Exception("レスポンスが取得できませんでした。"); // Host:が間違っていて200系だったらリダイレクト // ただし localhost は除く if(200 <= hr.StatusCode && hr.StatusCode < 300){ string hostValue = context.Request.Headers["Host"]; if(!string.IsNullOrEmpty(hostValue)){ if(!hostValue.Eq(myManager.IniData.Domain) && !hostValue.Eq("localhost")){ hr = new RedirectResponse(hr.Path, myManager.IniData.Domain); } } } // IMS つきのリクエストに 304 を返すか? string ims = context.Request.Headers["If-Modified-Since"]; if(ims != null && hr.LastModified != null){ DateTime imsTime = GetImsTime(ims); DateTime responseTime = CutMilliSeconds(hr.LastModified); if(imsTime >= responseTime && responseTime != default(DateTime)){ SendNotModifiedResponse(context); return; } } try{ hr.WriteResponse(context.Response); if(hr.ContentType == HatomaruResponse.XhtmlMediaType){ if(IsXhtmlAccept(context.Request)){ context.Response.Cache.VaryByHeaders.AcceptTypes = true; } else { context.Response.ContentType = HatomaruResponse.HtmlMediaType; } } return; }catch(System.IO.FileNotFoundException){ hr = null; } }
} // End FileSearch() // 特殊レスポンス // hatomaru.aspx を含む URL をリダイレクトする private RedirectResponse GetHatomaruAspxRedirect(AbsPath path){ AbsPath destPath = path.Remove(HatomaruAspxPath); RedirectResponse red = new RedirectResponse(destPath, IniData.Domain, path); return red; }