conn.headers
is a httplib.HTTPMessage
, which is a subclass of rfc822.Message
and thus has a (limited) dict
-like interface. You can use the 2-argument call to get
to supply a default value.
contentLen = conn.headers.get('content-length','NULL')