benoitc / couchbeam

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

#114 Fix; couchbeam:reply_att/1 handles 200 & 201 as success #115

Closed epappas closed 9 years ago

epappas commented 9 years ago

CouchDB upon the end of streaming, send 201 as success. Couchbeam should handle such cases as success. So the following part:

reply_att({ok, 200, _, Ref}) ->
    {[{<<"ok">>, true}|R]} = couchbeam_httpc:json_body(Ref),
            {ok, {R}};

Becomes:

reply_att({ok, Status, _, Ref}) when Status >= 200 andalso Status < 300 ->
  {[{<<"ok">>, true}|R]} = couchbeam_httpc:json_body(Ref),
  {ok, {R}};

Maybe a the same should be applied on 30x & 10x responses?

Cheers.