1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-03 18:16:17 +01:00

- fixed "osc -H ..." in combination with a proxy

This commit is contained in:
Marcus Huewe 2014-03-11 19:40:27 +01:00
parent 9034b27814
commit 8c506e5929

View File

@ -531,12 +531,20 @@ def init_basicauth(config):
# this is so ugly but httplib doesn't use
# a logger object or such
def new_method(self, *args, **kwargs):
self._orig_stdout = sys.stdout
sys.stdout = StringIO()
meth(self, *args, **kwargs)
hdr = sys.stdout.getvalue()
sys.stdout = self._orig_stdout
del self._orig_stdout
# check if this is a recursive call (note: we do not
# have to care about thread safety)
is_rec_call = getattr(self, '_orig_stdout', None) is not None
try:
if not is_rec_call:
self._orig_stdout = sys.stdout
sys.stdout = StringIO()
meth(self, *args, **kwargs)
hdr = sys.stdout.getvalue()
finally:
# restore original stdout
if not is_rec_call:
sys.stdout = self._orig_stdout
del self._orig_stdout
for i in hdrs:
if ishdr:
hdr = re.sub(r'%s:[^\\r]*\\r\\n' % i, '', hdr)