Skip to content

Commit 0148b7a

Browse files
committed
more fixes
1 parent 094c431 commit 0148b7a

File tree

3 files changed

+108
-1
lines changed

3 files changed

+108
-1
lines changed

src/js/node/http.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ const NodeHTTPServerSocket = class Socket extends Duplex {
385385
$isCallable(callback) && callback(err);
386386
return;
387387
}
388-
388+
389389
this.#closeHandle(handle, callback);
390390
}
391391

@@ -3331,6 +3331,7 @@ const METHODS = [
33313331
"PROPPATCH",
33323332
"PURGE",
33333333
"PUT",
3334+
"QUERY",
33343335
"REBIND",
33353336
"REPORT",
33363337
"SEARCH",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const http = require('http');
5+
6+
const makeRequest = (port, agent) =>
7+
new Promise((resolve, reject) => {
8+
const req = http.get(
9+
{ path: '/', port, agent },
10+
(res) => {
11+
res.resume();
12+
res.on('end', () => resolve());
13+
},
14+
);
15+
req.on('error', (e) => reject(e));
16+
req.end();
17+
});
18+
19+
const server = http.createServer(
20+
{ keepAliveTimeout: common.platformTimeout(2000), keepAlive: true },
21+
common.mustCall((req, res) => {
22+
const body = 'hello world\n';
23+
res.writeHead(200, { 'Content-Length': body.length });
24+
res.write(body);
25+
res.end();
26+
}, 2)
27+
);
28+
29+
const agent = new http.Agent({ maxSockets: 5, keepAlive: true });
30+
31+
server.listen(0, common.mustCall(async function() {
32+
await makeRequest(this.address().port, agent);
33+
// Block the event loop for 2 seconds
34+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 2000);
35+
await makeRequest(this.address().port, agent);
36+
server.close();
37+
agent.destroy();
38+
}));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright Joyent, Inc. and other Node contributors.
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a
4+
// copy of this software and associated documentation files (the
5+
// "Software"), to deal in the Software without restriction, including
6+
// without limitation the rights to use, copy, modify, merge, publish,
7+
// distribute, sublicense, and/or sell copies of the Software, and to permit
8+
// persons to whom the Software is furnished to do so, subject to the
9+
// following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included
12+
// in all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
'use strict';
23+
require('../common');
24+
const assert = require('assert');
25+
const http = require('http');
26+
27+
// This test ensures all http methods from HTTP parser are exposed
28+
// to http library
29+
30+
const methods = [
31+
'ACL',
32+
'BIND',
33+
'CHECKOUT',
34+
'CONNECT',
35+
'COPY',
36+
'DELETE',
37+
'GET',
38+
'HEAD',
39+
'LINK',
40+
'LOCK',
41+
'M-SEARCH',
42+
'MERGE',
43+
'MKACTIVITY',
44+
'MKCALENDAR',
45+
'MKCOL',
46+
'MOVE',
47+
'NOTIFY',
48+
'OPTIONS',
49+
'PATCH',
50+
'POST',
51+
'PROPFIND',
52+
'PROPPATCH',
53+
'PURGE',
54+
'PUT',
55+
'QUERY',
56+
'REBIND',
57+
'REPORT',
58+
'SEARCH',
59+
'SOURCE',
60+
'SUBSCRIBE',
61+
'TRACE',
62+
'UNBIND',
63+
'UNLINK',
64+
'UNLOCK',
65+
'UNSUBSCRIBE',
66+
];
67+
68+
assert.deepStrictEqual(http.METHODS, methods.sort());

0 commit comments

Comments
 (0)