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