1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-12 23:56:13 +01:00

add a temporary debug path to http_debug() for bug 369176 (empty responses from api.opensuse.org)

This commit is contained in:
Dr. Peter Poeml 2008-03-11 16:39:47 +00:00
parent 3f244d4b23
commit dad51ee405

View File

@ -1271,6 +1271,42 @@ def http_request(method, url, data=None, file=None):
conf.cookiejar.save(ignore_discard=True)
if filefd: filefd.close()
# this code is for debugging empty responses from api.opensuse.org
# https://bugzilla.novell.com/show_bug.cgi?id=369176
# Buildservice server sometimes sends broken replies
# only prjconf requests (_config) can have empty replies (we hope)
if fd.headers['Content-Length'] == '0' and not fd.url.endswith('/_config'):
print 'DEBUG INFO'
print
import time; print time.ctime()
print url
print
print 'Request Headers:'
for i in req.header_items():
print i
print
print 'Reply:'
try:
print fd.code, fd.msg
except:
print 'could not print fd.code, fd.msg'
try:
print fd.url
except:
print 'could not print fd.url'
try:
print fd.headers
except:
print 'could not print fd.headers'
print
print 'An empty reply was received. This is a bug...'
print 'Please go to https://bugzilla.novell.com/show_bug.cgi?id=369176 and add the above info.'
print 'Thanks!'
print
sys.exit(1)
return fd
@ -1280,6 +1316,7 @@ def http_PUT(*args, **kwargs): return http_request('PUT', *args, **kwargs)
def http_DELETE(*args, **kwargs): return http_request('DELETE', *args, **kwargs)
# obsolete!
def urlopen(url, data=None):
"""wrapper around urllib2.urlopen for error handling"""