cURL: multiple POST requests while reusing the TCP connection

Since curl 7.36.0, the --next or -: command-line option allows delimiting URLs and their associated options. From the curl man page:

For example, you can do both a GET and a POST in a single command line:

curl www1.example.com --next -d postthis www2.example.com

Your desired request could be:

curl -d "a=1" -o 1 http://example.com/script.php --next -d "a=2" -o 2 http://example.com/script.php

The answer of Daniel Stenberg, the author of cURL:

We've previously discussed adding that ability but so far we haven't.

Tags:

Linux

Curl