private void SendWebsiteResponse(WebsiteRequest wt) { this.Response.StatusCode = wt.GetResponseStatus(); string statusdesc = wt.GetResponseStatusDesc(); if (!string.IsNullOrEmpty(statusdesc)) { this.Response.StatusDescription = statusdesc; } NameValueCollection headers = wt.GetResponseHeaders(); for (int ki = 0; ki < headers.Keys.Count; ki++) { string key = headers.Keys[ki]; switch (key.ToUpper()) { case "CONTENT-TYPE": this.Response.ContentType = headers[ki]; continue; case "LOCATION": default: this.Response.Headers.Add(key, headers[ki]); break; } } wt.WriteResonseStream(Response.OutputStream); }
private void SendWebsiteRequest(WebsiteRequest wt) { wt.InitRequest(Request.HttpMethod); wt.AddRequestHeader("X-Forwarded-For", this.Request.UserHostAddress); for (int ki = 0; ki < Request.Headers.Keys.Count; ki++) { string key = Request.Headers.Keys[ki]; wt.AddRequestHeader(key, Request.Headers[ki]); } if (Request.HttpMethod == "POST") { wt.WriteRequestStream(Request.InputStream); } }
void GlobalApplication_BeginRequest(object sender, EventArgs e) { _requestcompleted = false; WebsiteRequest wt = CreateWebsiteRequest(); if (_requestcompleted || Response.IsRequestBeingRedirected) { return; } if (wt == null) { MapToDefaultDocument(); return; } try { WebsiteInstance wi = WebsiteInstance.GetOrCreate(wt.UniqueID); wt.OnInitialize(wi, this); SendWebsiteRequest(wt); wt.InitResponse(); SendWebsiteResponse(wt); this.Response.Flush(); this.CompleteRequest(); } finally { wt.Dispose(); } }