benoitc / couchbeam

Apache CouchDB client in Erlang
Other
242 stars 113 forks source link

couchbeam:db_exists/2 was failing #128

Closed epappas closed 9 years ago

epappas commented 9 years ago

In couchbeam:db_exists/2, couchbeam_httpc:db_request/6 is returning a tuple of 4 {ok, Status, Server Resp} instead of a tuple of 3 that was expecting. So db_exist was always returning false.

epappas commented 9 years ago

Strange,

The couchbeam_httpc:db_request/6 makes use of couchbeam_httpc:request/5, which is a proxy of hackney:request/5 that returns {ok, integer(), list(), client_ref()} on success.

Once couchbeam_httpc:db_resp/2 is called, the db_resp({ok, Status, Headers, Ref}=Resp, Expect) case is executed, so the result couchbeam:db_exists/2 is getting such a payload [1] as a result.

The result is valid, but db_exists returns false.

Any ideas?

Thanks!

[1]

{ok, 200,
 [{<<"Server">>,<<"CouchDB/1.6.1 (Erlang OTP/17)">>},
  {<<"Date">>,<<"Sat, 14 Mar 2015 12:02:17 GMT">>},
  {<<"Content-Type">>,<<"application/json">>},
  {<<"Content-Length">>,<<"235">>},
  {<<"Cache-Control">>,<<"must-revalidate">>}],
 #Ref<0.0.0.218>}
epappas commented 9 years ago

Seems that when I was connecting with Options [{basic_auth, {<<"....">>, <<"....">>}}] the response of hackney:request/5 was giving back a different tuple (tuple of 4 instead of 3).

Haven't really track why yet.

benoitc commented 9 years ago

fixed by using latest hackney version.

benoitc commented 9 years ago

Thanks for the ticket and patch anyway :)