If you want to know what is the size of an HTTP/HTTPS request response-payload, you need to look at the content-length header from the response headers.
Example:% curl -sI "https://code.jquery.com/jquery-3.5.0.min.js"
HTTP/2 200
date: Wed, 30 Nov 2022 12:02:51 GMT
content-length: 89493
content-type: application/javascript; charset=utf-8
last-modified: Fri, 20 Aug 2021 17:47:53 GMT
accept-ranges: bytes
server: nginx
etag: W/"611feac9-15d95"
cache-control: max-age=315360000
cache-control: public
access-control-allow-origin: *
vary: Accept-Encoding
x-hw: 1669809771.dop244.fr8.t,1669809771.cds237.fr8.hn,1669809771.cds139.fr8.c
You can pipe it with grep command to just get the size of the response in bytes.
Exmple:% curl -sI "https://code.jquery.com/jquery-3.5.0.min.js" | grep content-length
content-length: 89493
Note: The way Content-Lenght is displayed in the HTTP response may differ in upper-lowercase, so it's better to make use of case-insensitivity options with grep.
% curl -sI "https://code.jquery.com/jquery-3.5.0.min.js" | grep -iF 'content-length'
content-length: 89493
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
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
More Posts related to cURL,
- cURL Option to show HTTP Response Status Code
- URL Encode cURL HTTP GET\POST Data with Examples
- Capture cURL Request Output to a File
- Fix: Curl No Match Found Error
- trurl: A new command-line tool for URL parsing and manipulation by cURL Developer
- Send JSON Data as Payload using cURL HTTP POST Request
- cURL: Show Request and Response Headers
- Get cURL command from Chrome Inspect Network HTTP URL
- Save cURL Command Output to a external file
- cURL DELETE Request with Examples
- How to URL Encode Data for a cURL Request Parameters
- cURL Example using IP (IPv4 and IPv6) address and Port
- How to convert a Postman request to cURL Command
- [fix] command not found curl
- How to Pretty Print cURL JSON Output in Terminal
- How to follow redirects in cURL Command Request
- How to pass authorization header using cURL
- cURL -x Use of HTTP Proxy Server Examples
- Downloading Google Chrome using cURL Command
- How to get cURL Command to run in verbose mode?
- List of 28 Protocols supported by cURL with Examples
- Hide cURL Outputs and Errors on Terminal
- cURL -d Option with Examples
- How to show SSL Certificate details using cURL Command
- Perform Basic Authentication using cURL with Examples
More Posts:
- Mac Terminal Find Command History - MacOS
- Install Native Java JDK JRE on Apple Silicon M1 Mac - MacOS
- How to Open PowerShell on Mac? - Powershell
- SharePoint error - Your organization doesn't allow sharing with users from this domain. Please contact your IT department for help. (OSE403) - SharePoint
- [Mac] Find a file using filename in macOS Terminal - MacOS
- Copy file from one directory to other in Php - PHP
- Mac turn dark mode on or off using terminal command - MacOS
- Fix: Amazon Linux bash: sudo: command not found - AWS