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

fix: handling of multipart/form-data requests #173

Merged
merged 19 commits into from
Aug 20, 2020

Conversation

erunion
Copy link
Contributor

@erunion erunion commented Aug 7, 2020

  • This fixes the implementation of form-data in multipart/form-data content types in order to accommodate library utilization within the browser where the native FormData component is used.
    • Key differences between form-data and FormData that was causing the library to fail in the browser were two issues:
      • The API for FormData.append has three arguments, and the third should only be present if the second is a Blob or USVString. It is never an object, as form-data requires it to be.
      • FormData.pipe() isn't a function.
  • Fixes a bug in the Node request target that was causing fs.createReadStream pointers to be stringified and unusable.
  • Updates the following targets to prioritize param.fileName if it's present, even if param.value also is:
    • Shell ↠ cURL
    • Node ↠ request
  • Updates the Node request target to prefer single quotes in require statements and request.cookie calls. Since the rest of the snippet already preferred this, this change makes the whole snippet look a touch more cohesive and consistent.

Resolves #111

@reynolek
Copy link
Contributor

@develohpanda Mind looking at this PR?

@develohpanda develohpanda self-requested a review August 16, 2020 23:47
@reynolek
Copy link
Contributor

@erunion I believe after merging the code that changed var -> const, this created a handful of merge conflicts.

@erunion
Copy link
Contributor Author

erunion commented Aug 17, 2020

@reynolek Conflicts resolved.

Copy link
Contributor

@develohpanda develohpanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work, thanks for putting your time into this PR! I am largely unfamiliar with this topic, and your code comments were very useful. 💯

I have just a couple of notes and questions, however nothing major nor blocking!

src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
src/targets/node/request.js Show resolved Hide resolved
src/targets/shell/curl.js Show resolved Hide resolved
src/helpers/form-data.js Show resolved Hide resolved
test/requests.js Show resolved Hide resolved
test/targets.js Show resolved Hide resolved
test/targets.js Show resolved Hide resolved
@erunion
Copy link
Contributor Author

erunion commented Aug 20, 2020

@develohpanda Thanks for the review, and I've addressed your feedback.

Copy link
Contributor

@develohpanda develohpanda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done, thanks for your explanations as well!

@develohpanda develohpanda merged commit 7da7657 into Kong:master Aug 20, 2020
@erunion erunion deleted the fix/multipart-handling branch August 20, 2020 23:58
@johanbook
Copy link

When will this fix be released @develohpanda?

@develohpanda
Copy link
Contributor

@johanbook I have added a card to our board to publish a new version, we'll get to it hopefully this week or next week.

@reynolek
Copy link
Contributor

Released in 1.23.0

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

Successfully merging this pull request may close these issues.

File uploads using multipart/form-data not working
4 participants