Skip to content

Commit 896fb63

Browse files
hiroppyMylesBorins
authored andcommitted
test: add http_incoming's matchKnownFields test
https://github.com/nodejs/node/blob/master/lib/_http_incoming.js#L136 Coverage: https://coverage.nodejs.org/coverage-57f6a106fbc69a47/root/_http_incoming.js.html PR-URL: #10811 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com>
1 parent 7328306 commit 896fb63

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
'use strict';
2+
require('../common');
3+
constassert=require('assert');
4+
constIncomingMessage=require('http').IncomingMessage;
5+
6+
functioncheckDest(field,result,value){
7+
constdest={};
8+
9+
if(value)dest[field]='test';
10+
constincomingMessage=newIncomingMessage(field);
11+
// dest is changed by IncomingMessage._addHeaderLine
12+
incomingMessage._addHeaderLine(field,value,dest);
13+
assert.deepStrictEqual(dest,result);
14+
}
15+
16+
checkDest('',{'': undefined});
17+
checkDest('Content-Type',{'content-type': undefined});
18+
checkDest('content-type',{'content-type': 'test'},'value');
19+
checkDest('User-Agent',{'user-agent': undefined});
20+
checkDest('user-agent',{'user-agent': 'test'},'value');
21+
checkDest('Referer',{referer: undefined});
22+
checkDest('referer',{referer: 'test'},'value');
23+
checkDest('Host',{host: undefined});
24+
checkDest('host',{host: 'test'},'value');
25+
checkDest('Authorization',{authorization: undefined},undefined);
26+
checkDest('authorization',{authorization: 'test'},'value');
27+
checkDest('Proxy-Authorization',{'proxy-authorization': undefined});
28+
checkDest('proxy-authorization',{'proxy-authorization': 'test'},'value');
29+
checkDest('If-Modified-Since',{'if-modified-since': undefined});
30+
checkDest('if-modified-since',{'if-modified-since': 'test'},'value');
31+
checkDest('If-Unmodified-Since',{'if-unmodified-since': undefined});
32+
checkDest('if-unmodified-since',{'if-unmodified-since': 'test'},'value');
33+
checkDest('Form',{form: undefined});
34+
checkDest('form',{form: 'test, value'},'value');
35+
checkDest('Location',{location: undefined});
36+
checkDest('location',{location: 'test'},'value');
37+
checkDest('Max-Forwards',{'max-forwards': undefined});
38+
checkDest('max-forwards',{'max-forwards': 'test'},'value');
39+
checkDest('Retry-After',{'retry-after': undefined});
40+
checkDest('retry-after',{'retry-after': 'test'},'value');
41+
checkDest('Etag',{etag: undefined});
42+
checkDest('etag',{etag: 'test'},'value');
43+
checkDest('Last-Modified',{'last-modified': undefined});
44+
checkDest('last-modified',{'last-modified': 'test'},'value');
45+
checkDest('Server',{server: undefined});
46+
checkDest('server',{server: 'test'},'value');
47+
checkDest('Age',{age: undefined});
48+
checkDest('age',{age: 'test'},'value');
49+
checkDest('Expires',{expires: undefined});
50+
checkDest('expires',{expires: 'test'},'value');
51+
checkDest('Set-Cookie',{'set-cookie': [undefined]});
52+
checkDest('set-cookie',{'set-cookie': [undefined]});
53+
checkDest('Transfer-Encoding',{'transfer-encoding': undefined});
54+
checkDest('transfer-encoding',{'transfer-encoding': 'test, value'},'value');
55+
checkDest('Date',{date: undefined});
56+
checkDest('date',{date: 'test, value'},'value');
57+
checkDest('Connection',{connection: undefined});
58+
checkDest('connection',{connection: 'test, value'},'value');
59+
checkDest('Cache-Control',{'cache-control': undefined});
60+
checkDest('cache-control',{'cache-control': 'test, value'},'value');
61+
checkDest('Transfer-Encoding',{'transfer-encoding': undefined});
62+
checkDest('transfer-encoding',{'transfer-encoding': 'test, value'},'value');
63+
checkDest('Vary',{vary: undefined});
64+
checkDest('vary',{vary: 'test, value'},'value');
65+
checkDest('Content-Encoding',{'content-encoding': undefined},undefined);
66+
checkDest('content-encoding',{'content-encoding': 'test, value'},'value');
67+
checkDest('Cookies',{cookies: undefined});
68+
checkDest('cookies',{cookies: 'test, value'},'value');
69+
checkDest('Origin',{origin: undefined});
70+
checkDest('origin',{origin: 'test, value'},'value');
71+
checkDest('Upgrade',{upgrade: undefined});
72+
checkDest('upgrade',{upgrade: 'test, value'},'value');
73+
checkDest('Expect',{expect: undefined});
74+
checkDest('expect',{expect: 'test, value'},'value');
75+
checkDest('If-Match',{'if-match': undefined});
76+
checkDest('if-match',{'if-match': 'test, value'},'value');
77+
checkDest('If-None-Match',{'if-none-match': undefined});
78+
checkDest('if-none-match',{'if-none-match': 'test, value'},'value');
79+
checkDest('Accept',{accept: undefined});
80+
checkDest('accept',{accept: 'test, value'},'value');
81+
checkDest('Accept-Encoding',{'accept-encoding': undefined});
82+
checkDest('accept-encoding',{'accept-encoding': 'test, value'},'value');
83+
checkDest('Accept-Language',{'accept-language': undefined});
84+
checkDest('accept-language',{'accept-language': 'test, value'},'value');
85+
checkDest('X-Forwarded-For',{'x-forwarded-for': undefined});
86+
checkDest('x-forwarded-for',{'x-forwarded-for': 'test, value'},'value');
87+
checkDest('X-Forwarded-Host',{'x-forwarded-host': undefined});
88+
checkDest('x-forwarded-host',{'x-forwarded-host': 'test, value'},'value');
89+
checkDest('X-Forwarded-Proto',{'x-forwarded-proto': undefined});
90+
checkDest('x-forwarded-proto',{'x-forwarded-proto': 'test, value'},'value');

0 commit comments

Comments
 (0)