HTTPIE CURL and WGET

by Anish


Posted on Tuesday October 1st 2019


Referefce 8gwifi.org

Utilities are essentials for working with HTTP methods many such utilities exist which eases our daily Job. In this tutorial we will go to some of the practical use-case of handling HTTP methods which can be used in our daily life to increase our productivity and cover the below utilities

  • httpie: Client-side implementation of the HTTP/1.1 protocol
  • curl: transfer a URL
  • wget : The non-interactive network downloader

For Docker user can pull the Image

docker pull anishnath/httpclient

Fetch the headers only

  • http
# http 8gwifi.org
HTTP/1.1 301 Moved Permanently
CF-RAY: 51ec3d603adbce2b-LHR
.......
.......
Vary: Accept-Encoding
  • curl
# curl -I 8gwifi.org
/httpclient # curl -I 8gwifi.org
HTTP/1.1 301 Moved Permanently
........
........
Connection: keep-alive

HTTP Methods

POST

HTTP POST With content-type: application/x-www-form-urlencoded

curl -X POST \
  https://8gwifi.org/crypto/rest/encryptdecrypt/encrypt \
  -H 'content-type: application/x-www-form-urlencoded' \
  -d 'p_msg=Hello%208gwifi.org&p_secretkey=a23c6e1a4aa987e766ecad497f2f4166fb4117b64adfb8bc&p_cipher=AES_128%2FCFB%2FNOPADDING'
http --form POST https://8gwifi.org/crypto/rest/encryptdecrypt/encrypt \
  content-type:application/x-www-form-urlencoded \
  p_msg='Hello 8gwifi.org' \
  p_secretkey=a23c6e1a4aa987e766ecad497f2f4166fb4117b64adfb8bc \
  p_cipher=AES_128/CFB/NOPADDING
wget --quiet \
  --method POST \
  --header 'content-type: application/x-www-form-urlencoded' \
  --body-data 'p_msg=Hello%208gwifi.org&p_secretkey=a23c6e1a4aa987e766ecad497f2f4166fb4117b64adfb8bc&p_cipher=AES_128%2FCFB%2FNOPADDING' \
  --output-document \
  - https://8gwifi.org/crypto/rest/encryptdecrypt/encrypt

HTTP POST with multipart/form-data

  • curl
curl --request POST \
  --url https://0cloud0.com/ \
  --header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  --form hello=21
  • http
echo '------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="hello"

21
------WebKitFormBoundary7MA4YWxkTrZu0gW--' |  \
  http POST https://8gwifi.org/crypto/rest/encryptdecrypt/encrypt \
  content-type:'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW'
  • wget
wget --quiet \
  --method POST \
  --header 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  --body-data '------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name="hello"\r\n\r\n21\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--' \
  --output-document \
  - https://0cloud0.com/ 

HTTP POST with application/json

  • http
echo '{
  "id": 1,
  "name": "JSON DEMO"
}' |  \
  http POST https://example.com \
  content-type:application/json
  • curl
curl --request POST \
  --url https://example.com \
  --header 'content-type: application/json' \
  --data '{\n  "id": 1,\n  "name": "JSON DEMO"\n}'
  • wget
wget --quiet \
  --method POST \
  --header 'content-type: application/json' \
  --body-data '{\n  "id": 1,\n  "name": "JSON DEMO"\n}' \
  --output-document \
  - https://example.com

HTTP POST with application/xml

  • wget
wget --quiet \
  --method POST \
  --header 'content-type: application/xml' \
  --body-data '<xml>\n  <heading>XML Demo</heading>\n</xml>' \
  --output-document \
  - https://example.com
  • http
  echo '<xml>
  <heading>XML Demo</heading>
</xml>' |  \
  http POST https://example.com \
  content-type:application/xml 
  • curl
 curl --request POST \
  --url https://example.com \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/xml' \
  --data '<xml>\n  <heading>XML Demo</heading>\n</xml>'

PATCH

A HTTP patch operation with required headers

  • http
