11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_cirequire('../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ciconst IncomingMessage = require('http').IncomingMessage; 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_cifunction checkDest(field, result, value) { 71cb0ef41Sopenharmony_ci const dest = {}; 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci const incomingMessage = new IncomingMessage(field); 101cb0ef41Sopenharmony_ci // Dest is changed by IncomingMessage._addHeaderLine 111cb0ef41Sopenharmony_ci if (value) 121cb0ef41Sopenharmony_ci incomingMessage._addHeaderLine(field, 'test', dest); 131cb0ef41Sopenharmony_ci incomingMessage._addHeaderLine(field, value, dest); 141cb0ef41Sopenharmony_ci assert.deepStrictEqual(dest, result); 151cb0ef41Sopenharmony_ci} 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_cicheckDest('', { '': undefined }); 181cb0ef41Sopenharmony_cicheckDest('Content-Type', { 'content-type': undefined }); 191cb0ef41Sopenharmony_cicheckDest('content-type', { 'content-type': 'test' }, 'value'); 201cb0ef41Sopenharmony_cicheckDest('User-Agent', { 'user-agent': undefined }); 211cb0ef41Sopenharmony_cicheckDest('user-agent', { 'user-agent': 'test' }, 'value'); 221cb0ef41Sopenharmony_cicheckDest('Referer', { referer: undefined }); 231cb0ef41Sopenharmony_cicheckDest('referer', { referer: 'test' }, 'value'); 241cb0ef41Sopenharmony_cicheckDest('Host', { host: undefined }); 251cb0ef41Sopenharmony_cicheckDest('host', { host: 'test' }, 'value'); 261cb0ef41Sopenharmony_cicheckDest('Authorization', { authorization: undefined }, undefined); 271cb0ef41Sopenharmony_cicheckDest('authorization', { authorization: 'test' }, 'value'); 281cb0ef41Sopenharmony_cicheckDest('Proxy-Authorization', { 'proxy-authorization': undefined }); 291cb0ef41Sopenharmony_cicheckDest('proxy-authorization', { 'proxy-authorization': 'test' }, 'value'); 301cb0ef41Sopenharmony_cicheckDest('If-Modified-Since', { 'if-modified-since': undefined }); 311cb0ef41Sopenharmony_cicheckDest('if-modified-since', { 'if-modified-since': 'test' }, 'value'); 321cb0ef41Sopenharmony_cicheckDest('If-Unmodified-Since', { 'if-unmodified-since': undefined }); 331cb0ef41Sopenharmony_cicheckDest('if-unmodified-since', { 'if-unmodified-since': 'test' }, 'value'); 341cb0ef41Sopenharmony_cicheckDest('Form', { form: undefined }); 351cb0ef41Sopenharmony_cicheckDest('form', { form: 'test, value' }, 'value'); 361cb0ef41Sopenharmony_cicheckDest('Location', { location: undefined }); 371cb0ef41Sopenharmony_cicheckDest('location', { location: 'test' }, 'value'); 381cb0ef41Sopenharmony_cicheckDest('Max-Forwards', { 'max-forwards': undefined }); 391cb0ef41Sopenharmony_cicheckDest('max-forwards', { 'max-forwards': 'test' }, 'value'); 401cb0ef41Sopenharmony_cicheckDest('Retry-After', { 'retry-after': undefined }); 411cb0ef41Sopenharmony_cicheckDest('retry-after', { 'retry-after': 'test' }, 'value'); 421cb0ef41Sopenharmony_cicheckDest('Etag', { etag: undefined }); 431cb0ef41Sopenharmony_cicheckDest('etag', { etag: 'test' }, 'value'); 441cb0ef41Sopenharmony_cicheckDest('Last-Modified', { 'last-modified': undefined }); 451cb0ef41Sopenharmony_cicheckDest('last-modified', { 'last-modified': 'test' }, 'value'); 461cb0ef41Sopenharmony_cicheckDest('Server', { server: undefined }); 471cb0ef41Sopenharmony_cicheckDest('server', { server: 'test' }, 'value'); 481cb0ef41Sopenharmony_cicheckDest('Age', { age: undefined }); 491cb0ef41Sopenharmony_cicheckDest('age', { age: 'test' }, 'value'); 501cb0ef41Sopenharmony_cicheckDest('Expires', { expires: undefined }); 511cb0ef41Sopenharmony_cicheckDest('expires', { expires: 'test' }, 'value'); 521cb0ef41Sopenharmony_cicheckDest('Set-Cookie', { 'set-cookie': [undefined] }); 531cb0ef41Sopenharmony_cicheckDest('set-cookie', { 'set-cookie': ['test', 'value'] }, 'value'); 541cb0ef41Sopenharmony_cicheckDest('Transfer-Encoding', { 'transfer-encoding': undefined }); 551cb0ef41Sopenharmony_cicheckDest('transfer-encoding', { 'transfer-encoding': 'test, value' }, 'value'); 561cb0ef41Sopenharmony_cicheckDest('Date', { date: undefined }); 571cb0ef41Sopenharmony_cicheckDest('date', { date: 'test, value' }, 'value'); 581cb0ef41Sopenharmony_cicheckDest('Connection', { connection: undefined }); 591cb0ef41Sopenharmony_cicheckDest('connection', { connection: 'test, value' }, 'value'); 601cb0ef41Sopenharmony_cicheckDest('Cache-Control', { 'cache-control': undefined }); 611cb0ef41Sopenharmony_cicheckDest('cache-control', { 'cache-control': 'test, value' }, 'value'); 621cb0ef41Sopenharmony_cicheckDest('Transfer-Encoding', { 'transfer-encoding': undefined }); 631cb0ef41Sopenharmony_cicheckDest('transfer-encoding', { 'transfer-encoding': 'test, value' }, 'value'); 641cb0ef41Sopenharmony_cicheckDest('Vary', { vary: undefined }); 651cb0ef41Sopenharmony_cicheckDest('vary', { vary: 'test, value' }, 'value'); 661cb0ef41Sopenharmony_cicheckDest('Content-Encoding', { 'content-encoding': undefined }, undefined); 671cb0ef41Sopenharmony_cicheckDest('content-encoding', { 'content-encoding': 'test, value' }, 'value'); 681cb0ef41Sopenharmony_cicheckDest('Cookie', { cookie: undefined }); 691cb0ef41Sopenharmony_cicheckDest('cookie', { cookie: 'test; value' }, 'value'); 701cb0ef41Sopenharmony_cicheckDest('Origin', { origin: undefined }); 711cb0ef41Sopenharmony_cicheckDest('origin', { origin: 'test, value' }, 'value'); 721cb0ef41Sopenharmony_cicheckDest('Upgrade', { upgrade: undefined }); 731cb0ef41Sopenharmony_cicheckDest('upgrade', { upgrade: 'test, value' }, 'value'); 741cb0ef41Sopenharmony_cicheckDest('Expect', { expect: undefined }); 751cb0ef41Sopenharmony_cicheckDest('expect', { expect: 'test, value' }, 'value'); 761cb0ef41Sopenharmony_cicheckDest('If-Match', { 'if-match': undefined }); 771cb0ef41Sopenharmony_cicheckDest('if-match', { 'if-match': 'test, value' }, 'value'); 781cb0ef41Sopenharmony_cicheckDest('If-None-Match', { 'if-none-match': undefined }); 791cb0ef41Sopenharmony_cicheckDest('if-none-match', { 'if-none-match': 'test, value' }, 'value'); 801cb0ef41Sopenharmony_cicheckDest('Accept', { accept: undefined }); 811cb0ef41Sopenharmony_cicheckDest('accept', { accept: 'test, value' }, 'value'); 821cb0ef41Sopenharmony_cicheckDest('Accept-Encoding', { 'accept-encoding': undefined }); 831cb0ef41Sopenharmony_cicheckDest('accept-encoding', { 'accept-encoding': 'test, value' }, 'value'); 841cb0ef41Sopenharmony_cicheckDest('Accept-Language', { 'accept-language': undefined }); 851cb0ef41Sopenharmony_cicheckDest('accept-language', { 'accept-language': 'test, value' }, 'value'); 861cb0ef41Sopenharmony_cicheckDest('X-Forwarded-For', { 'x-forwarded-for': undefined }); 871cb0ef41Sopenharmony_cicheckDest('x-forwarded-for', { 'x-forwarded-for': 'test, value' }, 'value'); 881cb0ef41Sopenharmony_cicheckDest('X-Forwarded-Host', { 'x-forwarded-host': undefined }); 891cb0ef41Sopenharmony_cicheckDest('x-forwarded-host', { 'x-forwarded-host': 'test, value' }, 'value'); 901cb0ef41Sopenharmony_cicheckDest('X-Forwarded-Proto', { 'x-forwarded-proto': undefined }); 911cb0ef41Sopenharmony_cicheckDest('x-forwarded-proto', { 'x-forwarded-proto': 'test, value' }, 'value'); 921cb0ef41Sopenharmony_cicheckDest('X-Foo', { 'x-foo': undefined }); 931cb0ef41Sopenharmony_cicheckDest('x-foo', { 'x-foo': 'test, value' }, 'value'); 94