Comparing version 0.2.9 to 0.2.10
@@ -12,4 +12,6 @@ #!/usr/bin/env node | ||
var fs = require('fs'); | ||
var urlLib = require('url'); | ||
var loadTest = require('../lib/loadtest.js'); | ||
var headers = require('../lib/headers.js'); | ||
var packageJson = require(__dirname + '/../package.json'); | ||
@@ -22,3 +24,2 @@ // globals | ||
{ | ||
var packageJson = require(__dirname + '/../package.json'); | ||
console.log('Loadtest version: %s', packageJson.version); | ||
@@ -59,5 +60,10 @@ process.exit(0); | ||
} | ||
options.headers = [ | ||
['host', urlLib.parse(options.url).host], | ||
['user-agent', 'loadtest/' + packageJson.version], | ||
['accept', '*/*'], | ||
]; | ||
if (options.rawHeaders) | ||
{ | ||
options.headers = headers.readHeaders(options.rawHeaders); | ||
headers.addHeaders(options.rawHeaders, options.headers); | ||
console.log('headers: %s, %j', typeof options.headers, options.headers); | ||
@@ -64,0 +70,0 @@ } |
@@ -14,7 +14,6 @@ 'use strict'; | ||
/** | ||
* Read all headers and return in a suitable array. | ||
* Add all raw headers given to the given array. | ||
*/ | ||
exports.readHeaders = function(rawHeaders) | ||
exports.addHeaders = function(rawHeaders, headers) | ||
{ | ||
var headers = []; | ||
if (Array.isArray(rawHeaders)) | ||
@@ -35,3 +34,2 @@ { | ||
} | ||
return headers; | ||
}; | ||
@@ -51,3 +49,3 @@ | ||
var value = pieces[1]; | ||
headers.push([key, value]); | ||
headers.push([key.toLowerCase(), value]); | ||
} | ||
@@ -69,8 +67,13 @@ | ||
headers: [['k', 'v'], ['k2', 'v2']], | ||
} | ||
}, | ||
{ | ||
raw: 'K:v', | ||
headers: [['k', 'v']], | ||
}, | ||
]; | ||
tests.forEach(function(test) | ||
{ | ||
var result = exports.readHeaders(test.raw); | ||
testing.assertEquals(result, test.headers, 'Wrong headers', callback); | ||
var headers = []; | ||
exports.addHeaders(test.raw, headers); | ||
testing.assertEquals(headers, test.headers, 'Wrong headers', callback); | ||
}); | ||
@@ -125,3 +128,6 @@ testing.success(callback); | ||
{ | ||
testing.run([testAddHeaders, testConvert], callback); | ||
testing.run([ | ||
testAddHeaders, | ||
testConvert | ||
], callback); | ||
}; | ||
@@ -128,0 +134,0 @@ |
@@ -108,3 +108,3 @@ 'use strict'; | ||
} | ||
// log.info('Options: %j', options); | ||
log.debug('Options: %j', options); | ||
} | ||
@@ -111,0 +111,0 @@ |
{ | ||
"name": "loadtest", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"description": "Run load tests for your web application. Mostly ab-compatible interface, with an option to force requests per second. Includes an API for automated load testing.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/alexfernandez/loadtest", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4
49231
17
1552