11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif (!common.hasCrypto) 51cb0ef41Sopenharmony_ci common.skip('missing crypto'); 61cb0ef41Sopenharmony_ciconst assert = require('assert'); 71cb0ef41Sopenharmony_ciconst http2 = require('http2'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci// Http2ServerResponse.writeHead should support arrays and nested arrays 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci{ 121cb0ef41Sopenharmony_ci const server = http2.createServer(); 131cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 141cb0ef41Sopenharmony_ci const port = server.address().port; 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci server.once('request', common.mustCall((request, response) => { 171cb0ef41Sopenharmony_ci const returnVal = response.writeHead(200, [ 181cb0ef41Sopenharmony_ci ['foo', 'bar'], 191cb0ef41Sopenharmony_ci ['ABC', 123], 201cb0ef41Sopenharmony_ci ]); 211cb0ef41Sopenharmony_ci assert.strictEqual(returnVal, response); 221cb0ef41Sopenharmony_ci response.end(common.mustCall(() => { server.close(); })); 231cb0ef41Sopenharmony_ci })); 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci const client = http2.connect(`http://localhost:${port}`, common.mustCall(() => { 261cb0ef41Sopenharmony_ci const request = client.request(); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci request.on('response', common.mustCall((headers) => { 291cb0ef41Sopenharmony_ci assert.strictEqual(headers.foo, 'bar'); 301cb0ef41Sopenharmony_ci assert.strictEqual(headers.abc, '123'); 311cb0ef41Sopenharmony_ci assert.strictEqual(headers[':status'], 200); 321cb0ef41Sopenharmony_ci }, 1)); 331cb0ef41Sopenharmony_ci request.on('end', common.mustCall(() => { 341cb0ef41Sopenharmony_ci client.close(); 351cb0ef41Sopenharmony_ci })); 361cb0ef41Sopenharmony_ci request.end(); 371cb0ef41Sopenharmony_ci request.resume(); 381cb0ef41Sopenharmony_ci })); 391cb0ef41Sopenharmony_ci })); 401cb0ef41Sopenharmony_ci} 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci{ 431cb0ef41Sopenharmony_ci const server = http2.createServer(); 441cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 451cb0ef41Sopenharmony_ci const port = server.address().port; 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ci server.once('request', common.mustCall((request, response) => { 481cb0ef41Sopenharmony_ci const returnVal = response.writeHead(200, ['foo', 'bar', 'ABC', 123]); 491cb0ef41Sopenharmony_ci assert.strictEqual(returnVal, response); 501cb0ef41Sopenharmony_ci response.end(common.mustCall(() => { server.close(); })); 511cb0ef41Sopenharmony_ci })); 521cb0ef41Sopenharmony_ci 531cb0ef41Sopenharmony_ci const client = http2.connect(`http://localhost:${port}`, common.mustCall(() => { 541cb0ef41Sopenharmony_ci const request = client.request(); 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ci request.on('response', common.mustCall((headers) => { 571cb0ef41Sopenharmony_ci assert.strictEqual(headers.foo, 'bar'); 581cb0ef41Sopenharmony_ci assert.strictEqual(headers.abc, '123'); 591cb0ef41Sopenharmony_ci assert.strictEqual(headers[':status'], 200); 601cb0ef41Sopenharmony_ci }, 1)); 611cb0ef41Sopenharmony_ci request.on('end', common.mustCall(() => { 621cb0ef41Sopenharmony_ci client.close(); 631cb0ef41Sopenharmony_ci })); 641cb0ef41Sopenharmony_ci request.end(); 651cb0ef41Sopenharmony_ci request.resume(); 661cb0ef41Sopenharmony_ci })); 671cb0ef41Sopenharmony_ci })); 681cb0ef41Sopenharmony_ci} 691cb0ef41Sopenharmony_ci 701cb0ef41Sopenharmony_ci{ 711cb0ef41Sopenharmony_ci const server = http2.createServer(); 721cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 731cb0ef41Sopenharmony_ci const port = server.address().port; 741cb0ef41Sopenharmony_ci 751cb0ef41Sopenharmony_ci server.once('request', common.mustCall((request, response) => { 761cb0ef41Sopenharmony_ci try { 771cb0ef41Sopenharmony_ci response.writeHead(200, ['foo', 'bar', 'ABC', 123, 'extra']); 781cb0ef41Sopenharmony_ci } catch (err) { 791cb0ef41Sopenharmony_ci assert.strictEqual(err.code, 'ERR_INVALID_ARG_VALUE'); 801cb0ef41Sopenharmony_ci } 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ci response.end(common.mustCall(() => { server.close(); })); 831cb0ef41Sopenharmony_ci })); 841cb0ef41Sopenharmony_ci 851cb0ef41Sopenharmony_ci const client = http2.connect(`http://localhost:${port}`, common.mustCall(() => { 861cb0ef41Sopenharmony_ci const request = client.request(); 871cb0ef41Sopenharmony_ci 881cb0ef41Sopenharmony_ci request.on('end', common.mustCall(() => { 891cb0ef41Sopenharmony_ci client.close(); 901cb0ef41Sopenharmony_ci })); 911cb0ef41Sopenharmony_ci request.end(); 921cb0ef41Sopenharmony_ci request.resume(); 931cb0ef41Sopenharmony_ci })); 941cb0ef41Sopenharmony_ci })); 951cb0ef41Sopenharmony_ci} 96