Skip to content

Commit

Permalink
BugFix #15: it was causing strange timeout issues to occur with subse…
Browse files Browse the repository at this point in the history
…quent calls.
  • Loading branch information
Martin Murphy committed Dec 13, 2011
1 parent 56b7af6 commit 36fed28
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions LoveSeat/CouchClient.cs
Expand Up @@ -166,15 +166,21 @@ public void DeleteAdminUser(string userToDelete)
/// </summary>
/// <param name="databaseName"></param>
/// <returns></returns>
public bool HasDatabase(string databaseName)
{
public bool HasDatabase(string databaseName) {
var request = GetRequest(baseUri + databaseName);
request.Timeout = 5000;
var result = request
.Get()
.GetResponse();
return result.StatusCode == HttpStatusCode.OK;
}
request.Timeout = -1;

var response = request.GetResponse();
var pDocResult = new Document(response.GetResponseString());

if (pDocResult["error"] == null) {
return (true);
}
if (pDocResult["error"].Value<String>() == "not_found") {
return (false);
}
throw new Exception(pDocResult["error"].Value<String>());
}

/// <summary>
/// Returns true/false depending on whether or not the user is contained in the _users database
Expand Down

0 comments on commit 36fed28

Please sign in to comment.