11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ci// This test ensures that the http-parser doesn't expect a body when
51cb0ef41Sopenharmony_ci// a 304 Not Modified response has a non-zero Content-Length header
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst assert = require('assert');
81cb0ef41Sopenharmony_ciconst http = require('http');
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustCall((req, res) => {
111cb0ef41Sopenharmony_ci  res.setHeader('Content-Length', 11);
121cb0ef41Sopenharmony_ci  res.statusCode = 304;
131cb0ef41Sopenharmony_ci  res.end(null);
141cb0ef41Sopenharmony_ci}));
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ciserver.listen(0, () => {
171cb0ef41Sopenharmony_ci  const request = http.request({
181cb0ef41Sopenharmony_ci    port: server.address().port,
191cb0ef41Sopenharmony_ci  });
201cb0ef41Sopenharmony_ci
211cb0ef41Sopenharmony_ci  request.on('response', common.mustCall((response) => {
221cb0ef41Sopenharmony_ci    response.on('data', common.mustNotCall());
231cb0ef41Sopenharmony_ci    response.on('aborted', common.mustNotCall());
241cb0ef41Sopenharmony_ci    response.on('end', common.mustCall(() => {
251cb0ef41Sopenharmony_ci      assert.strictEqual(response.headers['content-length'], '11');
261cb0ef41Sopenharmony_ci      assert.strictEqual(response.statusCode, 304);
271cb0ef41Sopenharmony_ci      server.close();
281cb0ef41Sopenharmony_ci    }));
291cb0ef41Sopenharmony_ci  }));
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci  request.end(null);
321cb0ef41Sopenharmony_ci});
33