Created
March 27, 2020 02:50
-
-
Save QuynhVir/baf0e526aa708fabb1c162daf52d7055 to your computer and use it in GitHub Desktop.
Gzip requests
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
import zlib | |
import requests | |
headers = { | |
"accept-encoding" : "gzip", | |
"content-type" : "gzip", | |
} | |
post_data = "This is expected to be sent back as part of response body." | |
request_body = zlib.compress(post_data.encode("UTF-8")) | |
resp = requests.post("https://postman-echo.com/post", data=request_body, headers=headers) | |
print (resp.status_code) | |
print (resp.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment