def ReceiveRaw(self, **kw):
'''Read a server reply, unconverted to any format and return it.
'''
if self.local.data: return self.local.data
trace = self.trace
while 1:
response = self.local.h.getresponse()
reply_code, reply_msg, self.local.reply_headers, self.local.data = \
response.status, response.reason, response.msg, response.read()
if trace:
print >>trace, "_" * 33, time.ctime(time.time()), "RESPONSE:"
for i in (reply_code, reply_msg,):
print >>trace, str(i)
print >>trace, "-------"
print >>trace, str(self.local.reply_headers)
print >>trace, self.local.data
saved = None
for d in response.msg.getallmatchingheaders('set-cookie'):
if d[0] in [ ' ', '\t' ]:
saved += d.strip()
else:
if saved: self.cookies.load(saved)
saved = d.strip()
if saved: self.cookies.load(saved)
if response.status == 401:
if not callable(self.http_callbacks.get(response.status,None)):
raise RuntimeError('HTTP Digest Authorization Failed')
self.http_callbacks[response.status](response)
continue
if response.status != 100: break
# The httplib doesn't understand the HTTP continuation header.
# Horrible internals hack to patch things up.
self.local.h._HTTPConnection__state = httplib._CS_REQ_SENT
self.local.h._HTTPConnection__response = None
return self.local.data