@@ -61,20 +61,21 @@ def __init__(self, response):
61
61
def read (self , size = - 1 ):
62
62
"""Read as much as available or up to size and return it in a byte string.
63
63
64
- Do NOT use this unless you really need to. Reusing memory with `readinto` is much better.
65
- """
64
+ Do NOT use this unless you really need to. Reusing memory with `readinto` is much better.
65
+ """
66
66
if size == - 1 :
67
67
return self ._response .content
68
68
return self ._response .socket .recv (size )
69
69
70
70
def readinto (self , buf ):
71
71
"""Read as much as available into buf or until it is full. Returns the number of bytes read
72
- into buf."""
73
- return self ._response ._readinto (buf ) # pylint: disable=protected-access
72
+ into buf."""
73
+ return self ._response ._readinto (buf ) # pylint: disable=protected-access
74
74
75
75
76
76
class Response :
77
77
"""The response from a request, contains all the headers/content"""
78
+
78
79
# pylint: disable=too-many-instance-attributes
79
80
80
81
encoding = None
@@ -242,7 +243,7 @@ def close(self):
242
243
self ._throw_away (chunk_size + 2 )
243
244
self ._parse_headers ()
244
245
if self ._session :
245
- self ._session ._free_socket (self .socket ) # pylint: disable=protected-access
246
+ self ._session ._free_socket (self .socket ) # pylint: disable=protected-access
246
247
else :
247
248
self .socket .close ()
248
249
self .socket = None
@@ -344,6 +345,7 @@ def iter_content(self, chunk_size=1, decode_unicode=False):
344
345
345
346
class Session :
346
347
"""HTTP session that shares sockets and ssl context."""
348
+
347
349
def __init__ (self , socket_pool , ssl_context = None ):
348
350
self ._socket_pool = socket_pool
349
351
self ._ssl_context = ssl_context
@@ -521,7 +523,7 @@ def delete(self, url, **kw):
521
523
522
524
# Backwards compatible API:
523
525
524
- _default_session = None # pylint: disable=invalid-name
526
+ _default_session = None # pylint: disable=invalid-name
525
527
526
528
527
529
class _FakeSSLContext :
@@ -534,7 +536,7 @@ def wrap_socket(socket, server_hostname=None):
534
536
535
537
def set_socket (sock , iface = None ):
536
538
"""Legacy API for setting the socket and network interface. Use a `Session` instead."""
537
- global _default_session # pylint: disable=global-statement,invalid-name
539
+ global _default_session # pylint: disable=global-statement,invalid-name
538
540
_default_session = Session (sock , _FakeSSLContext ())
539
541
if iface :
540
542
sock .set_interface (iface )
0 commit comments