@artilleryio/int-core 2.11.0 → 2.12.0-c3be075

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.
@@ -23,6 +23,8 @@ const HttpAgent = require('agentkeepalive');
23
23
  const { HttpsAgent } = HttpAgent;
24
24
  const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent');
25
25
  const decompressResponse = require('decompress-response');
26
+ const fs = require('fs');
27
+ const path = require('path');
26
28
 
27
29
  const { promisify } = require('node:util');
28
30
 
@@ -395,16 +397,34 @@ HttpEngine.prototype.step = function step(requestSpec, ee, opts) {
395
397
  }
396
398
 
397
399
  if (params.formData) {
400
+ let fileUpload;
398
401
  const f = new FormData();
399
402
  requestParams.body = _.reduce(
400
403
  requestParams.formData,
401
404
  function (acc, v, k) {
402
- // acc[k] = template(v, context);
403
- acc.append(k, template(v, context));
405
+ let V = template(v, context);
406
+ if (V && _.isPlainObject(V) && V.fromFile) {
407
+ const absPath = path.resolve(
408
+ path.dirname(context.vars.$scenarioFile),
409
+ V.fromFile
410
+ );
411
+ fileUpload = absPath;
412
+ V = fs.createReadStream(absPath);
413
+ }
414
+ acc.append(k, V);
404
415
  return acc;
405
416
  },
406
417
  f
407
418
  );
419
+ if (params.setContentLengthHeader && fileUpload) {
420
+ try {
421
+ requestParams.headers = requestParams.headers || {};
422
+ requestParams.headers['content-length'] =
423
+ fs.statSync(fileUpload).size;
424
+ } catch (err) {
425
+ debug(`stat() on ${fileUpload} failed with ${err}`);
426
+ }
427
+ }
408
428
  }
409
429
 
410
430
  // Assign default headers then overwrite as needed
package/lib/runner.js CHANGED
@@ -468,7 +468,9 @@ function createContext(script, contextVars, additionalProperties = {}) {
468
468
  if (script._configPath) {
469
469
  INITIAL_CONTEXT.vars.$dirname = path.dirname(script._configPath);
470
470
  }
471
-
471
+ if (script._scriptPath) {
472
+ INITIAL_CONTEXT.vars.$scenarioFile = script._scriptPath;
473
+ }
472
474
  let result = INITIAL_CONTEXT;
473
475
 
474
476
  // variables from payloads:
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@artilleryio/int-core",
3
- "version": "2.11.0",
3
+ "version": "2.12.0-c3be075",
4
4
  "main": "./index.js",
5
5
  "license": "MPL-2.0",
6
6
  "dependencies": {
7
- "@artilleryio/int-commons": "2.7.0",
7
+ "@artilleryio/int-commons": "2.8.0-c3be075",
8
8
  "@artilleryio/sketches-js": "^2.1.1",
9
9
  "agentkeepalive": "^4.1.0",
10
10
  "arrivals": "^2.1.2",