Open In App

Sending HTTP Request Using cURL Set-1

Last Updated : 01 Aug, 2021
Like Article

Whenever we are dealing with HTTP requests, cURL simplifies our tasks to a great extent and is the easiest tool to get our hands dirty on.

cURL: It stands for “client URL” and is used in command line or scripts to transfer data. It is a great tool for dealing with HTTP requests like GET, POST, PUT, DELETE, etc. Although it provides us with the support of other internet protocols like HTTPS, FTP, SMTP, TELNET, we will be limiting it to HTTP in this article.

Pre-requisite: Install cURL properly as per your underlying operating system.

To check if it’s installed in your system or to know its version, the following command is executed in the command prompt


 curl --version


curl 7.67.0 (x86_64-pc-linux-gnu) libcurl/7.67.0 OpenSSL/1.1.1d zlib/1.2.11  
brotli/1.0.7 libidn2/2.2.0 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.41.0 librtmp/2.3 
Release-Date: 2019-11-06 
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets 

We can see that the output states the version, release date, protocols, and other features of curl as –version flag was used.

Note: The output may differ based on the version and the underlying operating system.

GET request using cURL: Get request is the most commonly used HTTP request as it is used to request the data from the server about a particular target i.e website. Let’s start by executing a simple Get request.


Note that instead of, you can specify the target on which you want to request the data.

Example :


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <link rel="stylesheet" href="./style.css">
        <h1>Admin panel</h1>
    <form action="" method="post">
        <div class="group">
            <input name="username" type="text">
            <span class="highlight"></span>
            <span class="bar"></span>
        <div class="group">
            <input name="password" type="password">
            <span class="highlight"></span>
            <span class="bar"></span>
        <button type="submit" class="button buttonBlue">
            <div class="ripples buttonRipples">
                <span class="ripplesCircle"></span>
    <script src=
    <script src="./script.js"></script>

In this manner, you will get the entire output which will be the same if your query through the browser and the response from the server is rendered by your client browser and then shown to you in a simplified manner.

Note: If you will view the target source code, you will find the same output.

Many other flags can be used with the above query. 

  • -v: It is used to get verbose output. 
curl -v
  • -u: Server user and password. 
 curl -u username:password -v
  • -L: Follow redirects. 
curl -u username:password -L -v
  • -X: Specify request command to use. 
curl -X GET -v

Note: By default curl uses GET request if we don’t specify the request command.

  • -s: Silent mode. 
curl -u username:password -s -L -v

You can dive deeply into using different flags as per the need with the help of the -h flag.

curl -h


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads