Socket
Socket
Sign inDemoInstall

loadtest

Package Overview
Dependencies
29
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.7 to 0.2.8

lib/headers.js

12

bin/loadtest.js

@@ -13,2 +13,3 @@ #!/usr/bin/env node

var loadTest = require('../lib/loadtest.js');
var headers = require('../lib/headers.js');

@@ -29,2 +30,3 @@ // globals

assignArgument('C', args, 'cookies', options);
assignArgument('H', args, 'rawHeaders', options);
assignArgument('T', args, 'contentType', options);

@@ -51,2 +53,7 @@ assignArgument('r', args, 'recover', options, true);

}
if (options.rawHeaders)
{
options.headers = headers.readHeaders(options.rawHeaders);
console.log('headers: %s, %j', typeof options.headers, options.headers);
}
loadTest.loadTest(options);

@@ -74,4 +81,5 @@

console.log(' -t timelimit Seconds to max. wait for responses');
console.log(' -T content-type The MIME type for the body');
console.log(' -C name=value Send a cookie with the given name');
console.log(' -T content-type The MIME type for the body');
console.log(' -H header:value Send a header with the given value');
console.log(' -p POST-file Send the contents of the file as POST body');

@@ -88,3 +96,3 @@ console.log(' -u PUT-file Send the contents of the file as PUT body');

console.log(' --debug Show debug messages');
process.exit(0);
process.exit(1);
}

@@ -67,1 +67,6 @@

### 2013-01-28: version 0.2.8.
* Issue 15: Added option -H to send a custom header.
* Separate multiple cookies with a semicolon instead of a comma: `cookie1=1; cookie2=2`.

@@ -17,2 +17,3 @@ 'use strict';

var timing = require('./timing.js');
var headers = require('./headers.js');

@@ -52,4 +53,7 @@ // globals

options = urlLib.parse(params.url);
log.info('Options: %j', options);
options.headers = {};
options.headers = [];
if (params.headers)
{
options.headers = params.headers;
}
if (!params.agent)

@@ -88,9 +92,21 @@ {

}
options.headers['Content-Length'] = message.length;
options.headers['Content-Type'] = params.contentType || 'text/plain';
options.headers.push(['Content-Length', message.length]);
options.headers.push(['Content-Type', params.contentType || 'text/plain']);
}
if (params.cookies)
{
options.headers.Cookie = params.cookies;
if (Array.isArray(params.cookies))
{
options.headers.push(['Cookie', params.cookies.join('; ')]);
}
else if (typeof params.cookies == 'string')
{
options.headers.push(['Cookie', params.cookies]);
}
else
{
console.error('Invalid cookies %j, please use an array or a string', params.cookies);
}
}
// log.info('Options: %j', options);
}

@@ -220,3 +236,6 @@

* - maxSeconds: how long to run the tests.
* - cookies: an array of objects, each with {name:name, value:value}.
* - cookies: a string or array of objects, each with {name:name, value:value}.
* - headers: a structure with headers:
* * map: {key: value, key2: value2},
* * array: [[key1, value1], [key2, value]].
* - method: the method to use: POST, PUT. Default: GET, what else.

@@ -259,2 +278,6 @@ * - body: the contents to send along a POST or PUT request.

}
if (options.headers)
{
options.headers = headers.convert(options.headers);
}
var operation = new Operation(options, constructor, callback);

@@ -261,0 +284,0 @@ operation.start();

8

lib/sample.js

@@ -36,4 +36,4 @@ 'use strict';

url: 'http://localhost:' + PORT,
maxRequests: 1000,
concurrency: 100,
maxRequests: 100,
concurrency: 10,
method: 'POST',

@@ -80,3 +80,3 @@ body: {

url: 'http://localhost:' + (PORT + 1),
maxRequests: 100,
maxRequests: 10,
};

@@ -95,3 +95,3 @@ loadtest.loadTest(options, function(error, result)

}
testing.assertEquals(result.totalRequests, 100, 'Invalid total requests', callback);
testing.assertEquals(result.totalRequests, 10, 'Invalid total requests', callback);
testing.assert(result.meanLatencyMs >= delay, 'Delay should be higher than %s, not %s', delay, result.meanLatencyMs, callback);

@@ -98,0 +98,0 @@ callback(null, result);

{
"name": "loadtest",
"version": "0.2.7",
"version": "0.2.8",
"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",

@@ -65,2 +65,7 @@ [![Build Status](https://secure.travis-ci.org/alexfernandez/loadtest.png)](http://travis-ci.org/alexfernandez/loadtest)

### -H header:value
Send a custom header with the request. A pair header:value is expected and sent to the server.
This parameter can be repeated as many times as needed.
### -T content-type

@@ -174,2 +179,7 @@

#### headers
A map of headers. Each header should be an entry in the map with the given value as a string.
If the value is an array, several headers with the same key will be sent.
#### method

@@ -176,0 +186,0 @@

@@ -23,3 +23,3 @@ 'use strict';

var tests = {};
var libs = [ 'timing', 'sample', 'websocket', 'loadtest' ];
var libs = ['timing', 'sample', 'websocket', 'loadtest', 'headers'];
libs.forEach(function(lib)

@@ -26,0 +26,0 @@ {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc