pip install curlify
- Fixed shell quotes. Fixed posting CSV file. Thanks to @leNEKO
- Add
--insecure
flag ifverify
parameter is notTrue
- Fixed body rendering when using
json
param to request function.
- Added
compressed
parameter toto_curl
function, if it is needed to add--compressed
option to generated cURL command.
- Skip
-d
option if request body is empty #6 - Minor changes to header sorting
- Order of headers is deterministic (thanks to @tomviner)
import curlify
import requests
response = requests.get("https://google.ru")
print(curlify.to_curl(response.request))
# curl -X 'GET' -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Connection: keep-alive' -H 'User-Agent: python-requests/2.18.4' 'https://www.google.ru/'
print(curlify.to_curl(response.request, compressed=True))
# curl -X 'GET' -H 'Accept: */*' -H 'Accept-Encoding: gzip, deflate' -H 'Connection: keep-alive' -H 'User-Agent: python-requests/2.18.4' --compressed 'https://www.google.ru/'