/// <summary> /// Dumps the web response /// </summary> /// <param name="response">The response to dump.</param> /// <returns>A string with all the object information in it.</returns> public static string BuildTraceDump(this HttpResponse response) { StringBuilder text = new StringBuilder(); text.AppendFormat("HttpResponse Type: {0}\n", response.GetType().ToString()); text.AppendFormat("ContentType: {0}\n", response.ContentType); text.AppendFormat("StatusCode: {0}\n", response.StatusCode); text.AppendFormat("Status: {0}\n", response.Status); text.AppendFormat("StatusDescription: {0}\n", response.Status); return(text.ToString()); }
/// <summary> /// Ends the request if the maximum request length is exceeded. /// </summary> /// <param name="response">The HTTP response.</param> /// <param name="isIIS7">Is this IIS 7?</param> /// <param name="context"> HttpContext </param> /// <param name="worker"> HttpWorkerRequest </param> void EndRequestOnRequestLengthExceeded(HttpResponse response, HttpWorkerRequest worker, HttpContext context, bool isIIS7) { _status.LengthExceeded = true; System.Threading.Thread.Sleep(5000); if (isIIS7) { response.GetType().GetMethod("CloseConnectionAfterError", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(response, null); } throw new HttpException(LengthExceededHttpCode, "Maximum request length exceeded"); }
private HttpResponse CreateResponse() { var response = new HttpResponse(new StringWriter(stream)); var type = response.GetType(); var context = type.GetProperty("Context", BindingFlags.Instance | BindingFlags.NonPublic); context.SetValue(response, HttpContext.Current, null); return response; }