Skip to content

Commit

Permalink
test: updating to test 304 and 204 explicity
Browse files Browse the repository at this point in the history
  • Loading branch information
josephhackman committed Jul 8, 2020
1 parent 9e30728 commit 44d4d6d
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions test/parallel/test-http-reuse-socket.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
const common = require('../common');
const http = require('http');
Expand All @@ -28,8 +7,8 @@ const Countdown = require('../common/countdown');
// The HEAD:204, GET:200 was the most pathological test case I could find.
// GETs following a 204 response with a content-encoding header failed.
// Responses without bodies and without content-length or encoding caused
// the socket to be closed.
const codes = [204, 200, 200];
// the socket to be closed.
const codes = [304, 204, 200, 200];
const methods = ['HEAD', 'HEAD', 'GET'];

const sockets = [];
Expand All @@ -47,7 +26,6 @@ const server = http.createServer(common.mustCall((req, res) => {
}, codes.length));

function nextRequest() {

const request = http.request({
port: server.address().port,
path: '/',
Expand All @@ -63,11 +41,11 @@ function nextRequest() {
response.resume();
}));
request.on('socket', common.mustCall((socket) => {
if (sockets.indexOf(socket) === -1) {
if (!sockets.includes(socket)) {
sockets.push(socket);
}
}));
request.end();
}

server.listen(0, nextRequest);
server.listen(0, common.mustCall(nextRequest));

0 comments on commit 44d4d6d

Please sign in to comment.