jeffbski / bench-rest

bench-rest - benchmark REST (HTTP/HTTPS) API's. node.js client module for easy load testing / benchmarking REST API's using a simple structure/DSL can create REST flows with setup and teardown and returns (measured) metrics.
MIT License
303 stars 51 forks source link

Get with headers #30

Open salasia opened 7 years ago

salasia commented 7 years ago

how to api call with headers ? Type erros:

Object.keys(obj).forEach(function (i) {
         ^
TypeError: Object.keys called on non-object
jeffbski commented 7 years ago

Just add the headers to any of the flow request objects.

var flow = {
    main: [
      { put: 'http://localhost:8000/foo_#{INDEX}', json: 'mydata_#{INDEX}' },
      { 
        get: 'http://localhost:8000/foo_#{INDEX}',
        headers: {
          'User-Agent': 'request'
        }
      }
    ]
  };

Since it uses request as the http client, it supports any of the options request supports.

https://github.com/request/request#custom-http-headers