cURL is the most widely used command on the terminal/console to test an HTTP GET request payload. It is very simple to use and comes pre-installed on Windows Command Line and macOS Terminal.
cURL HTTP GET request Syntax:
curl THE-HTTP-GET-URL
Example:
curl http://code2care.org/testing-http-get-with-curl-command
Example on Windows Command Prompt
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>This page was viewed using cURL command</title>
</head>
<body>
<h1>Hello World! cUrl Http Get</h1>
</body>
</html>
Example macOS or Linux Terminal:
$ curl google.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 219 100 219 0 0 2009 0 --:--:-- --:--:-- --:--:-- 2009
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
As you can see in the examples this is the simplest cURL command to fetch the content of an HTTP URL, it will print out the whole HTML source code of the URL in the console as output.
cURL HTTP GET request with Response Headers:
If you are interested in knowing the HTTP response headers as well you can make use of argument -i (include) to print it, as you can see below the headers are printed before the HTML payload.
$ curl -i google.com
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 219 100 219 0 0 1063 0 --:--:-- --:--:-- --:--:-- 1068
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Sat, 01 Aug 2020 11:43:19 GMT
Expires: Mon, 31 Aug 2020 11:43:19 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- [Fix] Error 1020 Cloudflare: Access was denied
- What is an Authorization Code Grant? OAuth 2.0
- Fix: psql: error: connection to server at localhost (::1) port 5432 failed: FATAL: database does not exist
- 100+ SEO Tips to improve your website search ranking
- How to submit website to dmoz directory
- How to check the version of NodeJS installed
- How to enter Rockstar Activation Code?
- Background task activation is spurious error - Windows 10, Office 2016, Office 365
- Angular CLI ng Error: You need to specify a command before moving on. Use --help to view the available commands
- cURL HTTP GET request command examples
- Fix - JioCinema Something Went Wrong Please Try Again Error 8001 while streaming IPL Cricket Live
- How to remove password from pdf file
- How to identify the version of IntelliJ
- Command: How to scp a file to remote server location?
- How to add Widgets to MacBook Desktop
- Setting up RSS feeds notifications within Outlook
- Fix - Website Connection timed out Error Code 522 (Cloudflare)
- How to fix: Please check your network connection (Retry)
- Fix: Could not connect to Redis at 127.0.0.1:6379: Connection refused
- Accept Only 0-9 Numbers RegEx Example
- How to create a New Project in Visual Studio Code (VS Code)
- Top 10 emerging breakthrough trending technologies
- Free Unlimited Calls from MTNL & BSNL Landlines from 1st May 2015
- [Error] zsh: command not found: mvn
- How to Scan iPhone for Virus? Is Antivirus it really required?
- JavaScript: Convert an Image into Base64 String - JavaScript
- [fix] Java JDBC ConnectException: Connection refused - Java
- Step by Step: Spring Boot + JPA + MySQL + Redis as Cache - Java
- Android : Error in http connection java.net.SocketException: Permission denied - Android
- Fix: Microsoft Excel Quit Unexpectedly on Mac - MacOS
- How to identify installed Java (JDK) Version on macOS - MacOS
- Cannot create new Microsoft Team using PowerShell, even as Admin - Teams
- Fix :wq! Vi Error - E32: No file name (when write and quit) - vi