ethanent / phin

Node HTTP client
MIT License
576 stars 33 forks source link

not possible to pass data as buffer #30

Closed benkroeger closed 5 years ago

benkroeger commented 5 years ago

it seems that when passing a Buffer in const options = { data: Buffer.from('foo') }, centra would handle it as json since typeof Buffer resolves to object. I see two solutions here:

  1. default sendAs to 'raw', which would become a breaking change (since currently 'json' is assumed
  2. add options.buffer and leave options.data as is. When options.buffer is used, call req.body(options.buffer, 'raw')

Thoughts? Happy to provide PR after discussion about suggested options

ethanent commented 5 years ago

Thanks for submitting the issue, @benkroeger!

Patch 3.2.1 has resolved the issue as now buffers are sent in their intended form: as binary data! This patch is now available on NPM. :)