| 25 | } |
| 26 | |
| 27 | create(options) { |
| 28 | const args = [ |
| 29 | '-d', options.duration, |
| 30 | '-c', options.connections, |
| 31 | '-j', |
| 32 | '-n', |
| 33 | ]; |
| 34 | for (const field in options.headers) { |
| 35 | if (this.opts.shell) { |
| 36 | args.push('-H', `'${field}=${options.headers[field]}'`); |
| 37 | } else { |
| 38 | args.push('-H', `${field}=${options.headers[field]}`); |
| 39 | } |
| 40 | } |
| 41 | const scheme = options.scheme || 'http'; |
| 42 | args.push(`${scheme}://127.0.0.1:${options.port}${options.path}`); |
| 43 | const child = child_process.spawn(this.executable, args, this.opts); |
| 44 | return child; |
| 45 | } |
| 46 | |
| 47 | processResults(output) { |
| 48 | let result; |