Skip to content

Commit 7733e1e

Browse files
committed
fix: update deps, finally fix keep-alive tests
Signed-off-by: Charlike Mike Reagent <[email protected]>
1 parent 8ea22e0 commit 7733e1e

File tree

3 files changed

+34
-36
lines changed

3 files changed

+34
-36
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"eslint-plugin-prettier": "^3.1.2",
3030
"prettier": "^1.19.1",
3131
"prettier-plugin-pkgjson": "^0.2.0",
32-
"request": "^2.11.4",
33-
"urun": "^0.0.6",
32+
"request": "^2.88.0",
33+
"urun": "^0.0.8",
3434
"utest": "^0.0.8"
3535
}
3636
}

test/standalone/test-keep-alive-error.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const formidable = require('../../src/index');
88
let ok = 0;
99
let errors = 0;
1010

11-
const PORT = 13532;
11+
const PORT = 0;
1212
const server = http.createServer((req, res) => {
1313
const form = formidable();
1414
form.on('error', () => {
@@ -24,45 +24,50 @@ const server = http.createServer((req, res) => {
2424
form.parse(req);
2525
});
2626

27-
server.listen(PORT, 'localhost', () => {
27+
server.listen(PORT, () => {
2828
const choosenPort = server.address().port;
2929
const url = `http://localhost:${choosenPort}`;
3030
console.log('Server up and running at:', url);
3131

3232
const client = net.createConnection(choosenPort);
3333

34-
// first send malformed post upload
34+
// first send malformed (boundary / hyphens) post upload
3535
client.write(
3636
'POST /upload-test HTTP/1.1\r\n' +
3737
'Host: localhost\r\n' +
3838
'Connection: keep-alive\r\n' +
3939
'Content-Type: multipart/form-data; boundary=----aaa\r\n' +
4040
'Content-Length: 10011\r\n\r\n' +
4141
'------aaa\n\r',
42-
); // expected \r\n
42+
);
4343

4444
setTimeout(() => {
4545
const buf = Buffer.alloc(10000);
4646
buf.fill('a');
4747
client.write(buf);
48-
49-
// correct post upload
50-
client.write(
51-
'POST /upload-test HTTP/1.1\r\n' +
52-
'Host: localhost\r\n' +
53-
'Connection: keep-alive\r\n' +
54-
'Content-Type: multipart/form-data; boundary=----aaa\r\n' +
55-
'Content-Length: 13\r\n\r\n' +
56-
'------aaa--\r\n',
57-
);
48+
client.end();
5849

5950
setTimeout(() => {
60-
assert.strictEqual(ok, 1, `should ok count === 1, has: ${ok}`);
61-
// TODO: fix it!
62-
// assert.strictEqual(errors, 1, 'should errors count === 1, has: ' + errors);
63-
console.log('should errors === 1', errors);
64-
client.end();
65-
server.close();
66-
}, 100);
67-
}, 100);
51+
assert.strictEqual(errors, 1, `should "errors" === 1, has: ${errors}`);
52+
53+
const clientTwo = net.createConnection(choosenPort);
54+
55+
// correct post upload (with hyphens)
56+
clientTwo.write(
57+
'POST /upload-test HTTP/1.1\r\n' +
58+
'Host: localhost\r\n' +
59+
'Connection: keep-alive\r\n' +
60+
'Content-Type: multipart/form-data; boundary=----aaa\r\n' +
61+
'Content-Length: 13\r\n\r\n' +
62+
'------aaa--\r\n',
63+
);
64+
clientTwo.end();
65+
66+
setTimeout(() => {
67+
assert.strictEqual(ok, 1, `should "ok" count === 1, has: ${ok}`);
68+
69+
server.close();
70+
}, 300);
71+
}, 200);
72+
}, 150);
6873
});

yarn.lock

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,7 @@ regexpp@^2.0.1:
13541354
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f"
13551355
integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==
13561356

1357-
request@^2.11.4:
1357+
request@^2.88.0:
13581358
version "2.88.0"
13591359
resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef"
13601360
integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==
@@ -1687,17 +1687,10 @@ uri-js@^4.2.2:
16871687
dependencies:
16881688
punycode "^2.1.0"
16891689

1690-
urun@^0.0.6:
1691-
version "0.0.6"
1692-
resolved "https://registry.yarnpkg.com/urun/-/urun-0.0.6.tgz#e0fa856980367d86bf146e180bc3890320ab1d2f"
1693-
integrity sha1-4PqFaYA2fYa/FG4YC8OJAyCrHS8=
1694-
dependencies:
1695-
utest "0.0.2"
1696-
1697-
1698-
version "0.0.2"
1699-
resolved "https://registry.yarnpkg.com/utest/-/utest-0.0.2.tgz#3862e2975309ea5de0940444a6c6ee0179726a16"
1700-
integrity sha1-OGLil1MJ6l3glAREpsbuAXlyahY=
1690+
urun@^0.0.8:
1691+
version "0.0.8"
1692+
resolved "https://registry.yarnpkg.com/urun/-/urun-0.0.8.tgz#3799a0293714c1115d326a4e69e2a5f96ee786e2"
1693+
integrity sha1-N5mgKTcUwRFdMmpOaeKl+W7nhuI=
17011694

17021695
utest@^0.0.8:
17031696
version "0.0.8"

0 commit comments

Comments
 (0)