Babak K. Shandiz
Babak K. Shandiz's Blog

Babak K. Shandiz's Blog

Living in the Shell #16; curl (HTTP/S Client) (Part 1)

Living in the Shell #16; curl (HTTP/S Client) (Part 1)

Babak K. Shandiz's photo
Babak K. Shandiz
ยทDec 15, 2021ยท

1 min read

curl ๐ŸŒ

Makes requests in various protocols, including (but not limited to) HTTP/HTTPS/FTP/FTPS.

Make a simple GET request

curl https://google.com
<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="https://www.google.com/">here</A>.
</BODY></HTML>

Simple GET request with following redirects -L

curl -L https://google.com

Write response to a file -o

curl -L https://google.com -o content.html

Include response headers -i

curl -i -L https://google.com
HTTP/2 301 
location: https://www.google.com/
content-type: text/html; charset=UTF-8
date: Wed, 15 Dec 2021 17:45:16 GMT
expires: Fri, 14 Jan 2022 17:45:16 GMT
cache-control: public, max-age=2592000
server: gws
content-length: 220
x-xss-protection: 0
x-frame-options: SAMEORIGIN
...

Request via a HTTP proxy server -x

curl -L https://google.com -x proxy-server:port

Request via a SOCKS proxy server --socks

curl -L https://google.com --socks proxy-server:port
ย 
Share this