From e6579af7e959d6797f2931ffb68f79191363d66d Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 30 Oct 2014 22:17:11 +0100 Subject: [PATCH] Yet Yet More BitId Debugging --- Logic/Logic.csproj | 1 + Logic/Support/ExtensionMethods.cs | 73 +++++++++++++++++++++++++++++++ Site5/Security/Login.aspx.cs | 73 ------------------------------- 3 files changed, 74 insertions(+), 73 deletions(-) create mode 100644 Logic/Support/ExtensionMethods.cs diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index 00570158..4ed860f2 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -226,6 +226,7 @@ + diff --git a/Logic/Support/ExtensionMethods.cs b/Logic/Support/ExtensionMethods.cs new file mode 100644 index 00000000..1874b8d1 --- /dev/null +++ b/Logic/Support/ExtensionMethods.cs @@ -0,0 +1,73 @@ +namespace System.Web.ExtensionMethods +{ + /// + /// Extension methods for HTTP Request. + /// + /// See the HTTP 1.1 specification http://www.w3.org/Protocols/rfc2616/rfc2616.html + /// for details of implementation decisions. + /// + /// + public static class HttpRequestExtensions + { + + /// + /// Dump the raw http request to a string. + /// + /// The that should be dumped. + /// The raw HTTP request. + 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; + } + } + } +} diff --git a/Site5/Security/Login.aspx.cs b/Site5/Security/Login.aspx.cs index f7fc44d9..97f0bceb 100644 --- a/Site5/Security/Login.aspx.cs +++ b/Site5/Security/Login.aspx.cs @@ -326,76 +326,3 @@ namespace Swarmops.Pages.Security } -namespace System.Web.ExtensionMethods -{ - /// - /// Extension methods for HTTP Request. - /// - /// See the HTTP 1.1 specification http://www.w3.org/Protocols/rfc2616/rfc2616.html - /// for details of implementation decisions. - /// - /// - public static class HttpRequestExtensions - { - - /// - /// Dump the raw http request to a string. - /// - /// The that should be dumped. - /// The raw HTTP request. - 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; - } - } - } -}