Automate Curl multiple HTTP requests


Answer: 1

20 hours ago

On Ubuntu server 16.04.6, I am using Curl (v. 7.47.0) to test my web-server and network components.

Using the -: option (also known as --next), I keep the TCP connection open, and send multiple HTTP requests to my server, for example:

 curl -s -o /dev/null -: -s -d "data" -:

Now, assuming I would like to send exactly the same HTTP request 3 times, I would use:

curl -o /dev/null -: -o /dev/null -: -o /dev/null

My question is: is there a way to repeat this HTTP request to the same uri with same options "n" amount of times without adding -: -o /dev/null over and over again?

For example, sending 100 of the same HTTP requests using the same TCP connection without writing -: -o /dev/null 99 times?

Added by: Ruby Purdy

Answer: 2

33 hours ago

You can use xargs for this purpose like this:

for i in {1..100} ; do
  echo ' -o /dev/null -:'
done | xargs curl -s

Please, note that xargs will not produce a command larger than 2,088,616 characters in my system. You can determine this maximum length in your system by running xargs --show-limits in your system.

Added by: Shawna Hand

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9