How to install curl will depend on your operating system, but it's available for practically every platform you are likely to work with; just check out all the downloads at https://curl.haxx.se/download.html. The command has dozens of possible options, but for our intents, we will be looking at the following table. Note that most options have two versions: a short, single character one, and a longer one, intended to be clearer for understanding:
-K filename
--config filename
|
Lets you specify the name of a file that has options in it so that your command is shorter. In the given file, each option will be in a different line. |
-d key=value
--data key=value
|
Allows you to send data in the body of the request. If you use this option several times, curl will use & as a separator, as standard. |
--data-binary someData
|
Similar to --data, but used to send binary data. Most frequently it is followed by @filename, meaning that the contents of the named file will be sent. |
-D filename
--dump-header filename
|
Dumps the headers of the received data into a file. |
-H "header:value"
--header "header:value"
|
Allows you to set and send some header with a request. You can use this option several times to set many headers. |
-i
--include
|
Includes headers of the received data in the output. |
-o filename
--output filename
|
Stores the received data in the given file. |
-s
--silent
|
Minimizes output to the console. |
-v
--verbose
|
Maximizes output to the console. |
-X method
--request method
|
Specifies which HTTP method will be used, such as GET, POST, PUT, and so on. |
Finally, if you need help, use curl --help or curl --manual, and you'll get a full description of the utility and its options. Now let's look at how we can use curl to test our services.