Skip to content

Instantly share code, notes, and snippets.

@QuynhVir
Created March 27, 2020 02:50
Show Gist options
  • Save QuynhVir/baf0e526aa708fabb1c162daf52d7055 to your computer and use it in GitHub Desktop.
Save QuynhVir/baf0e526aa708fabb1c162daf52d7055 to your computer and use it in GitHub Desktop.
Gzip requests
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