CouchClient.HasDatabase Method #15

Closed
npateman opened this Issue Oct 13, 2011 · 2 comments

Comments

Projects
None yet
2 participants
@npateman

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);
        }
        else
            throw new Exception(pDocResult["error"].Value<String>());
    }
@soitgoes

This comment has been minimized.

Show comment
Hide comment
@soitgoes

soitgoes Oct 13, 2011

Owner

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

Owner

soitgoes commented Oct 13, 2011

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

@soitgoes

This comment has been minimized.

Show comment
Hide comment
@soitgoes

soitgoes Dec 13, 2011

Owner

I've merged in your method slightly altered.
36fed28

Owner

soitgoes commented Dec 13, 2011

I've merged in your method slightly altered.
36fed28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment