Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Update major busboy version #1457

Merged
merged 2 commits into from Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -458,29 +458,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