Skip to content

CouchClient.HasDatabase Method #15

npateman opened this Issue Oct 13, 2011 · 2 comments

2 participants


Hi there,

I had to make a modification to the CouchDatabase.HasDatabase method, as it was it was causing strange timeout issues to occur with subsequent calls. I believe the reason for this is that it was always returning "True" as it was due to CouchDB returning a 200 status code and some error JSON even if it doesn't exist, the method was only checking for a 200 status code.

    public bool HasDatabase(string databaseName)
        var request = GetRequest(baseUri + databaseName);
        request.Timeout = -1;

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

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

Nice catch.. It'd be great if you could send me a pull request for this change.

@soitgoes soitgoes closed this in 36fed28 Dec 13, 2011

I've merged in your method slightly altered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.