Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL - - digest command

Tags:

curl

Please explain this curl command:

curl --digest \
    -u{username}:{password} \
    -v \
    -X PUT \
    -H 'Expect: ' \
    -H 'Content-type: application/xml' \
    -d @- \
    http://webapi.ebayclassifieds.com/webapi/partners/{username}/ads/{ext-reference-id} \
        < ad.xml 

What does the < sign mean?

What I understand:

[--digest] its a digest authentication
[-u{username}:{password}] obviously username and password
[-X PUT] method="put"
[-H 'Expect: '] header = 'Expect: '
[-H 'Content-type: application/xml'] additional header

This is probably what I don't get -d @- url < ad.xml [-d @- http://webapi.ebayclassifieds.com/webapi/partners/{username}/ads/{ext-reference-id} < ad.xml ]

What I found:

-d, --data

(HTTP) 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. Compare to -F, --form.

-d, --data is the same as --data-ascii. 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 together with a separating &-symbol. Thus, using '-d name=daniel -d skill=lousy' would generate 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. The contents of the file must already be URL-encoded. Multiple files can also be specified. Posting data from a file named 'foobar' would thus be done with --data @foobar.

Leading question: If somebody knows how to translate this to cfhttp just dont mind the digest authentication and assume request is working with digest authentication.

like image 286
Vlad Avatar asked Feb 24 '12 18:02

Vlad


1 Answers

The "-d@ -" option means that curl will send a POST request with the data it reads from stdin.

The '<' operator tells the shell to feed a file to stdin.

You could make a simpler command line by instead doing -d @ad.xml and not use stdin at all.

like image 63
Daniel Stenberg Avatar answered Oct 19 '22 10:10

Daniel Stenberg