Skip to content

Commit de7eb0e

Browse files
jnikulacrobinso
authored andcommitted
Fix bugzilla detection behind proxy
Python requests handles proxying, use it also during bugzilla detection phase. Don't bother with cookies at this point.
1 parent 211dc02 commit de7eb0e

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

bugzilla/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
from bugzilla.base import BugzillaBase as _BugzillaBase
2828
from bugzilla.base import BugzillaError
29+
from bugzilla.base import RequestsTransport
2930
from bugzilla.bugzilla3 import Bugzilla3, Bugzilla32, Bugzilla34, Bugzilla36
3031
from bugzilla.bugzilla4 import Bugzilla4, Bugzilla42, Bugzilla44
3132
from bugzilla.rhbugzilla import RHBugzilla, RHBugzilla3, RHBugzilla4
@@ -39,7 +40,7 @@ class NovellBugzilla(Bugzilla34):
3940
def getBugzillaClassForURL(url):
4041
url = Bugzilla3.fix_url(url)
4142
log.debug("Detecting subclass for %s", url)
42-
s = ServerProxy(url)
43+
s = ServerProxy(url, RequestsTransport(url))
4344
rhbz = False
4445
bzversion = ''
4546
c = None

bugzilla/base.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _build_cookiejar(cookiefile):
108108
class RequestsTransport(Transport):
109109
user_agent = 'Python/Bugzilla'
110110

111-
def __init__(self, url, cookiejar,
111+
def __init__(self, url, cookiejar=None,
112112
sslverify=True, sslcafile=None, debug=0):
113113
# pylint: disable=W0231
114114
# pylint does not handle multiple import of Transport well
@@ -128,7 +128,7 @@ def __init__(self, url, cookiejar,
128128

129129
self.request_defaults = {
130130
'cert': sslcafile if self.use_https else None,
131-
'cookies': cookiejar,
131+
'cookies': cookiejar if cookiejar else None,
132132
'verify': sslverify,
133133
'headers': {
134134
'Content-Type': 'text/xml',
@@ -157,12 +157,13 @@ def _request_helper(self, url, request_body):
157157
response.encoding = 'UTF-8'
158158

159159
# update/set any cookies
160-
for cookie in response.cookies:
161-
self._cookiejar.set_cookie(cookie)
160+
if self._cookiejar is not None:
161+
for cookie in response.cookies:
162+
self._cookiejar.set_cookie(cookie)
162163

163-
if self._cookiejar.filename is not None:
164-
# Save is required only if we have a filename
165-
self._cookiejar.save()
164+
if self._cookiejar.filename is not None:
165+
# Save is required only if we have a filename
166+
self._cookiejar.save()
166167

167168
response.raise_for_status()
168169
return self.parse_response(response)

0 commit comments

Comments
 (0)