Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #54 from teci/DetailedExcpetion

Detailed exception and keys length limit
  • Loading branch information...
commit 567367bd1ee8e52d22f2fd6609cd9ee057f383a9 2 parents b973418 + 5247d4a
@soitgoes authored
View
11 LoveSeat/CouchException.cs
@@ -8,18 +8,25 @@ public class CouchException : System.Exception
private readonly HttpWebRequest request;
private readonly HttpWebResponse response;
- public CouchException(HttpWebRequest request, HttpWebResponse response, string mesg) : base(mesg)
+ public CouchException(HttpWebRequest request, HttpWebResponse response, string mesg)
+ : base(BuildExceptionMessage(mesg, request))
{
this.request = request;
this.response = response;
}
public CouchException(HttpWebRequest request, CouchResponse response, string mesg)
- : base(mesg)
+ : base(BuildExceptionMessage(mesg, request))
{
}
public HttpWebRequest Request { get { return request; } }
public HttpWebResponse Response { get { return response; } }
+
+ private static string BuildExceptionMessage(string msg, HttpWebRequest request)
+ {
+ string excpetionMsg = string.Format("{0} {1}", request.RequestUri, msg);
+ return excpetionMsg;
+ }
}
}
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,6 +104,10 @@ 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
@@ -110,7 +115,7 @@ public override string ToString()
/// </summary>
internal bool isAtKeysSizeLimit
{
- get { return Keys != null && Keys.Any() && Keys.ToString().Length > KeysLengthLimit; }
+ get { return Keys != null && Keys.Any() && BuildKeysString().Length > KeysLengthLimit; }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.