Skip to content

Commit 027b861

Browse files
wlgh1553targos
authored andcommitted
benchmark, test: replace CRLF variable with string literal
PR-URL: #59466 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Tim Perry <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]>
1 parent e517792 commit 027b861

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

‎benchmark/http/bench-parser.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ function main({len, n }){
1616
constkOnHeadersComplete=HTTPParser.kOnHeadersComplete|0;
1717
constkOnBody=HTTPParser.kOnBody|0;
1818
constkOnMessageComplete=HTTPParser.kOnMessageComplete|0;
19-
constCRLF='\r\n';
2019

2120
functionprocessHeader(header,n){
2221
constparser=newParser(REQUEST);
@@ -43,12 +42,12 @@ function main({len, n }){
4342
returnparser;
4443
}
4544

46-
letheader=`GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`;
45+
letheader=`GET /hello HTTP/1.1\r\nContent-Type: text/plain\r\n`;
4746

4847
for(leti=0;i<len;i++){
49-
header+=`X-Filler${i}: ${Math.random().toString(36).substring(2)}${CRLF}`;
48+
header+=`X-Filler${i}: ${Math.random().toString(36).substring(2)}\r\n`;
5049
}
51-
header+=CRLF;
50+
header+='\r\n';
5251

5352
processHeader(Buffer.from(header),n);
5453
}

‎test/parallel/test-http-header-overflow.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ const assert = require('assert');
44
const{ createServer, maxHeaderSize }=require('http');
55
const{ createConnection }=require('net');
66

7-
constCRLF='\r\n';
87
constDUMMY_HEADER_NAME='Cookie: ';
98
constDUMMY_HEADER_VALUE='a'.repeat(
109
// Plus one is to make it 1 byte too big
1110
maxHeaderSize-DUMMY_HEADER_NAME.length+1
1211
);
1312
constPAYLOAD_GET='GET /blah HTTP/1.1';
14-
constPAYLOAD=PAYLOAD_GET+CRLF+DUMMY_HEADER_NAME+DUMMY_HEADER_VALUE;
13+
constPAYLOAD=PAYLOAD_GET+'\r\n'+DUMMY_HEADER_NAME+DUMMY_HEADER_VALUE;
1514

1615
constserver=createServer();
1716

‎test/parallel/test-http-upgrade-client2.js‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@
2323
constcommon=require('../common');
2424
consthttp=require('http');
2525

26-
constCRLF='\r\n';
27-
2826
constserver=http.createServer();
2927
server.on('upgrade',function(req,socket){
30-
socket.write(`HTTP/1.1 101 Ok${CRLF}`+
31-
`Connection: Upgrade${CRLF}`+
32-
`Upgrade: Test${CRLF}${CRLF}`+
28+
socket.write(`HTTP/1.1 101 Ok\r\n`+
29+
`Connection: Upgrade\r\n`+
30+
`Upgrade: Test\r\n\r\n`+
3331
'head');
3432
socket.on('end',function(){
3533
socket.end();

‎test/parallel/test-https-foafssl.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const webIdUrl = 'URI:http://example.com/#me'
4747
constmodulus=fixtures.readKey('rsa_cert_foafssl_b.modulus','ascii').replace(/\n/g,'');
4848
constexponent=fixtures.readKey('rsa_cert_foafssl_b.exponent','ascii').replace(/\n/g,'');
4949

50-
constCRLF='\r\n';
5150
constbody='hello world\n';
5251
letcert;
5352

@@ -76,7 +75,7 @@ server.listen(0, function(){
7675
client.stdout.on('data',function(data){
7776
console.log('response received');
7877
constmessage=data.toString();
79-
constcontents=message.split(CRLF+CRLF).pop();
78+
constcontents=message.split('\r\n\r\n').pop();
8079
assert.strictEqual(body,contents);
8180
server.close((e)=>{
8281
assert.ifError(e);

0 commit comments

Comments
(0)