Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

CouchClient.HasDatabase Method #15

Closed
npateman opened this Issue · 2 comments

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
Owner

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

@soitgoes soitgoes closed this in 36fed28
@soitgoes
Owner

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
Something went wrong with that request. Please try again.