Option to not "Accept: application/json"
paulmakepeace opened this issue · 2 comments
def request(method, path, opts = {})
headers = (opts[:headers] || {}).dup
headers["X-Auth-Token"] = auth_token
headers["Accept"] = "application/json"
I'd like to be able to not set this Accept
header; there are cases where the "\n"-delimited data is just fine and I don't want to incur the JSON traffic & parsing cost. I also have seen response truncation that breaks JSON parsing too.
The quick hack answer is headers["Accept"] ||= "application/json"
; maybe a less hacky solution is json: false
in opts
or a attr in the SwiftClient object. Happy to do a PR for any of those or better idea.
hi, thanks for opening and willingness to contribute. I think the ||=
solution is just fine. However, the paginate
method should then explicitly set it, as it requires json to work. Looking forward for a PR.
I tried the ||=
and it ended up messy and felt too much like "leaky abstraction". See what you think...