Skip to content

cUrl target does not encode body for application/x-www-form-urlencoded request #197

Closed

Description

@jgiovaresco

cUrl target does not URL encode when the request is a POST request with form URL encoded parameters.

Given the following HAR request

{
   "method":"POST",
   "url":"http://localhost:3000/url-encoded",
   "httpVersion":"HTTP/1.1",
   "cookies":[],
   "headers":[
      {
         "name":"Content-Type",
         "value":"application/x-www-form-urlencoded"
      }
   ],
   "queryString":[],
   "postData":{
      "mimeType":"application/x-www-form-urlencoded",
      "text":"%24filter=my%26value%20%3D%201",
      "params":[
         {
            "name":"$filter",
            "value":"my&value = 1"
         }
      ],
      "size":0,
      "jsonObj":false,
      "paramsObj":{
         "$filter":"my&value = 1"
      }
   },
   "headersSize":-1,
   "bodySize":-1,
   "settingEncodeUrl":true
}

The current cUrl snippet is

curl --request POST \
  --url http://localhost:3000/url-encoded \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data '$filter=my&value = 1'

To tell to cUrl to URL encode the data, we should use --data-urlencode. This will encode the value, but we should also encode the key. It can be done by prefixing the string to encode with =.
source

See Kong/insomnia#1958

Activity

  1. added 4 commits that reference this issue on Oct 31, 2020
    4aa1c9c
    3e3f425
    8f6fa17
    8cc8fc7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions