Skip to content

Commit

Permalink
Managed older pycurl version bug with unicode
Browse files Browse the repository at this point in the history
See pycurl/pycurl#124 for details.
  • Loading branch information
geektophe committed Jul 25, 2022
1 parent 820ebac commit 7b3dfbe
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 116 deletions.
20 changes: 17 additions & 3 deletions shinken/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,29 @@ def __create_con(self, proxy, strong_ssl):
con.setopt(con.VERBOSE, 0)
# Remove the Expect: 100-Continue default behavior of pycurl, because swsgiref do not
# manage it
con.setopt(pycurl.HTTPHEADER, ['Expect:', 'Keep-Alive: 300', 'Connection: Keep-Alive'])
con.setopt(pycurl.USERAGENT, 'shinken:%s pycurl:%s' % (VERSION, PYCURL_VERSION))
headers = ['Expect:', 'Keep-Alive: 300', 'Connection: Keep-Alive']
user_agent = 'shinken:%s pycurl:%s' % (VERSION, PYCURL_VERSION)
# Manages bug described in https://github.com/pycurl/pycurl/issues/124
try:
con.setopt(pycurl.HTTPHEADER, headers)
con.setopt(pycurl.USERAGENT, user_agent)
except TypeError:
headers = [h.encode("utf-8") for h in headers]
user_agent = user_agent.encode("utf-8")
con.setopt(pycurl.HTTPHEADER, headers)
con.setopt(pycurl.USERAGENT, user_agent)
con.setopt(pycurl.FOLLOWLOCATION, 1)
con.setopt(pycurl.FAILONERROR, True)
con.setopt(pycurl.CONNECTTIMEOUT, self.timeout)
con.setopt(pycurl.HTTP_VERSION, pycurl.CURL_HTTP_VERSION_1_1)

if proxy:
con.setopt(pycurl.PROXY, proxy)
# Manages bug described in https://github.com/pycurl/pycurl/issues/124
try:
con.setopt(pycurl.PROXY, proxy)
except TypeError:
proxy = proxy.encode("utf-8")
con.setopt(pycurl.PROXY, proxy)

# Also set the SSL options to do not look at the certificates too much
# unless the admin asked for it
Expand Down
37 changes: 0 additions & 37 deletions test/docker-files/docker-file-DEBIAN-installation-debian6-pip.txt

This file was deleted.

24 changes: 0 additions & 24 deletions test/docker-files/docker-file-DEBIAN-installation-debian7-pip.txt

This file was deleted.

20 changes: 0 additions & 20 deletions test/docker-files/docker-file-DEBIAN-installation-debian8-pip.txt

This file was deleted.

19 changes: 0 additions & 19 deletions test/docker-files/docker-file-DEBIAN-installation-debian9-pip.txt

This file was deleted.

13 changes: 0 additions & 13 deletions test/docker-files/docker-file-PYTHON-python2-debian9.txt

This file was deleted.

0 comments on commit 7b3dfbe

Please sign in to comment.