If you only want to fetch the content-type for a response, make use of the --write-out option and the variable content_type
Example:% curl -s -o /dev/null -w "%{content_type}\n" http://example.org
Output:
text/html; charset=UTF-8

You may also make use of the -I option along with grep,
% curl -I http://example.org
HTTP/1.1 200 OK
Content-Encoding: gzip
Accept-Ranges: bytes
Age: 584814
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Mon, 12 Dec 2022 11:33:10 GMT
Etag: "3147526947"
Expires: Mon, 19 Dec 2022 11:33:10 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Server: ECS (dcb/7F60)
X-Cache: HIT
Content-Length: 648
Example:
% curl -Is http://example.org | grep -iF 'Content-Type'
Output:
Content-Type: text/html; charset=UTF-8
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!