CURL — Introduction

Tejaswini
1 min readJan 12, 2021

I was part of CRIO-Winter of doing and I learned about curl and it’s super awesome to have a tool like that. Although there are tools like postman now-s-days curl was invented way back in 1997 that can be used in Linux terminal.

  • Introduction:

CURL is Client URL which is a command line tool used to send and get HTTP requests for debugging or testing while you are developing or using Api’s .

Commands:

curl https://www.google.com

The above command is by default a GET command where the response is displayed in the form of HTML.

curl -o store.html https://www.google.com

The above command is used to push the content into a file like store.html and you can retrieve the data using the below command.

cat store.html 

For printing response headers the below command can be used

curl -i -X GET http://www.flipkart.com
  • Response:
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Tue, 12 Jan 2021 17:23:13 GMT
Content-Type: text/html
Content-Length: 178
Location: https://www.flipkart.com/
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor=”white”>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>

The below command is used to redirect the request

curl -v -L -X GET http://www.flipkart.com

For POST you can use the below command

curl -d'{key value pairs}' url

To get total time needed to load the website

curl -w "%{time_total}\n" -o /dev/null -s www.flipkart.com

Resources:

CURL is an open source project you can check it out https://github.com/curl/curl and contribute if you want:)

--

--

Tejaswini

Fitness Trainer and Nutritionist and Software Engineer