diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-03-05 21:49:48 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-03-05 21:49:48 -0800 |
commit | c8ddd3b2a4e4aa1a90c867c619845ffb2d967a4c (patch) | |
tree | e24ac49b3b18a04fb9bbfe8b970063b3b3f6ab7a /src/DotNetOpenAuth.Core | |
parent | d0f15854c8fda26fd1b5d561a7f7a8316ff3e830 (diff) | |
download | DotNetOpenAuth-c8ddd3b2a4e4aa1a90c867c619845ffb2d967a4c.zip DotNetOpenAuth-c8ddd3b2a4e4aa1a90c867c619845ffb2d967a4c.tar.gz DotNetOpenAuth-c8ddd3b2a4e4aa1a90c867c619845ffb2d967a4c.tar.bz2 |
Fixed StyleCop messages.
Diffstat (limited to 'src/DotNetOpenAuth.Core')
-rw-r--r-- | src/DotNetOpenAuth.Core/Messaging/HttpRequestHeaders.cs | 10 | ||||
-rw-r--r-- | src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs | 96 | ||||
-rw-r--r-- | src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs | 25 | ||||
-rw-r--r-- | src/DotNetOpenAuth.Core/Requires.cs | 1 |
4 files changed, 120 insertions, 12 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/HttpRequestHeaders.cs b/src/DotNetOpenAuth.Core/Messaging/HttpRequestHeaders.cs index 8da8013..9579a81 100644 --- a/src/DotNetOpenAuth.Core/Messaging/HttpRequestHeaders.cs +++ b/src/DotNetOpenAuth.Core/Messaging/HttpRequestHeaders.cs @@ -1,8 +1,8 @@ -// ----------------------------------------------------------------------- -// <copyright file="HttpRequestHeaders.cs" company=""> -// TODO: Update copyright text. +//----------------------------------------------------------------------- +// <copyright file="HttpRequestHeaders.cs" company="Andrew Arnott"> +// Copyright (c) Andrew Arnott. All rights reserved. // </copyright> -// ----------------------------------------------------------------------- +//----------------------------------------------------------------------- namespace DotNetOpenAuth.Messaging { using System; @@ -11,7 +11,7 @@ namespace DotNetOpenAuth.Messaging { using System.Text; /// <summary> - /// TODO: Update summary. + /// Well known HTTP headers. /// </summary> internal static class HttpRequestHeaders { /// <summary> diff --git a/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs b/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs index fc86728..ed948ce 100644 --- a/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs +++ b/src/DotNetOpenAuth.Core/Messaging/HttpRequestInfo.cs @@ -26,18 +26,41 @@ namespace DotNetOpenAuth.Messaging { /// of our one. /// </remarks> public class HttpRequestInfo : HttpRequestBase { + /// <summary> + /// The HTTP verb in the request. + /// </summary> private readonly string httpMethod; + /// <summary> + /// The full request URL. + /// </summary> private readonly Uri requestUri; - private readonly NameValueCollection queryString; - + /// <summary> + /// The HTTP headers. + /// </summary> private readonly NameValueCollection headers; + /// <summary> + /// The variables defined in the query part of the URL. + /// </summary> + private readonly NameValueCollection queryString; + + /// <summary> + /// The POSTed form variables. + /// </summary> private readonly NameValueCollection form; + /// <summary> + /// The server variables collection. + /// </summary> private readonly NameValueCollection serverVariables; + /// <summary> + /// Initializes a new instance of the <see cref="HttpRequestInfo"/> class. + /// </summary> + /// <param name="request">The request.</param> + /// <param name="requestUri">The request URI.</param> internal HttpRequestInfo(HttpRequestMessageProperty request, Uri requestUri) { Requires.NotNull(request, "request"); Requires.NotNull(requestUri, "requestUri"); @@ -51,6 +74,13 @@ namespace DotNetOpenAuth.Messaging { Reporting.RecordRequestStatistics(this); } + /// <summary> + /// Initializes a new instance of the <see cref="HttpRequestInfo"/> class. + /// </summary> + /// <param name="httpMethod">The HTTP method.</param> + /// <param name="requestUri">The request URI.</param> + /// <param name="form">The form variables.</param> + /// <param name="headers">The HTTP headers.</param> internal HttpRequestInfo(string httpMethod, Uri requestUri, NameValueCollection form = null, NameValueCollection headers = null) { Requires.NotNullOrEmpty(httpMethod, "httpMethod"); Requires.NotNull(requestUri, "requestUri"); @@ -80,6 +110,13 @@ namespace DotNetOpenAuth.Messaging { Reporting.RecordRequestStatistics(this); } + /// <summary> + /// Initializes a new instance of the <see cref="HttpRequestInfo"/> class. + /// </summary> + /// <param name="httpMethod">The HTTP method.</param> + /// <param name="requestUri">The request URI.</param> + /// <param name="headers">The headers.</param> + /// <param name="inputStream">The input stream.</param> internal HttpRequestInfo(string httpMethod, Uri requestUri, NameValueCollection headers, Stream inputStream) { Requires.NotNullOrEmpty(httpMethod, "httpMethod"); Requires.NotNull(requestUri, "requestUri"); @@ -94,50 +131,105 @@ namespace DotNetOpenAuth.Messaging { Reporting.RecordRequestStatistics(this); } + /// <summary> + /// Gets the HTTP method. + /// </summary> public override string HttpMethod { get { return this.httpMethod; } } + /// <summary> + /// Gets the headers. + /// </summary> public override NameValueCollection Headers { get { return this.headers; } } + /// <summary> + /// Gets the URL. + /// </summary> public override Uri Url { get { return this.requestUri; } } + /// <summary> + /// Gets the raw URL. + /// </summary> public override string RawUrl { get { return this.requestUri.AbsolutePath + this.requestUri.Query; } } + /// <summary> + /// Gets the form. + /// </summary> public override NameValueCollection Form { get { return this.form; } } + /// <summary> + /// Gets the query string. + /// </summary> public override NameValueCollection QueryString { get { return this.queryString; } } + /// <summary> + /// Gets the server variables. + /// </summary> public override NameValueCollection ServerVariables { get { return this.serverVariables; } } + /// <summary> + /// Creates an <see cref="HttpRequestBase"/> instance that describes the specified HTTP request. + /// </summary> + /// <param name="request">The request.</param> + /// <param name="requestUri">The request URI.</param> + /// <returns>An instance of <see cref="HttpRequestBase"/>.</returns> public static HttpRequestBase Create(HttpRequestMessageProperty request, Uri requestUri) { return new HttpRequestInfo(request, requestUri); } + /// <summary> + /// Creates an <see cref="HttpRequestBase"/> instance that describes the specified HTTP request. + /// </summary> + /// <param name="listenerRequest">The listener request.</param> + /// <returns>An instance of <see cref="HttpRequestBase"/>.</returns> public static HttpRequestBase Create(HttpListenerRequest listenerRequest) { return new HttpRequestInfo(listenerRequest); } + /// <summary> + /// Creates an <see cref="HttpRequestBase"/> instance that describes the specified HTTP request. + /// </summary> + /// <param name="httpMethod">The HTTP method.</param> + /// <param name="requestUri">The request URI.</param> + /// <param name="form">The form variables.</param> + /// <param name="headers">The HTTP headers.</param> + /// <returns>An instance of <see cref="HttpRequestBase"/>.</returns> public static HttpRequestBase Create(string httpMethod, Uri requestUri, NameValueCollection form = null, NameValueCollection headers = null) { return new HttpRequestInfo(httpMethod, requestUri, form, headers); } + /// <summary> + /// Creates an <see cref="HttpRequestBase"/> instance that describes the specified HTTP request. + /// </summary> + /// <param name="httpMethod">The HTTP method.</param> + /// <param name="requestUri">The request URI.</param> + /// <param name="headers">The headers.</param> + /// <param name="inputStream">The input stream.</param> + /// <returns>An instance of <see cref="HttpRequestBase"/>.</returns> public static HttpRequestBase Create(string httpMethod, Uri requestUri, NameValueCollection headers, Stream inputStream) { return new HttpRequestInfo(httpMethod, requestUri, headers, inputStream); } + /// <summary> + /// Reads name=value pairs from the POSTed form entity when the HTTP headers indicate that that is the payload of the entity. + /// </summary> + /// <param name="httpMethod">The HTTP method.</param> + /// <param name="headers">The headers.</param> + /// <param name="inputStream">The input stream.</param> + /// <returns>The non-null collection of form variables.</returns> private static NameValueCollection ParseFormData(string httpMethod, NameValueCollection headers, Stream inputStream) { Requires.NotNullOrEmpty(httpMethod, "httpMethod"); Requires.NotNull(headers, "headers"); diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs index bff016b..664db71 100644 --- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs +++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs @@ -1481,7 +1481,14 @@ namespace DotNetOpenAuth.Messaging { return dictionary; } - internal static NameValueCollection ToNameValueCollection(this IDictionary<string,string> data) { + /// <summary> + /// Converts a dictionary to a <see cref="NameValueCollection"/> + /// </summary> + /// <param name="data">The existing dictionary.</param> + /// <returns>The new collection.</returns> + internal static NameValueCollection ToNameValueCollection(this IDictionary<string, string> data) { + Requires.NotNull(data, "data"); + var nvc = new NameValueCollection(); foreach (var entry in data) { nvc.Add(entry.Key, entry.Value); @@ -1672,7 +1679,10 @@ namespace DotNetOpenAuth.Messaging { /// <summary> /// Gets the query data from the original request (before any URL rewriting has occurred.) /// </summary> - /// <returns>A <see cref="NameValueCollection"/> containing all the parameters in the query string.</returns> + /// <param name="request">The request.</param> + /// <returns> + /// A <see cref="NameValueCollection"/> containing all the parameters in the query string. + /// </returns> internal static NameValueCollection GetQueryStringBeforeRewriting(this HttpRequestBase request) { // This request URL may have been rewritten by the host site. // For openid protocol purposes, we really need to look at @@ -1692,8 +1702,10 @@ namespace DotNetOpenAuth.Messaging { /// Gets a value indicating whether the request's URL was rewritten by ASP.NET /// or some other module. /// </summary> + /// <param name="request">The request.</param> + /// <returns>A value indicating whether there is evidence that the URL of the request has been changed to some internal server (farm) representation.</returns> /// <value> - /// <c>true</c> if this request's URL was rewritten; otherwise, <c>false</c>. + /// <c>true</c> if this request's URL was rewritten; otherwise, <c>false</c>. /// </value> internal static bool GetIsUrlRewritten(this HttpRequestBase request) { return request.Url != GetPublicFacingUrl(request); @@ -1759,13 +1771,16 @@ namespace DotNetOpenAuth.Messaging { /// <summary> /// Gets the query or form data from the original request (before any URL rewriting has occurred.) /// </summary> - /// <returns>A set of name=value pairs.</returns> + /// <param name="request">The request.</param> + /// <returns> + /// A set of name=value pairs. + /// </returns> [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Expensive call")] internal static NameValueCollection GetQueryOrForm(this HttpRequestBase request) { Requires.NotNull(request, "request"); return request.HttpMethod == "GET" ? GetQueryStringBeforeRewriting(request) : request.Form; } - + /// <summary> /// Creates a symmetric algorithm for use in encryption/decryption. /// </summary> diff --git a/src/DotNetOpenAuth.Core/Requires.cs b/src/DotNetOpenAuth.Core/Requires.cs index 41720c2..1aa0cf8 100644 --- a/src/DotNetOpenAuth.Core/Requires.cs +++ b/src/DotNetOpenAuth.Core/Requires.cs @@ -24,6 +24,7 @@ namespace DotNetOpenAuth { /// <typeparam name="T">The type of the parameter</typeparam> /// <param name="value">The value.</param> /// <param name="parameterName">Name of the parameter.</param> + /// <returns>The tested value, guaranteed to not be null.</returns> #if !CLR4 [ContractArgumentValidator] #endif |