djc / couchdb-python

Python library for working with CouchDB
Other
202 stars 86 forks source link

Server.version() broken for CouchDB 2.0 #303

Closed adrienverge closed 8 years ago

adrienverge commented 8 years ago

At least from version 2.0, it is required to query host:5984/ (not just host:5984) to get the version information:

{"couchdb":"Welcome","version":"2.0.0-RC4","vendor":{"name":"The Apache Software Foundation"}}

If the trailing slash is omitted, it results in an error:

{"error":"not_found","reason":"Database does not exist."}
djc commented 8 years ago

Thanks for the report! To me, this actually seems like a bug in CouchDB. Did you discuss with them? If they can justify this behavior, I'm happy to accept your patch.

adrienverge commented 8 years ago

To me, this actually seems like a bug in CouchDB.

Actually you're right... I'll try to see with them!

djc commented 8 years ago

I filed https://issues.apache.org/jira/browse/COUCHDB-3137.

djc commented 8 years ago

So I am trying to see what CouchDB-Python actually sends in terms of the HTTP request, but it's not making sense to me. Note I'm not running CouchDB-2.0 yet, so I can't exactly reproduce the bug you're seeing. What version of Python are you using? Can you let me know what we send? I've been using variations on this patch to try and debug:

diff --git a/couchdb/http.py b/couchdb/http.py
index 7e6e509..ef49620 100644
--- a/couchdb/http.py
+++ b/couchdb/http.py
@@ -11,6 +11,7 @@
 standard library.
 """

+from __future__ import print_function
 from base64 import b64encode
 from datetime import datetime
 import errno
@@ -310,6 +311,7 @@ class Session(object):
                 conn.putrequest(method, path_query, skip_accept_encoding=True)
                 for header in headers:
                     conn.putheader(header, headers[header])
+                print('BUFFER', conn._buffer)
                 if body is None:
                     conn.endheaders()
                 else:
adrienverge commented 8 years ago

Hey @djc,

When trying to reproduce on a clean setup, I realized the "bug" was due to my nginx conf. There's no problem actually: both CouchDB 2.0 and couchdb-python are working fine.

Really sorry about that,

Adrien

djc commented 8 years ago

Ah! It can happen... Good to hear you've solved the problem.