summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs')
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
index a4aff73..619f252 100644
--- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
@@ -1611,6 +1611,19 @@ namespace DotNetOpenAuth.Messaging {
}
/// <summary>
+ /// Enumerates all members of the collection as key=value pairs.
+ /// </summary>
+ internal static IEnumerable<KeyValuePair<string, string>> AsKeyValuePairs(this NameValueCollection nvc) {
+ Requires.NotNull(nvc, "nvc");
+
+ foreach (string key in nvc) {
+ foreach (string value in nvc.GetValues(key)) {
+ yield return new KeyValuePair<string, string>(key, value);
+ }
+ }
+ }
+
+ /// <summary>
/// Converts a <see cref="NameValueCollection"/> to an IDictionary&lt;string, string&gt;.
/// </summary>
/// <param name="nvc">The NameValueCollection to convert. May be null.</param>
@@ -1881,6 +1894,11 @@ namespace DotNetOpenAuth.Messaging {
internal static string EscapeUriDataStringRfc3986(string value) {
Requires.NotNull(value, "value");
+ // fast path for empty values.
+ if (value.Length == 0) {
+ return value;
+ }
+
// Start with RFC 2396 escaping by calling the .NET method to do the work.
// This MAY sometimes exhibit RFC 3986 behavior (according to the documentation).
// If it does, the escaping we do that follows it will be a no-op since the