meafmira / bs-axios

Bucklescript bindings for axios
71 stars 23 forks source link

Removing/overriding default headers #19

Open viguan opened 5 years ago

viguan commented 5 years ago

Following the example for Headers in the readme:

let headers = Axios.Headers.fromDict(headersDict);
Axios.getc("https://example.com", Axios.makeConfig(~headers, ()));

I noticed that Axios appends default headers, like Accept: application/json, text/plain, */*. The service I am trying to connect with doesn't accept the Accept headers, and throws me a 406 -- Not Acceptable error.

Also, when I set the header dict like dict.set("accept", "*/*"), I noticed that the Accept header value gets appended with */* instead of being replace. The Accept header ultimately looks like: Accept: application/json, text/plain, */*, */*.

I noticed that there is a way to remove the default header for the js library: https://stackoverflow.com/questions/46656474/axios-remove-headers-authorization-in-1-call-only

Is there a way to remove default headers? Or override them?

meafmira commented 5 years ago

Hello. Thank you for issue. I'll try to fix it soon