@artilleryio/int-core 2.0.10-e07b755 → 2.0.10-f23d4c6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/engine_http.js +23 -6
  2. package/package.json +2 -2
@@ -85,6 +85,10 @@ function HttpEngine(script) {
85
85
  this.config.http = {};
86
86
  }
87
87
 
88
+ if (typeof this.config.http.defaults === 'undefined') {
89
+ this.config.http.defaults = {};
90
+ }
91
+
88
92
  if (typeof this.config.http.cookieJarOptions === 'undefined') {
89
93
  this.config.http.cookieJarOptions = {};
90
94
  }
@@ -197,7 +201,10 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
197
201
  }
198
202
 
199
203
  if (typeof requestSpec.think !== 'undefined') {
200
- return engineUtil.createThink(requestSpec, self.config.defaults.think);
204
+ return engineUtil.createThink(
205
+ requestSpec,
206
+ self.config.http.defaults.think || self.config.defaults.think
207
+ );
201
208
  }
202
209
 
203
210
  if (typeof requestSpec.log !== 'undefined') {
@@ -350,8 +357,11 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
350
357
 
351
358
  // Request.js -> Got.js translation
352
359
  if (params.qs) {
353
- requestParams.searchParams = template(params.qs, context);
360
+ requestParams.searchParams = qs.stringify(
361
+ template(params.qs, context)
362
+ );
354
363
  }
364
+
355
365
  if (typeof params.gzip === 'boolean') {
356
366
  requestParams.decompress = params.gzip;
357
367
  } else {
@@ -384,7 +394,8 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
384
394
 
385
395
  // Assign default headers then overwrite as needed
386
396
  let defaultHeaders = lowcaseKeys(
387
- config.defaults.headers || { 'user-agent': USER_AGENT }
397
+ config.http.defaults.headers ||
398
+ config.defaults.headers || { 'user-agent': USER_AGENT }
388
399
  );
389
400
  const combinedHeaders = _.extend(
390
401
  defaultHeaders,
@@ -808,7 +819,9 @@ function lastRequest(res, requestParams) {
808
819
  HttpEngine.prototype.setInitialContext = function (initialContext) {
809
820
  initialContext._successCount = 0;
810
821
 
811
- initialContext._defaultStrictCapture = this.config.defaults.strictCapture;
822
+ initialContext._defaultStrictCapture =
823
+ this.config.http.defaults.strictCapture ||
824
+ this.config.defaults.strictCapture;
812
825
  initialContext._jar = new tough.CookieJar(
813
826
  null,
814
827
  this.config.http.cookieJarOptions
@@ -816,8 +829,12 @@ HttpEngine.prototype.setInitialContext = function (initialContext) {
816
829
 
817
830
  initialContext._enableCookieJar = false;
818
831
  // If a default cookie is set, we will use the jar straightaway:
819
- if (typeof this.config.defaults.cookie === 'object') {
820
- initialContext._defaultCookie = this.config.defaults.cookie;
832
+ if (
833
+ typeof this.config.http.defaults.cookie === 'object' ||
834
+ typeof this.config.defaults.cookie === 'object'
835
+ ) {
836
+ initialContext._defaultCookie =
837
+ this.config.http.defaults.cookie || this.config.defaults.cookie;
821
838
  initialContext._enableCookieJar = true;
822
839
  }
823
840
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@artilleryio/int-core",
3
- "version": "2.0.10-e07b755",
3
+ "version": "2.0.10-f23d4c6",
4
4
  "main": "./index.js",
5
5
  "dependencies": {
6
- "@artilleryio/int-commons": "2.0.0-e07b755",
6
+ "@artilleryio/int-commons": "2.0.0-f23d4c6",
7
7
  "@artilleryio/sketches-js": "^2.1.1",
8
8
  "agentkeepalive": "^4.1.0",
9
9
  "arrivals": "^2.1.2",