Using curl to test POST data: Difference between revisions
Jump to navigation
Jump to search
(Created page with "==Basic request passing variables as POST== Use <code>--data</code> or <code>-d</code> option to pass variables to the page. <syntaxhighlight lang="bash"> $ curl -d "user=mylo...") |
No edit summary |
||
| Line 18: | Line 18: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
$ curl -u mylogin:myp\&ss --ntlm -d "user=mylogin&pass=mypass&foo=bar&biz=bash" http://www.mydomain.com/mypage/ | $ curl -u mylogin:myp\&ss --ntlm -d "user=mylogin&pass=mypass&foo=bar&biz=bash" http://www.mydomain.com/mypage/ | ||
</syntaxhighlight> | |||
==Storing arguments in a text file== | |||
Content of file, saved as <code>curlargs.txt</code>: | |||
<pre> | |||
-d foo=bar&biz=bash http://localhost/mytestpage.html | |||
</pre> | |||
Run curl using contents of <code>curlargs.txt</code> (in a bash shell): | |||
<syntaxhighlight lang="bash"> | |||
$ cat curlargs.txt | xargs -n3 curl | |||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Web Development]] | [[Category:Web Development]] | ||
Revision as of 20:20, 21 November 2012
Basic request passing variables as POST
Use --data or -d option to pass variables to the page.
$ curl -d "user=mylogin&pass=mypass&foo=bar&biz=bash" http://www.mydomain.com/mypage/
Request using basic authentication
Use --user or -u option.
$ curl -u mylogin:mypass -d "user=mylogin&pass=mypass&foo=bar&biz=bash" http://www.mydomain.com/mypage/
Request using Windows integrated authentication
Add --ntlm option.
$ curl -u mylogin:mypass --ntlm -d "user=mylogin&pass=mypass&foo=bar&biz=bash" http://www.mydomain.com/mypage/
Special characters in username or password
Escape special characters with back slash.
$ curl -u mylogin:myp\&ss --ntlm -d "user=mylogin&pass=mypass&foo=bar&biz=bash" http://www.mydomain.com/mypage/
Storing arguments in a text file
Content of file, saved as curlargs.txt:
-d foo=bar&biz=bash http://localhost/mytestpage.html
Run curl using contents of curlargs.txt (in a bash shell):
$ cat curlargs.txt | xargs -n3 curl