Skip to content

Conversation

@nicwaller
Copy link

Motivation

In a project recently, I was troubleshooting some failed form submissions with request and it was very useful for me to see the actual body of the multipart/form-data request. When I asked on Stack Overflow how to get the raw message body of the HTTP request, a few people suggested that I use this project (request-debug).

But until now, request-debug didn't actually show the body of multipart/form-data requests! So I added it.

Safety

This adds a dependency on form-data. That doesn't seem unreasonable, because request is already bringing in a version of form-data. But it's bringing in a slightly older version without the very useful getBuffer() method, so this change just monkey-patches the useful code onto the old object. The ideal solution would be for request to update their dependency on form-data to bring in 2.5.0 or higher.

This inspects a property (_form) that is internal to request. If that is ever removed, request-debug would fail safe. But if it was changed to a different object (not a form-data object) that could cause request-debug to fail.

Basically, this should work just fine until the next major version of form-data is released, and possibly longer.

nicwaller pushed a commit to nicwaller/request that referenced this pull request Aug 3, 2019
form-data 2.4.0 adds the getBuffer() function which is very helpful to request-debug
Ref: request/request-debug#26

Going to form-data 2.5.0 should also be fine because the changes are mostly non-functional, like adding TypeScript typings.
@nicwaller nicwaller closed this Aug 8, 2020
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.

1 participant