insomnia icon indicating copy to clipboard operation
insomnia copied to clipboard

[Bug] `copy as curl` does not url encode "form url encoded parameters"

Open timrs2998 opened this issue 5 years ago • 3 comments

Describe the bug

If I copy as curl a regular GET request with query paramters, the query parameters are URL Encoded as expected:

curl --request GET \
  --url 'http://google.com/?asdf=asdf%20asdf'

However, if I copy as curl a POST request with form url encoded paramters, the form parameters are not url encoded:

curl --request POST \
  --url http://google.com/ \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'asdf=asdf asdf'

This is inconsistent with the query parameter behavior and causes copy as curl to produce a different request than what Insomnia executes. When executing the request in Insomnia, the parameters are url encoded correctly as shown in the timeline.

The expected copy as curl output is:

curl --request POST \
  --url http://google.com/ \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'asdf=asdf%20asdf'

To Reproduce Steps to reproduce the behavior:

  1. Create new request
  2. Change method to "POST"
  3. Change method to "Form URL Encoded"
  4. Add a form paramter that requires encoding
  5. View the timeline, Insomnia URL encodes correctly
  6. Copy as curl, the URL encoding is absent

Expected behavior

  • Insomnia's behavior matches the behavior of the "copy as curl" request
  • Form URL paramters are URL Encoded in "copy as curl"

Screenshots

NA

Desktop (please complete the following information):

  • OS: macOS 10.14.6
  • Installation Method: App
  • App Version v7.0.1

Additional context

NA

timrs2998 avatar Feb 20 '20 17:02 timrs2998

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 31 '21 07:05 stale[bot]

Hi @timrs2998 thanks for reporting this issue, and apologies for not getting back sooner!

The root of this problem is in an underlying dependency, httpsnippet that we use - It had been reported in https://github.com/Kong/httpsnippet/issues/197 and there was a fix merged for it recently: https://github.com/Kong/httpsnippet/pull/198.

We'll update you here as soon as we update the dependency in Insomnia.

Heads up @dimitropoulos when we release a new version of httpsnippet and update Insomnia, we should be able to close this issue

filfreire avatar Jul 28 '22 11:07 filfreire