collective / sphinxcontrib-httpexample

Adds example directive for sphinx-contrib httpdomain
23 stars 20 forks source link

Invalid parmeter for curl (at least on MacOS) --data-raw #77

Closed phforesteot closed 1 year ago

phforesteot commented 1 year ago

Hi, When running a curl command on mac the option --data-raw does not exists it should be --data.

  curl --help
  Usage: curl [options...] <url>
  -d, --data <data>   HTTP POST data
  -f, --fail          Fail silently (no output at all) on HTTP errors
  -h, --help <category>  Get help for commands
  -i, --include       Include protocol response headers in the output
  -o, --output <file>  Write to file instead of stdout
  -O, --remote-name   Write output to a file named as the remote file
  -s, --silent        Silent mode
  -T, --upload-file <file>  Transfer local FILE to destination
  -u, --user <user:password>  Server user and password
  -A, --user-agent <name>  Send User-Agent <name> to server
  -v, --verbose       Make the operation more talkative
  -V, --version       Show version number and quit

Regards Thx

https://github.com/collective/sphinxcontrib-httpexample/blob/bb21e6359e0193b017eef8001cbfd5023ce87d35/src/sphinxcontrib/httpexample/builders.py#L97

datakurre commented 1 year ago

@tisto @sneridagh Sorry but you are the first Mac users I remembered and have been users of this sphinx extension from the beginning. It might that @tisto actually recommended we to use --data-raw in the first place instead of --data.

Can you confirm this?

From curl man page in Linux

       -d, --data <data>
              (HTTP  MQTT)  Sends  the specified data in a POST request to the HTTP server, in the same way that a
              browser does when a user has filled in an HTML form and presses the submit button. This  will  cause
              curl  to  pass the data to the server using the content-type application/x-www-form-urlencoded. Com‐
              pare to -F, --form.

              --data-raw is almost the same but does not have a special interpretation of the @ character. To post
              data  purely  binary,  you should instead use the --data-binary option. To URL-encode the value of a
              form field you may use --data-urlencode.

              If any of these options is used more than once on the same command line, the data  pieces  specified
              will  be merged with a separating &-symbol. Thus, using '-d name=daniel -d skill=lousy' would gener‐
              ate a post chunk that looks like 'name=daniel&skill=lousy'.

              If you start the data with the letter @, the rest should be a file name to read the data from, or  -
              if  you want curl to read the data from stdin. Posting data from a file named 'foobar' would thus be
              done with -d, --data @foobar. When --data is told to read from a file like  that,  carriage  returns
              and  newlines will be stripped out. If you do not want the @ character to have a special interpreta‐
              tion use --data-raw instead.

              Examples:
               curl -d "name=curl" https://example.com
               curl -d "name=curl" -d "tool=cmdline" https://example.com
               curl -d @filename https://example.com

              See also --data-binary, --data-urlencode and --data-raw. This option is mutually  exclusive  to  -F,
              --form and -I, --head and -T, --upload-file.

So quite possibly using just --data would be safe enough too, but that would be a minor surprise change to all the docs around.

phforesteot commented 1 year ago

I'm sorry, I must have done something wrong. When using man curl , then I saw the option. And it's working fine.