restangular
restangular copied to clipboard
Overwrite default headers with undefined
Is there a way to set the default headers to undefined for a single request? I'm well aware of the optional headers ~~withHttpConfig~~, but it ignores undefined value(bug?), i.e. uses the default value, sets it to null when null is used and uses the default value when an empty object literal is given as the headers.
withHttpConfig doesn't in general work with headers, i.e. no provided value is used.
Use case: The server uses the Authorization header as a scoping mechanism, where it has a different scope depending on whether there is an Authorization header.
We deal with the scoping by using default headers, but sometimes we've to do a single request in a different scope and would rather not unset and set default headers for that matter.
This sounds like a bug; can you please provide a live example on Plunkr?
https://plnkr.co/edit/5HiwmcxBGmd2wudbsPhK?p=preview
Use console to check the resulting request headers. I've provided comments in the script.
I've provided wrong description to the problem, so allow me correct myself.
The withHttpConfig in general doesn't work with headers. No provided header is used. The behavior described above is for the optional headers one can provide for most of the defined request methods provided by restangular.
Yikes. That is a bug. Would you mind submitting a PR to fix this?
Is this fixed yet?