gaxios icon indicating copy to clipboard operation
gaxios copied to clipboard

`Content-Type` response header is ignored

Open JustinBeckwith opened this issue 4 years ago • 2 comments

Related to https://github.com/googleapis/google-api-nodejs-client/issues/1777.

We accept a responseType as part of the request config that dictates what processing we do with the response body before returning it in res.data. By default, we just assume json if not told otherwise. The problem pops up when the content type is defined in a response header, and we just ignore it. When an application/gzip content type comes back in a header, I'd argue we shouldn't try JSON.parse-ing that by default :)

JustinBeckwith avatar Jan 29 '20 22:01 JustinBeckwith

cc @bcoe

JustinBeckwith avatar Jan 29 '20 22:01 JustinBeckwith

adding Accept parameter to header prevent adding json content type by gaxios.

like "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.",

fullflash avatar Nov 15 '20 14:11 fullflash