Skip to content
Browse files

Fix bug in ViewOptions which check the wrong keys length.

The property isAtKeysSizeLimit always check the ToString of Keys which return CLR type name.
Thanks to Ian1971 we fix the bug and now checking the actual keys string.
Also increase the keys length limit to 6k.
  • Loading branch information...
1 parent b8b3669 commit 5247d4af2b911b2b903b8947873402fe4484881d @ido-ran ido-ran committed Oct 22, 2013
Showing with 10 additions and 5 deletions.
  1. +1 −1 LoveSeat/Properties/AssemblyInfo.cs
  2. +9 −4 LoveSeat/ViewOptions.cs
View
2 LoveSeat/Properties/AssemblyInfo.cs
@@ -33,4 +33,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.2.0")]
+[assembly: AssemblyFileVersion("1.0.2.1")]
View
13 LoveSeat/ViewOptions.cs
@@ -12,9 +12,10 @@ namespace LoveSeat
public class ViewOptions : IViewOptions
{
/// <summary>
- /// Limit the length of the Keys parameter to 1800 characters.
+ /// Limit the length of the Keys parameter to 6000 characters.
+ /// Services such as Cloudant limit the URL length to 8k so 6000 should be on the safe side.
/// </summary>
- private const int KeysLengthLimit = 1800;
+ private const int KeysLengthLimit = 6000;
public ViewOptions()
{
@@ -56,7 +57,7 @@ public override string ToString()
if ((Key != null) && (Key.Count > 0))
result += "&key=" + Key.ToString();
if (Keys != null && !isAtKeysSizeLimit)
- result += "&keys=[" + String.Join(",", Keys.Select(k => k.ToString()).ToArray()) + "]";
+ result += "&keys=[" + BuildKeysString() + "]";
if ((StartKey != null) && (StartKey.Count > 0))
if((StartKey.Count == 1) && (EndKey.Count > 1))
result += "&startkey=[" + StartKey.ToString() + "]";
@@ -103,14 +104,18 @@ public override string ToString()
return result.Length < 1 ? "" : "?" + result.Substring(1);
}
+ private string BuildKeysString() {
+ return String.Join(",", Keys.Select(k => k.ToString()).ToArray());
+ }
+
/// <summary>
/// Get indication if the length of keys parameter went over the allowed limit.
/// This indicate that the Keys parameter should be encoded in the requeqst body
/// instead of URL paraemter.
/// </summary>
internal bool isAtKeysSizeLimit
{
- get { return Keys != null && Keys.Any() && Keys.ToString().Length > KeysLengthLimit; }
+ get { return Keys != null && Keys.Any() && BuildKeysString().Length > KeysLengthLimit; }
}
}

0 comments on commit 5247d4a

Please sign in to comment.
Something went wrong with that request. Please try again.