Always use a ctypes array for recv_info(), for simplicity sake
@@ -51,12 +51,6 @@ except ImportError: # Platform-specific: Python 3
_fileobject = None
from ..packages.backports.makefile import backport_makefile
-try:
- memoryview(b'')
- has_memoryview = True
-except NameError:
- has_memoryview = False
-
__all__ = ['inject_into_urllib3', 'extract_from_urllib3']
# SNI always works
@@ -196,11 +190,6 @@ def _read_callback(connection_id, data_buffer, data_length_pointer):
timeout = wrapped_socket.gettimeout()
error = None
read_count = 0
- if has_memoryview:
- buffer = (ctypes.c_char * requested_length).from_address(data_buffer)
- buffer_view = memoryview(buffer)
- else:
- buffer_view = None
try:
while read_count < requested_length:
@@ -209,15 +198,7 @@ def _read_callback(connection_id, data_buffer, data_length_pointer):
if not readables:
raise socket.error(errno.EAGAIN, 'timed out')
- # We need to tell ctypes that we have a buffer that can be
- # written to. Upsettingly, we do that like this:
- if buffer_view is not None:
- chunk_size = base_socket.recv_into(
- buffer_view[read_count:requested_length]
- )
- else:
remaining = requested_length - read_count
- # This is likely innefficient, but works on Python 2.6
buffer = (ctypes.c_char * remaining).from_address(
data_buffer + read_count
)