http PATCH https://api.cloudflare.com/client/v4 \
  x-auth-email:[email protected] \
  x-auth-key:1b2c4be9f9432d53e0cfbc61439de679
  • curl
curl --request PATCH \
  --url https://api.cloudflare.com/client/v4 \
  --header 'x-auth-email: [email protected]' \
  --header 'x-auth-key: 1b2c4be9f9432d53e0cfbc61439de679'
  • wget
wget --quiet \
  --method PATCH \
  --header 'x-auth-email: email_id' \
  --header 'x-auth-key: 1b2c4be9f9432d53e0cfbc61439de679' \
  --output-document \
  - https://api.cloudflare.com/client/v4

Authentication

  • Basic auth
http -a username:password http://8gwifi.org

curl

curl -u username:password http://8gwifi.org
curl --header "Authorization: Basic $AUTH" http://8gwifi.org

wget

wget  \
  --method GET \
  --header 'authorization: Basic YW5pc2g6YW5pc2g=' \
  - https://0cloud0.com/
  • Authorization Bearer
curl --header "Authorization: Bearer $TOKEN" http://8gwifi.org
  • Digest auth
http -A digest -a username:password https://0cloud0.com
curl --digest --user username:password https://0cloud0.com
  • NTLM
curl --ntlm --user username:password https://0cloud0.com
  • Negotiate
curl --negotiate --user username:password https://0cloud0.com
  • Password prompt
    http -a username https://0cloud0.com

TLS Handling

Allow Insecure connection

curl  -k https://example.com

Client certificate Validation

curl  -E  wk.cert  https://example.com

Use Specfic TLS version to Connect

# curl  -I --tlsv1.3 https://msn.com
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to msn.com:443 
# curl  -I --tlsv1.2 https://msn.com
HTTP/1.1 301 Moved Permanently
Content-Length: 143
Content-Type: text/html; charset=UTF-8
Location: https://www.msn.com/
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Tue, 01 Oct 2019 10:39:40 GMT
http --ssl tls1.2  https://msn.com

Download File

  • http
# http --download  https://8gwifi.org/docs/img/6book.png

Downloading 167.86 kB to "6book.png"
Done. 167.86 kB in 0.39169s (428.57 kB/s)
  • curl
# curl https://8gwifi.org/docs/img/6book.png --output myfile.png
% Total  % Received % Xferd  Average Speed Time  Time Time  Current
Dload  Upload Total Spent  Left  Speed
100  167k  100  167k  0 0 168k  0 --:--:-- --:--:-- --:--:--  167k
  • wget
wget https://8gwifi.org/docs/img/6book.png

Silent Download

curl https://8gwifi.org/docs/img/6book.png --output myfile.png -s

Follow 30x Location redirects

  • curl
# curl -L -I http://8gwifi.org

HTTP/1.1 301 Moved Permanently
........
........
Connection: keep-alive

HTTP/2 200 
............
.............
cf-ray: 51ed29d20f79bb94-LHR

If you have any more Idea Please paste on comments I will add this on the List with your Name

Next Reading : How to Monitoring All Executed Commands in Linux



Thanku for reading !!! Give a Share for Support


Your Support Matters!

Instead of directly asking for donations, I'm thrilled to offer you all nine of my books for just $9 on leanpub By grabbing this bundle you not only help cover my coffee, beer, and Amazon bills but also play a crucial role in advancing and refining this project. Your contribution is indispensable, and I'm genuinely grateful for your involvement in this journey!

Any private key value that you enter or we generate is not stored on this site, this tool is provided via an HTTPS URL to ensure that private keys cannot be stolen, for extra security run this software on your network, no cloud dependency



python Cryptography Topics
Topics
For Coffee/ Beer/ Amazon Bill and further development of the project Support by Purchasing, The Modern Cryptography CookBook for Just $9 Coupon Price

Kubernetes for DevOps

Hello Dockerfile

Cryptography for Python Developers

Cryptography for JavaScript Developers

Go lang ryptography for Developers