busboy icon indicating copy to clipboard operation
busboy copied to clipboard

Content-types with parameters: parameters not reported on 'file' event

Open fabriziolussana opened this issue 10 years ago • 3 comments

I am trying to parse requests with parts that have content-types with parameters, e.g.:

audio/x-raw;format=S8;rate=16000

(from http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-types-definitions.html).

When the 'file' event is triggered, the mimeType reported does not show any of the above parameters, it's just 'audio/x-raw'. Is that by design?

I can see where this is happening. In multipart.js, the content-type is parsed, but why is the base alone returned with the event and not the parameters (at least those not consumed by / unknown to busboy)?

Thanks!

fabriziolussana avatar Nov 13 '15 20:11 fabriziolussana

Typically there are no parameters, that is why only the mime type is included.

The problem with adding them now is it would mean adding yet another parameter, which I am reluctant to do anymore. An addition like this would most likely be folded into a backwards incompatible change where objects are passed to event handlers instead of many function parameters. That kind of change is just something I haven't gotten to yet. If you're feeling adventurous and want to submit a PR to make these kinds of changes, feel free.

mscdex avatar Nov 13 '15 21:11 mscdex

I see. I wasn't really thinking about an object to be passed to the event handler nor expecting busboy to return those parameters as properties. When I first started my parsing attempts I was just expecting the entire content type to be passed, as a string, to the handler.

fabriziolussana avatar Nov 13 '15 21:11 fabriziolussana

Well if the literal string was passed it would no longer be just the mime type, it could include parameters, which might throw people off if they are comparing that value to some known list of mime types for example.

mscdex avatar Nov 13 '15 23:11 mscdex