silkimen / cordova-plugin-advanced-http

Cordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning!
MIT License
400 stars 321 forks source link

[Bug] [Browser] requests not working correctly because request options are not processed correctly #438

Closed silkimen closed 3 years ago

silkimen commented 3 years ago

Requests are not working correctly because request options are not processed correctly. The offset is off by one, because second timeout parameter is not implemented here.

// line 177ff. in public-interface.js
helpers.processData(options.data, options.serializer, function (data) {
  exec(onSuccess, onFail, 'CordovaHttpPlugin', options.method, [url, data, options.serializer, headers, options.connectTimeout, options.readTimeout, options.followRedirect, options.responseType, reqId]);
});

// maps to following cordova proxy implementation line 154ff. in cordova-http-plugin.js 
var data, serializer, headers, timeout, followRedirect, responseType, reqId;
var url = opts[0];

if (withData) {
  data = opts[1];
  serializer = opts[2];
  headers = opts[3];
  timeout = opts[4]; // should be connectTimeout
  followRedirect = opts[5]; // following offsets are wrong because readTimeout is missing here
  responseType = opts[6];
  reqId = opts[7];
} else {
  headers = opts[1];
  timeout = opts[2]; // see above
  followRedirect = opts[3];
  responseType = opts[4];
  reqId = opts[5];
}
silkimen commented 3 years ago

Will be fixed in v3.2.2.