Creating a lame utility HTTP server
In this recipe, we will discuss the cURL tool in Linux. The cURL tool is used for transferring the data from or to a server. It supports many protocols, and http
is one of them. cURL is used to transfer the data from URL. It has so many tricks to offer, such as http post, ftp post, user authentication, proxy support, file transfer, SSL connections, cookies, and similar.
Getting ready
Besides having a Terminal open, you need to ensure that you have curl
installed on your system.
How to do it…
We will learn about HTTP GET
and POST
methods using curl
in Linux. Now, we will see examples of GET
and POST
:
GET
: The HTTP GET method is used to request a data from a specified resource. The command is the example of HTTP GET and is accepting JSON formatted data:
$ curl -H "Content-Type:application/json" -H "Accept:application/json" -X GET http://host/resource/name
Another example of HTTP GET, which is accepting XML formatted data is as follows:
$ curl -H "Content-Type:application...