Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add checks for CRLF and LF

  • Loading branch information...
commit d686117f9329cb44b03c362cb32783039df931b8 1 parent 4de6c65
@substack authored
Showing with 35 additions and 1 deletion.
  1. +35 −1 test/insert.js
View
36 test/insert.js
@@ -2,7 +2,7 @@ var test = require('tap').test;
var insert = require('../lib/insert');
var chunky = require('chunky');
-test('insert headers', function (t) {
+test('insert headers CRLF', function (t) {
t.plan(2 * 50);
var msg = [
'POST / HTTP/1.1',
@@ -35,3 +35,37 @@ test('insert headers', function (t) {
s.end();
}
});
+
+test('insert headers LF', function (t) {
+ t.plan(2 * 50);
+ var msg = [
+ 'POST / HTTP/1.1',
+ 'Host: beep',
+ '',
+ 'sound=boop'
+ ].join('\n');
+
+ for (var i = 0; i < 50; i++) {
+ var bufs = chunky(msg);
+ t.equal(bufs.map(String).join(''), msg);
+
+ var s = insert({ headers: { foo : 'bar', baz : 'quux' } });
+ var data = '';
+ s.on('data', function (buf) { data += buf });
+ s.on('end', function () {
+ t.equal(data, [
+ 'POST / HTTP/1.1',
+ 'Host: beep',
+ 'foo: bar',
+ 'baz: quux',
+ '',
+ 'sound=boop'
+ ].join('\n'));
+ });
+
+ for (var j = 0; j < bufs.length; j++) {
+ s.write(bufs[j]);
+ }
+ s.end();
+ }
+});
Please sign in to comment.
Something went wrong with that request. Please try again.