diff --git a/benchmark/http/bench-parser.js b/benchmark/http/bench-parser.js index f2c120cd97f133..0a1e8f7b5e8a0f 100644 --- a/benchmark/http/bench-parser.js +++ b/benchmark/http/bench-parser.js @@ -16,7 +16,6 @@ function main({ len, n }) { const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; const kOnBody = HTTPParser.kOnBody | 0; const kOnMessageComplete = HTTPParser.kOnMessageComplete | 0; - const CRLF = '\r\n'; function processHeader(header, n) { const parser = newParser(REQUEST); @@ -43,12 +42,12 @@ function main({ len, n }) { return parser; } - let header = `GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`; + let header = `GET /hello HTTP/1.1\r\nContent-Type: text/plain\r\n`; for (let i = 0; i < len; i++) { - header += `X-Filler${i}: ${Math.random().toString(36).substring(2)}${CRLF}`; + header += `X-Filler${i}: ${Math.random().toString(36).substring(2)}\r\n`; } - header += CRLF; + header += '\r\n'; processHeader(Buffer.from(header), n); } diff --git a/test/parallel/test-http-header-overflow.js b/test/parallel/test-http-header-overflow.js index 0d0dffed89b089..930b0e6d5bacba 100644 --- a/test/parallel/test-http-header-overflow.js +++ b/test/parallel/test-http-header-overflow.js @@ -4,14 +4,13 @@ const assert = require('assert'); const { createServer, maxHeaderSize } = require('http'); const { createConnection } = require('net'); -const CRLF = '\r\n'; const DUMMY_HEADER_NAME = 'Cookie: '; const DUMMY_HEADER_VALUE = 'a'.repeat( // Plus one is to make it 1 byte too big maxHeaderSize - DUMMY_HEADER_NAME.length + 1 ); const PAYLOAD_GET = 'GET /blah HTTP/1.1'; -const PAYLOAD = PAYLOAD_GET + CRLF + DUMMY_HEADER_NAME + DUMMY_HEADER_VALUE; +const PAYLOAD = PAYLOAD_GET + '\r\n' + DUMMY_HEADER_NAME + DUMMY_HEADER_VALUE; const server = createServer(); diff --git a/test/parallel/test-http-upgrade-client2.js b/test/parallel/test-http-upgrade-client2.js index 8883faa9e05067..8521a8ab47fb31 100644 --- a/test/parallel/test-http-upgrade-client2.js +++ b/test/parallel/test-http-upgrade-client2.js @@ -23,13 +23,11 @@ const common = require('../common'); const http = require('http'); -const CRLF = '\r\n'; - const server = http.createServer(); server.on('upgrade', function(req, socket) { - socket.write(`HTTP/1.1 101 Ok${CRLF}` + - `Connection: Upgrade${CRLF}` + - `Upgrade: Test${CRLF}${CRLF}` + + socket.write(`HTTP/1.1 101 Ok\r\n` + + `Connection: Upgrade\r\n` + + `Upgrade: Test\r\n\r\n` + 'head'); socket.on('end', function() { socket.end(); diff --git a/test/parallel/test-https-foafssl.js b/test/parallel/test-https-foafssl.js index df375e7d22201e..ec009c6a768185 100644 --- a/test/parallel/test-https-foafssl.js +++ b/test/parallel/test-https-foafssl.js @@ -47,7 +47,6 @@ const webIdUrl = 'URI:http://example.com/#me'; const modulus = fixtures.readKey('rsa_cert_foafssl_b.modulus', 'ascii').replace(/\n/g, ''); const exponent = fixtures.readKey('rsa_cert_foafssl_b.exponent', 'ascii').replace(/\n/g, ''); -const CRLF = '\r\n'; const body = 'hello world\n'; let cert; @@ -76,7 +75,7 @@ server.listen(0, function() { client.stdout.on('data', function(data) { console.log('response received'); const message = data.toString(); - const contents = message.split(CRLF + CRLF).pop(); + const contents = message.split('\r\n\r\n').pop(); assert.strictEqual(body, contents); server.close((e) => { assert.ifError(e);