XMLHttpRequest header search (v2)

Revision 2 of this benchmark created on


Setup

const headers = 'date: Fri, 08 Dec 2017 21:04:30 GMT\r\ncontent-encoding: gzip\r\nx-content-type-options: nosniff\r\nserver: meinheld/0.6.1\r\nx-frame-options: DENY\r\ncontent-type: text/html; charset=utf-8\r\nconnection: keep-alive\r\nstrict-transport-security: max-age=63072000\r\nvary: Cookie, Accept-Encoding\r\ncontent-length: 6502\r\nx-xss-protection: 1; mode=block\r\nx-dd-b: 1\r\n';

Test runner

Ready to run.

Testing in
TestOps/sec
forEach
let foundStatusHeader = false;

headers
	.trim()
    .split(/[\r\n]+/)
    .forEach(function (line) {
		var parts = line.split(': ');
		var header = parts.shift().toLowerCase();

		if (header === self.dataDomeStatusHeader) {
			foundStatusHeader = true;
        }
	});
	
return foundStatusHeader;
ready
indexOf
let foundStatusHeader = false;

foundStatusHeader = headers.indexOf('\nx-dd-b: ') > -1;
	
return foundStatusHeader;
ready
includes
let foundStatusHeader = false;

foundStatusHeader = headers.includes('x-dd-b:');
	
return foundStatusHeader;
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.