Socket
Socket
Sign inDemoInstall

gaxios

Package Overview
Dependencies
15
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.1.0 to 4.2.0

45

build/src/gaxios.js

@@ -33,2 +33,17 @@ "use strict";

}
function hasBuffer() {
return typeof Buffer !== 'undefined';
}
function hasHeader(options, header) {
return !!getHeader(options, header);
}
function getHeader(options, header) {
header = header.toLowerCase();
for (const key of Object.keys((options === null || options === void 0 ? void 0 : options.headers) || {})) {
if (header === key.toLowerCase()) {
return options.headers[key];
}
}
return undefined;
}
let HttpsProxyAgent;

@@ -184,17 +199,23 @@ function loadProxy() {

}
else if (typeof opts.data === 'object') {
opts.body = JSON.stringify(opts.data);
// Allow the user to specifiy their own content type,
// such as application/json-patch+json; for historical reasons this
// content type must currently be a json type, as we are relying on
// application/x-www-form-urlencoded (which is incompatible with
// upstream GCP APIs) being rewritten to application/json.
//
// TODO: refactor upstream dependencies to stop relying on this
// side-effect.
if (!opts.headers['Content-Type'] ||
!opts.headers['Content-Type'].includes('json')) {
else if (hasBuffer() && Buffer.isBuffer(opts.data)) {
// Do not attempt to JSON.stringify() a Buffer:
opts.body = opts.data;
if (!hasHeader(opts, 'Content-Type')) {
opts.headers['Content-Type'] = 'application/json';
}
}
else if (typeof opts.data === 'object') {
// If www-form-urlencoded content type has been set, but data is
// provided as an object, serialize the content using querystring:
if (getHeader(opts, 'content-type') ===
'application/x-www-form-urlencoded') {
opts.body = opts.paramsSerializer(opts.data);
}
else {
if (!hasHeader(opts, 'Content-Type')) {
opts.headers['Content-Type'] = 'application/json';
}
opts.body = JSON.stringify(opts.data);
}
}
else {

@@ -201,0 +222,0 @@ opts.body = opts.data;

# Changelog
## [4.2.0](https://www.github.com/googleapis/gaxios/compare/v4.1.0...v4.2.0) (2021-03-01)
### Features
* handle application/x-www-form-urlencoded/Buffer ([#374](https://www.github.com/googleapis/gaxios/issues/374)) ([ce21e9c](https://www.github.com/googleapis/gaxios/commit/ce21e9ccd228578a9f90bb2fddff797cec4a9402))
## [4.1.0](https://www.github.com/googleapis/gaxios/compare/v4.0.1...v4.1.0) (2020-12-08)

@@ -4,0 +11,0 @@

{
"name": "gaxios",
"version": "4.1.0",
"version": "4.2.0",
"description": "A simple common HTTP client specifically for Google APIs and services.",

@@ -79,3 +79,3 @@ "main": "build/src/index.js",

"null-loader": "^4.0.0",
"puppeteer": "^5.0.0",
"puppeteer": "^8.0.0",
"sinon": "^9.0.0",

@@ -82,0 +82,0 @@ "tmp": "0.2.1",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc