multipart: expose parsed Content-Disposition params on file/field info - #387
Open
Martin-Luther wants to merge 1 commit into
Open
Martin-Luther wants to merge 1 commit into
Martin-Luther wants to merge 1 commit into
Conversation
Surface the full set of parsed Content-Disposition parameters for each part as info.dispositionParams on both the file and field events. This exposes the standard parameters (name, filename) as well as any custom parameter (for example a group tag) without changing any existing field of the info object.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the already-parsed
Content-Dispositionparameters to theinfoobject thatis passed to the
fileandfieldevents, asinfo.dispositionParams.Motivation
A multipart part's
Content-Dispositionheader can carry parameters beyondnameand
filename. busboy already parses the complete parameter list viaparseParams,but only surfaces
nameandfilename— so a consumer that needs any otherparameter has to re-parse the raw header itself.
That duplication is the problem: a second parser has to re-implement RFC 2231
continuations and charset-tagged values (
name*=utf-8''...) to stay consistent withbusboy, and any divergence between the two silently misattributes parts. Exposing the
value busboy has already computed removes the need for a second parser entirely.
What changes
lib/types/multipart.js: the parseddisp.paramsis retained per part and includedin the
infoobject emitted with thefileandfieldevents, asdispositionParams. It isnullfor a part with noContent-Dispositionheader.That is the whole change — 10 lines. No new options, no signature changes, nothing
removed or renamed.
Compatibility
Strictly additive: one new property on an object that is already passed to the
listener.
info.name/info.filename/info.encoding/info.mimeTypeand everyexisting event signature are untouched, so existing consumers are unaffected whether
or not they read the new property.
Tests
test/test-types-multipart-disposition-params.js(new) — covers the exposedparameters for both
fileandfieldparts, including a part with noContent-Dispositionheader.test/test-types-multipart.js— extended to assert the new property alongside theexisting expectations.
test/test-types-multipart-charsets.js,test/test-types-multipart-stream-pause.js— updated where they assert the full
infoshape.Related
#183 asks for the same underlying capability (making additional multipart header
information available). This PR is the narrower form of that request: rather than
surfacing arbitrary headers, it exposes only what
parseParamsalready produces forContent-Disposition, which keeps the surface small and avoids any new parsing.