Browse Source

In some odd cases HTTPResponse returns None instead of a file handle. Raise HTTPError when that happens.

main
Ionut Turturica 12 years ago
parent
commit
986c2df791
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      src/SOAPpy/Client.py

+ 6
- 2
src/SOAPpy/Client.py View File

@@ -280,13 +280,17 @@ class HTTPTransport:
except:
message_len = -1
f = r.getfile()
if f is None:
raise HTTPError(code, "Empty response from server\nCode: %s\nHeaders: %s" % (msg, headers))

if message_len < 0:
# Content-Length missing or invalid; just read the whole socket
# This won't work with HTTP/1.1 chunked encoding
data = r.getfile().read()
data = f.read()
message_len = len(data)
else:
data = r.getfile().read(message_len)
data = f.read(message_len)

if(config.debug):
print "code=",code


Loading…
Cancel
Save