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:
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>
Have Questions? Post them here!
- How to create a New Project in Visual Studio Code (VS Code)
- How to Whitelist IP Address on GoDaddy Hosting?
- CentOS Cannot find a valid baseurl for repo base7x86_64 yum
- Fix: This app is no longer shared with you error iPhone or iPad iOS
- How to check the version of NodeJS installed
- [Error] There was an error connecting to the apple id server
- Find Restroom Near Me - Closest Toilet Nearby Using Your Current Location
- How to install xz data compression software using Brew
- Steps to Delete or Deactivate Instagram Account
- How to enable line numbers in IntelliJ
- How to display line numbers in Terminal while displaying content of a file
- Unzip a Zip file from Terminal Command
- Install SonarLint on Visual Studio Code
- How to Scan iPhone for Virus? Is Antivirus it really required?
- 100+ SEO Tips to improve your website search ranking
- [fix] Editor could not be opened unexpected error: File is a directory (VS Code)
- How to Fix Spelling Errors on Microsoft Word for Mac
- How to convert byte array to String [Kotlin]
- [Fix] Error 1020 Cloudflare: Access was denied
- Command: How to scp a file to remote server location?
- What is an Authorization Code Grant? OAuth 2.0
- How to Connect to AWS Windows EC2 UI Instance from M1 Mac (Updated 2022)
- How to replace with space
- VS Code Remove Unused Imports Keyboard Shortcut
- How to rerun last command in Zsh shell
- Chessboard with pieces using pure HTML and CSS - Html
- Fix Apache Tomca: java.lang.OutOfMemoryError: PermGen spaceError - Tomcat
- How to undo last Git Commit on Local Repository? - Git
- The tag img may only appear as a descendant of tag noscript. Did you mean amp-img - AMP
- Rename git branch on Local and GitHub Remove using Command - Git
- Open New Terminal Window Using Keyboard Shortcut macOS - MacOS
- Docker MySQL Compose File with Volume Example - Docker
- Power BI error Something went wrong, unable to read the application metadata - Microsoft