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

[v1.x] bad content-type: application/javascript - cannot handle the error #571

Closed
Portur opened this issue Feb 6, 2020 · 4 comments
Closed

Comments

@Portur
Copy link

Portur commented Feb 6, 2020

Hi,

Formidable throws when content-type is application/javascript OR application/XML.


Looking at the code I can see this is not supported
image


This specifically is using postman
image

Odd to throw, but I can't catch the error.

const form = formidable({ multiples: true, uploadDir: 'files/' });
form.on('error', (e) => {   //no such listener
    e
})

Am I doing something wrong?

@GrosSacASac
Copy link
Contributor

You will need a custom parser to handle XML and JavaScript content

@tunnckoCore
Copy link
Member

tunnckoCore commented Feb 6, 2020

@Portur try with formidable@canary or formidable@dev. And yet, it still should be throwing in that content-type. But at least should handle errors better, because #531 refactor of streams.

There probably won't be any new version in the v1.x. The codebase is changed a lot since then too. Not to mention the custom parsers (Plugins API) feature of v2 - #545.

@tunnckoCore tunnckoCore changed the title Error : bad content-type : application/javascript [v1.x] bad content-type : application/javascript - cannot handle errors Feb 6, 2020
@tunnckoCore tunnckoCore changed the title [v1.x] bad content-type : application/javascript - cannot handle errors [v1.x] bad content-type: application/javascript - cannot handle the error Feb 6, 2020
@Portur
Copy link
Author

Portur commented Feb 6, 2020

I would simply ignore any content-types that are not within my scope, which means ignoring application/javascript anyway. If there is a method to do that I'd use it today.

The documentation states an error listener. Is this incorrect?

form.once('error', console.error);

@GrosSacASac
Copy link
Contributor

@Portur yes if you are not using form.parse, otherwise check the first argument against null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants