summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs
diff options
context:
space:
mode:
authorMicrosoft <aspnet@microsoft.com>2011-12-20 17:52:24 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2012-03-01 19:36:32 -0800
commit1197a5c95f0af0ced8339ae07ef6b3980532c8d7 (patch)
treeb771327d73f970665e28c9679b2baf6c2e0a9b67 /src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs
parent67e1a42ffe2ed7ac2bf99c703f17e4406cc35921 (diff)
downloadDotNetOpenAuth-1197a5c95f0af0ced8339ae07ef6b3980532c8d7.zip
DotNetOpenAuth-1197a5c95f0af0ced8339ae07ef6b3980532c8d7.tar.gz
DotNetOpenAuth-1197a5c95f0af0ced8339ae07ef6b3980532c8d7.tar.bz2
Make changes per discussion. Remove the DNOA.WebPages project. Rename DNOA.Web to DNOA.AspNet.
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs')
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs b/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs
index 0cf37a5..ad5b832 100644
--- a/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs
@@ -245,7 +245,8 @@ namespace DotNetOpenAuth.Messaging {
if (this.InputStream.CanSeek) {
this.InputStream.Seek(originalPosition, SeekOrigin.Begin);
}
- } else {
+ }
+ else {
this.form = new NameValueCollection();
}
}
@@ -280,7 +281,8 @@ namespace DotNetOpenAuth.Messaging {
if (!this.IsUrlRewritten) {
// No rewriting has taken place.
this.queryStringBeforeRewriting = this.QueryString;
- } else {
+ }
+ else {
// Rewriting detected! Recover the original request URI.
ErrorUtilities.VerifyInternal(this.UrlBeforeRewriting != null, "UrlBeforeRewriting is null, so the query string cannot be determined.");
this.queryStringBeforeRewriting = HttpUtility.ParseQueryString(this.UrlBeforeRewriting.Query);
@@ -317,6 +319,24 @@ namespace DotNetOpenAuth.Messaging {
/// is a read-only kind of <see cref="NameValueCollection"/>.
/// </remarks>
internal static Uri GetPublicFacingUrl(HttpRequest request, NameValueCollection serverVariables) {
+ return GetPublicFacingUrl(new HttpRequestWrapper(request), serverVariables);
+ }
+
+ /// <summary>
+ /// Gets the public facing URL for the given incoming HTTP request.
+ /// </summary>
+ /// <param name="request">The request.</param>
+ /// <param name="serverVariables">The server variables to consider part of the request.</param>
+ /// <returns>
+ /// The URI that the outside world used to create this request.
+ /// </returns>
+ /// <remarks>
+ /// Although the <paramref name="serverVariables"/> value can be obtained from
+ /// <see cref="HttpRequest.ServerVariables"/>, it's useful to be able to pass them
+ /// in so we can simulate injected values from our unit tests since the actual property
+ /// is a read-only kind of <see cref="NameValueCollection"/>.
+ /// </remarks>
+ internal static Uri GetPublicFacingUrl(HttpRequestBase request, NameValueCollection serverVariables) {
Requires.NotNull(request, "request");
Requires.NotNull(serverVariables, "serverVariables");
@@ -336,7 +356,8 @@ namespace DotNetOpenAuth.Messaging {
publicRequestUri.Host = hostAndPort.Host;
publicRequestUri.Port = hostAndPort.Port; // CC missing Uri.Port contract that's on UriBuilder.Port
return publicRequestUri.Uri;
- } else {
+ }
+ else {
// Failover to the method that works for non-web farm enviroments.
// We use Request.Url for the full path to the server, and modify it
// with Request.RawUrl to capture both the cookieless session "directory" if it exists
@@ -358,7 +379,8 @@ namespace DotNetOpenAuth.Messaging {
NameValueCollection query;
if (this.HttpMethod == "GET") {
query = this.QueryStringBeforeRewriting;
- } else {
+ }
+ else {
query = this.Form;
}
return query;
@@ -396,7 +418,8 @@ namespace DotNetOpenAuth.Messaging {
foreach (string key in pairs) {
try {
headers.Add(key, pairs[key]);
- } catch (ArgumentException ex) {
+ }
+ catch (ArgumentException ex) {
Logger.Messaging.WarnFormat(
"{0} thrown when trying to add web header \"{1}: {2}\". {3}",
ex.GetType().Name,