Skip to content

Instantly share code, notes, and snippets.

@paveldedik
Created June 8, 2018 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paveldedik/8a02a3ee0c1578f2eea7ef526bd4104a to your computer and use it in GitHub Desktop.
Save paveldedik/8a02a3ee0c1578f2eea7ef526bd4104a to your computer and use it in GitHub Desktop.
Minimal example to raise bad write entry error with urllib3 and certifi.
import certifi
import urllib3.contrib.pyopenssl
from urllib3.connectionpool import connection_from_url
urllib3.contrib.pyopenssl.inject_into_urllib3()
conn = connection_from_url('https://httpbin.org/post', cert_reqs='CERT_REQUIRED', ca_certs=certifi.where())
conn.urlopen(
method='POST',
url='https://httpbin.org/post',
body=u'c'*401000,
headers={'User-Agent': 'python-requests/2.18.4',
'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*',
'Connection': 'keep-alive', 'Content-Length': '401000'},
redirect=False,
assert_same_host=False,
preload_content=False,
decode_content=False,
retries=1,
timeout=30, # timeout causes bad write entry error
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment