DEV Community

Cover image for Living in the Shell #16; curl (HTTP/S Client) (Part 1)
Babak K. Shandiz
Babak K. Shandiz

Posted on • Originally published at babakks.github.io on

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

curl 🌐

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

Make a simple GET request

curl https://google.com 
Enter fullscreen mode Exit fullscreen mode
<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 
Enter fullscreen mode Exit fullscreen mode

Write response to a file -o

curl -L https://google.com -o content.html 
Enter fullscreen mode Exit fullscreen mode

Include response headers -i

curl -i -L https://google.com 
Enter fullscreen mode Exit fullscreen mode
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 
Enter fullscreen mode Exit fullscreen mode

Request via a SOCKS proxy server --socks

curl -L https://google.com --socks proxy-server:port 
Enter fullscreen mode Exit fullscreen mode

Top comments (0)