xref: /third_party/node/test/parallel/test-http-head-response-has-no-body-end-implicit-headers.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst http = require('http');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci// This test is to make sure that when the HTTP server
61cb0ef41Sopenharmony_ci// responds to a HEAD request with data to res.end,
71cb0ef41Sopenharmony_ci// it does not send any body but the response is sent
81cb0ef41Sopenharmony_ci// anyway.
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciconst server = http.createServer(function(req, res) {
111cb0ef41Sopenharmony_ci  res.end('FAIL'); // broken: sends FAIL from hot path.
121cb0ef41Sopenharmony_ci});
131cb0ef41Sopenharmony_ciserver.listen(0);
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciserver.on('listening', common.mustCall(function() {
161cb0ef41Sopenharmony_ci  const req = http.request({
171cb0ef41Sopenharmony_ci    port: this.address().port,
181cb0ef41Sopenharmony_ci    method: 'HEAD',
191cb0ef41Sopenharmony_ci    path: '/'
201cb0ef41Sopenharmony_ci  }, common.mustCall(function(res) {
211cb0ef41Sopenharmony_ci    res.on('end', common.mustCall(function() {
221cb0ef41Sopenharmony_ci      server.close();
231cb0ef41Sopenharmony_ci    }));
241cb0ef41Sopenharmony_ci    res.resume();
251cb0ef41Sopenharmony_ci  }));
261cb0ef41Sopenharmony_ci  req.end();
271cb0ef41Sopenharmony_ci}));
28

Indexes created Thu Nov 07 10:32:03 CST 2024