Yet Yet More BitId Debugging
This commit is contained in:
@@ -226,6 +226,7 @@
|
||||
<Compile Include="Structure\UptakeGeography.cs" />
|
||||
<Compile Include="Support\ActivistEvents.cs" />
|
||||
<Compile Include="Support\DatabaseMaintenance.cs" />
|
||||
<Compile Include="Support\ExtensionMethods.cs" />
|
||||
<Compile Include="Support\Imagery.cs" />
|
||||
<Compile Include="Support\IXmlPayload.cs" />
|
||||
<Compile Include="Support\LogEntries\CashAdvanceRequestedLogEntry.cs" />
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
namespace System.Web.ExtensionMethods
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for HTTP Request.
|
||||
/// <remarks>
|
||||
/// See the HTTP 1.1 specification http://www.w3.org/Protocols/rfc2616/rfc2616.html
|
||||
/// for details of implementation decisions.
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public static class HttpRequestExtensions
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Dump the raw http request to a string.
|
||||
/// </summary>
|
||||
/// <param name="request">The <see cref="HttpRequest"/> that should be dumped. </param>
|
||||
/// <returns>The raw HTTP request.</returns>
|
||||
public static string ToRaw(this HttpRequest request)
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
WriteStartLine(request, writer);
|
||||
WriteHeaders(request, writer);
|
||||
WriteBody(request, writer);
|
||||
|
||||
return writer.ToString();
|
||||
}
|
||||
|
||||
public static string GetBody(this HttpRequest request)
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
WriteBody(request, writer);
|
||||
|
||||
return writer.ToString();
|
||||
}
|
||||
|
||||
private static void WriteStartLine(HttpRequest request, StringWriter writer)
|
||||
{
|
||||
const string SPACE = " ";
|
||||
|
||||
writer.Write(request.HttpMethod);
|
||||
writer.Write(SPACE + request.Url);
|
||||
writer.WriteLine(SPACE + request.ServerVariables["SERVER_PROTOCOL"]);
|
||||
}
|
||||
|
||||
|
||||
private static void WriteHeaders(HttpRequest request, StringWriter writer)
|
||||
{
|
||||
foreach (string key in request.Headers.AllKeys)
|
||||
{
|
||||
writer.WriteLine(string.Format("{0}: {1}", key, request.Headers[key]));
|
||||
}
|
||||
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
|
||||
private static void WriteBody(HttpRequest request, StringWriter writer)
|
||||
{
|
||||
StreamReader reader = new StreamReader(request.InputStream);
|
||||
|
||||
try
|
||||
{
|
||||
string body = reader.ReadToEnd();
|
||||
writer.WriteLine(body);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.BaseStream.Position = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -326,76 +326,3 @@ namespace Swarmops.Pages.Security
|
||||
}
|
||||
|
||||
|
||||
namespace System.Web.ExtensionMethods
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for HTTP Request.
|
||||
/// <remarks>
|
||||
/// See the HTTP 1.1 specification http://www.w3.org/Protocols/rfc2616/rfc2616.html
|
||||
/// for details of implementation decisions.
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
public static class HttpRequestExtensions
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Dump the raw http request to a string.
|
||||
/// </summary>
|
||||
/// <param name="request">The <see cref="HttpRequest"/> that should be dumped. </param>
|
||||
/// <returns>The raw HTTP request.</returns>
|
||||
public static string ToRaw(this HttpRequest request)
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
WriteStartLine(request, writer);
|
||||
WriteHeaders(request, writer);
|
||||
WriteBody(request, writer);
|
||||
|
||||
return writer.ToString();
|
||||
}
|
||||
|
||||
public static string GetBody(this HttpRequest request)
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
WriteBody(request, writer);
|
||||
|
||||
return writer.ToString();
|
||||
}
|
||||
|
||||
private static void WriteStartLine(HttpRequest request, StringWriter writer)
|
||||
{
|
||||
const string SPACE = " ";
|
||||
|
||||
writer.Write(request.HttpMethod);
|
||||
writer.Write(SPACE + request.Url);
|
||||
writer.WriteLine(SPACE + request.ServerVariables["SERVER_PROTOCOL"]);
|
||||
}
|
||||
|
||||
|
||||
private static void WriteHeaders(HttpRequest request, StringWriter writer)
|
||||
{
|
||||
foreach (string key in request.Headers.AllKeys)
|
||||
{
|
||||
writer.WriteLine(string.Format("{0}: {1}", key, request.Headers[key]));
|
||||
}
|
||||
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
|
||||
private static void WriteBody(HttpRequest request, StringWriter writer)
|
||||
{
|
||||
StreamReader reader = new StreamReader(request.InputStream);
|
||||
|
||||
try
|
||||
{
|
||||
string body = reader.ReadToEnd();
|
||||
writer.WriteLine(body);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.BaseStream.Position = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user