-
-
Notifications
You must be signed in to change notification settings - Fork 683
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4f82bc
commit d9c8608
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {Readable} from 'node:stream'; | ||
import MultipartParser from '../../src/parsers/Multipart.js'; | ||
import {malformedMultipart} from '../../src/FormidableError.js'; | ||
|
||
import test from 'node:test'; | ||
import assert, { deepEqual } from 'node:assert'; | ||
|
||
|
||
|
||
test('MultipartParser does not hang', async (t) => { | ||
const mime = `--_\r\n--_--\r\n`; | ||
const parser = new MultipartParser(); | ||
parser.initWithBoundary('_'); | ||
try { | ||
for await (const {name, buffer, start, end} of Readable.from(mime).pipe(parser)) { | ||
console.log(name, buffer ? buffer.subarray(start, end).toString() : ''); | ||
} | ||
|
||
} catch (e) { | ||
deepEqual(e.code, malformedMultipart) | ||
return; | ||
// console.error('error'); | ||
// console.error(e); | ||
|
||
} | ||
assert(false, 'should catch error'); | ||
}); |