diff --git a/hitit.js b/hitit.js index 49fb9b6..9e1852c 100644 --- a/hitit.js +++ b/hitit.js @@ -1,5 +1,5 @@ /* -hitit - v1.2.2 +hitit - v1.2.3 Written by Federico Pereiro (fpereiro@gmail.com) and released into the public domain. */ @@ -209,8 +209,10 @@ Written by Federico Pereiro (fpereiro@gmail.com) and released into the public do preproc (seq); + var t = Date.now (); + var CB = function () { - log ('Starting request', fseq [counter].tag, '(' + (counter + 1) + '/' + fseq.length + ')'); + log ('Starting request (' + (Math.round ((Date.now () - t) / 10) / 100) + 's)', fseq [counter].tag, '(' + (counter + 1) + '/' + fseq.length + ')'); h.one (state, fseq [counter++], function (error, rdata) { if (error) return cb (error, hist); hist.push (rdata); @@ -223,6 +225,7 @@ Written by Federico Pereiro (fpereiro@gmail.com) and released into the public do } h.stdmap = function (req) { + if (type (req) !== 'array') return log ('Request passed to h.stdmap must be an array!'); return { tag: req [0], method: req [1], diff --git a/package.json b/package.json index dd621d2..3f3213a 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "hitit", - "version": "1.2.2", + "version": "1.2.3", "description": "Minimalistic tool for API testing.", "dependencies": { - "dale": "4.3.1", + "dale": "4.3.3", "mime": "1.6.0", - "teishi": "3.13.0" + "teishi": "3.13.2" }, "main": "hitit.js", "author": "Federico Pereiro ", diff --git a/readme.md b/readme.md index 668c17d..29406a7 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,7 @@ hitit is a minimalistic tool for testing an HTTP(S) API. It is a stopgap until I ## Current status of the project -The current version of hitit, v1.2.2, is considered to be *mostly stable* and *mostly complete*. [Suggestions](https://github.com/fpereiro/hitit/issues) and [patches](https://github.com/fpereiro/hitit/pulls) are welcome. Future changes planned are: +The current version of hitit, v1.2.3, is considered to be *mostly stable* and *mostly complete*. [Suggestions](https://github.com/fpereiro/hitit/issues) and [patches](https://github.com/fpereiro/hitit/pulls) are welcome. Future changes planned are: - Support for concurrent testing (a.k.a stress testing). @@ -46,7 +46,7 @@ To do a single request, use `h.one`. This function takes three arguments: `state Many times it is useful to make a request depending on `state`. For that reason, any of the keys of `options` can also be a function; if so, it will be evaluated passing `state` as its only argument. For example, if `state.id` is `3` and you define `options.path` to be `function (state) {return 'download/' + state.id}`, this is equivalent to setting `options.path` to `'download/3'`. Note that also the matching keys of `state` are evaluated in this way if they are functions. -The `body` can be of any type. If it's `null` or `undefined`, it will be considered an empty string. If it's neither an array or an object, it will be coerced a string. If it is either an array or an object with `body.multipart` being `undefined`, it will be considered a JSON. In this case, it will be automatically stringified and the `content-header` will be set to `application/json` (unless you override this default). Finally, if `body` is an object and `body.multipart` is defined, hitit will do a `multipart/form-data` request. `body.multipart` can be either an object or an array of objects. Each of these objects can represent either a `field` or a `file`. In the case of a `field`, the object will have three keys: `type: 'field'`, `name: STRING` and `value: STRING`. In the case of a `file`, the object will have these fields: `type: 'file'`, `name: STRING`, either `value` or `path` (the first to provide the literal value of the file, the second a path to where the file is) and an optional `contentType` - in its absence, if `path` is provided, a mime lookup of the file will be performed. In my case, I always override this by setting `contentType` to `application/octet-stream`. +The `body` can be of any type. If it's `null` or `undefined`, it will be considered an empty string. If it's neither an array or an object, it will be coerced a string. If it is either an array or an object with `body.multipart` being `undefined`, it will be considered a JSON. In this case, it will be automatically stringified and the `content-header` will be set to `application/json` (unless you override this default). Finally, if `body` is an object and `body.multipart` is defined, hitit will do a `multipart/form-data` request. `body.multipart` can be either an object or an array of objects. Each of these objects can represent either a `field` or a `file`. In the case of a `field`, the object will have three keys: `type: 'field'`, `name: STRING` and `value: STRING`. In the case of a `file`, the object will have these fields: `type: 'file'`, `name: STRING`, either `value` or `path` (the first to provide the literal value of the file, the second a path to where the file is) and an optional `contentType` - in its absence, if `path` is provided, a mime lookup of the file will be performed. ```javascript // Example