creationix / couch-client

A minimal CouchDB client that easy and powerful
MIT License
101 stars 9 forks source link

Custom headers #20

Closed diversario closed 13 years ago

diversario commented 13 years ago

I added functionality to specify custom headers. This should be a non-breaking change.

In this version, body can be either JS object as it was before or an array. In case of an object all changes are just ignored and everything works as before. In case of an array, first elemens is treated as body and second is treated as customHeaders.

body can be omitted by setting first element of the array to {}.

Examples: body only: {"name": "value"} headers only: [{}, {"Content-Type": "image/png", "Header": "Value"}] body and headers: [{"name": "value"}, {"Content-Type": "image/png", "Header": "Value"}]

diversario commented 13 years ago

Request body is still mangled at this point, I'm closing this request for now.

diversario commented 13 years ago

This can be merged for custom headers functionality, but binary attachments won't work because body is parsed into JSON object. I'll test to see if it's possible to pass body as a Buffer object.

candland commented 13 years ago

I tried to merge but the basicTests.js file doesn't run w/ these changes. Also can you add some test cases for this?

diversario commented 13 years ago

Yeah, I'll do that.

diversario commented 13 years ago

Closing this because there's a newer one for 0.1.0 branch.