Created
August 30, 2021 01:11
-
-
Save abiydv/c09de26f706ab68670885bd2d3d2d959 to your computer and use it in GitHub Desktop.
Curl Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -F "firstname=John" -F"lastname=Doe" "https://httpbin.org/post" -F"file=@file.txt" | |
{ | |
"args": {}, | |
"data": "", | |
"files": { | |
"file": "This is a test file\n" | |
}, | |
"form": { | |
"firstname": "John", | |
"lastname": "Doe" | |
}, | |
"headers": { | |
"Accept": "*/*", | |
"Content-Length": "408", | |
"Content-Type": "multipart/form-data; boundary=------------------------afd9220cdc8dae3d", | |
"Host": "httpbin.org", | |
"User-Agent": "curl", | |
"X-Amzn-Trace-Id": "Root=1-60ec24b5-1cdf63422773e29d6c0b653f" | |
}, | |
"json": null, | |
"url": "https://httpbin.org/post" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -F "firstname=John" -F "lastname=Doe" "https://httpbin.org/post" | |
{ | |
"args": {}, | |
"data": "", | |
"files": {}, | |
"form": { | |
"firstname": "John", | |
"lastname": "Doe" | |
}, | |
"headers": { | |
"Accept": "*/*", | |
"Content-Length": "248", | |
"Content-Type": "multipart/form-data; boundary=------------------------e41227aceee312a6", | |
"Host": "httpbin.org", | |
"User-Agent": "curl", | |
"X-Amzn-Trace-Id": "Root=1-60ec23d7-3a82be0162af35456010c778" | |
}, | |
"json": null, | |
"url": "https://httpbin.org/post" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl "https://httpbin.org/post" -d "firstname=John&lastname=Doe" | |
{ | |
"args": {}, | |
"data": "", | |
"files": {}, | |
"form": { | |
"firstname": "John", | |
"lastname": "Doe" | |
}, | |
"headers": { | |
"Accept": "*/*", | |
"Content-Length": "27", | |
"Content-Type": "application/x-www-form-urlencoded", | |
"Host": "httpbin.org", | |
"User-Agent": "curl", | |
"X-Amzn-Trace-Id": "Root=1-60ec27f5-4d461f2d3bbf20ed16291ed3" | |
}, | |
"json": null, | |
"url": "https://httpbin.org/post" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl https://httpbin.org/headers -H "CustomHeader1: value1" -H "CustomHeader2: value2" | |
{ | |
"headers": { | |
"Accept": "*/*", | |
"Customheader1": "value1", | |
"Customheader2": "value2", | |
"Host": "httpbin.org", | |
"User-Agent": "curl/7.73.0", | |
"X-Amzn-Trace-Id": "Root=1-5fadb190-26af70e1691093c76d180401" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -v https://httpbin.org/ip -s -o /dev/null | grep ">" | |
* Trying 3.211.1.78:443... | |
* Connected to httpbin.org (3.211.1.78) port 443 (#0) | |
* Using HTTP2, server supports multi-use | |
* Connection state changed (HTTP/2 confirmed) | |
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 | |
} [5 bytes data] | |
* Using Stream ID: 1 (easy handle 0x1da3b7de150) | |
} [5 bytes data] | |
> GET /ip HTTP/2 | |
> Host: httpbin.org | |
> user-agent: curl/7.73.0 | |
> accept: */* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -D - https://httpbin.org/ip -s -o /dev/null | |
HTTP/2 200 | |
date: Thu, 12 Nov 2019 19:10:39 GMT | |
content-type: application/json | |
content-length: 32 | |
server: gunicorn/19.9.0 | |
access-control-allow-origin: * | |
access-control-allow-credentials: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -I https://httpbin.org/ip | |
HTTP/2 200 | |
date: Thu, 12 Nov 2019 19:08:13 GMT | |
content-type: application/json | |
content-length: 32 | |
server: gunicorn/19.9.0 | |
access-control-allow-origin: * | |
access-control-allow-credentials: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while read url; do curl $url -w " %{response_code} | $url --> %{redirect_url} \n" -s -o /dev/null; done < urls.txt | |
301 | https://httpbin.org/status/301 --> https://httpbin.org/redirect/1 | |
302 | https://httpbin.org/status/302 --> https://httpbin.org/redirect/1 | |
307 | https://httpbin.org/status/307 --> https://httpbin.org/redirect/1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl https://httpbin.org/status/302 -w "%{response_code} %{redirect_url}" -s -o /dev/null | |
302 https://httpbin.org/redirect/1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl https://httpbin.org/headers -A "bob-the-builder" | |
{ | |
"headers": { | |
"Accept": "*/*", | |
"Host": "httpbin.org", | |
"User-Agent": "bob-the-builder", | |
"X-Amzn-Trace-Id": "Root=1-5fadb05b-490211b54febef30592912b5" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment