mikeal / r2

HTTP client. Spiritual successor to request.
Apache License 2.0
4.45k stars 118 forks source link

Assuming all JSON payloads are application/json is wrong #70

Open inadarei opened 6 years ago

inadarei commented 6 years ago

This is regarding: https://github.com/mikeal/r2/blob/master/index.js#L73

If current code sees that you are passing json it overrides content-type header to be set to application/json. But application/json is not the only JSON media type. There're plenty of others:

  1. HAL http://stateless.co/hal_specification.html
  2. JSON API http://jsonapi.org/
  3. Siren https://github.com/kevinswiber/siren
  4. Hyper http://hyperjson.io/

to name just a few

bcomnes commented 6 years ago

Probably just make the opts.headers override this.