Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return len(body)
except TypeError:
try:
return os.fstat(body.fileno()).st_size
except (AttributeError, OSError):
return None
class HTTPClient(object):
HTTP_11 = 'HTTP/1.1'
HTTP_10 = 'HTTP/1.0'
BLOCK_SIZE = 1024 * 4 # 4KB
DEFAULT_HEADERS = Headers({
'User-Agent': 'python/gevent-http-client-' + __version__
})
@classmethod
def from_url(cls, url, **kw):
if not isinstance(url, URL):
url = URL(url)
enable_ssl = url.scheme == PROTO_HTTPS
if not enable_ssl:
kw.pop('ssl_options', None)
return cls(url.host, port=url.port, ssl=enable_ssl, **kw)
def __init__(self, host, port=None, headers=None,
block_size=BLOCK_SIZE,
connection_timeout=ConnectionPool.DEFAULT_CONNECTION_TIMEOUT,
network_timeout=ConnectionPool.DEFAULT_NETWORK_TIMEOUT,
disable_ipv6=False,