summaryrefslogtreecommitdiff
path: root/benchmark/http/check_invalid_header_char.js
blob: d71bc6fc607ef587be1826063f31ef97fd7fb5c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';

const common = require('../common.js');
const _checkInvalidHeaderChar = require('_http_common')._checkInvalidHeaderChar;

const bench = common.createBenchmark(main, {
  key: [
    // Valid
    '',
    '1',
    '\t\t\t\t\t\t\t\t\t\tFoo bar baz',
    'keep-alive',
    'close',
    'gzip',
    '20091',
    'private',
    'text/html; charset=utf-8',
    'text/plain',
    'Sat, 07 May 2016 16:54:48 GMT',
    'SAMEORIGIN',
    'en-US',

    // Invalid
    'Here is a value that is really a folded header value\r\n  this should be \
     supported, but it is not currently',
    '中文呢', // unicode
    'foo\nbar',
    '\x7F'
  ],
  n: [1e6],
});

function main(conf) {
  const n = +conf.n;
  const key = conf.key;

  bench.start();
  for (var i = 0; i < n; i++) {
    _checkInvalidHeaderChar(key);
  }
  bench.end(n);
}