Skip to content

Commit

Permalink
test: Update major busboy version (#1457)
Browse files Browse the repository at this point in the history
* test: update busboy

* make linter happy
  • Loading branch information
jimmywarting committed Jan 17, 2022
1 parent dd2cea4 commit 1028f83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -46,7 +46,7 @@
"devDependencies": {
"abort-controller": "^3.0.0",
"abortcontroller-polyfill": "^1.7.1",
"busboy": "^0.3.1",
"busboy": "^1.4.0",
"c8": "^7.7.2",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
Expand Down
17 changes: 8 additions & 9 deletions test/utils/server.js
@@ -1,7 +1,7 @@
import http from 'node:http';
import zlib from 'node:zlib';
import {once} from 'node:events';
import Busboy from 'busboy';
import busboy from 'busboy';

export default class TestServer {
constructor(hostname) {
Expand Down Expand Up @@ -465,29 +465,28 @@ export default class TestServer {
}

if (p === '/multipart') {
let body = '';
res.statusCode = 200;
res.setHeader('Content-Type', 'application/json');
const busboy = new Busboy({headers: request.headers});
let body = '';
busboy.on('file', async (fieldName, file, fileName) => {
body += `${fieldName}=${fileName}`;
const bb = busboy({headers: request.headers});
bb.on('file', async (fieldName, file, info) => {
body += `${fieldName}=${info.filename}`;
// consume file data
// eslint-disable-next-line no-empty, no-unused-vars
for await (const c of file) {}
});

busboy.on('field', (fieldName, value) => {
bb.on('field', (fieldName, value) => {
body += `${fieldName}=${value}`;
});
busboy.on('finish', () => {
bb.on('close', () => {
res.end(JSON.stringify({
method: request.method,
url: request.url,
headers: request.headers,
body
}));
});
request.pipe(busboy);
request.pipe(bb);
}

if (p === '/m%C3%B6bius') {
Expand Down

0 comments on commit 1028f83

Please sign in to comment.