Skip to content
Myr

Use urllib for chunked requests

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Leon Verrall · committed by Leon Verrall · parent 4983a9b · Browse files · 1 file+13 added−58 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−58 removed

  • other:+13 added−58 removed

1 file+13 added−58 removed

modified:requests/adapters.py+13 added-58 removed
433 unmodified lines
434 else:435 timeout = TimeoutSauce(connect=timeout, read=timeout)436437 try:438 if not chunked:439 resp = conn.urlopen(440 method=request.method,441 url=url,442 body=request.body,443 headers=request.headers,444 redirect=False,445 assert_same_host=False,446 preload_content=False,447 decode_content=False,448 retries=self.max_retries,449 timeout=timeout450 )438 resp = conn.urlopen(439 method=request.method,440 url=url,441 body=request.body,442 headers=request.headers,443 redirect=False,444 assert_same_host=False,445 preload_content=False,446 decode_content=False,447 retries=self.max_retries,448 timeout=timeout,449 chunked=chunked450 )451452 # Send the request.453 else:454 if hasattr(conn, 'proxy_pool'):455 conn = conn.proxy_pool456457 low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT)458459 try:460 low_conn.putrequest(request.method,461 url,462 skip_accept_encoding=True)463464 for header, value in request.headers.items():465 low_conn.putheader(header, value)466467 low_conn.endheaders()468469 for i in request.body:470 low_conn.send(hex(len(i))[2:].encode('utf-8'))471 low_conn.send(b'\r\n')472 low_conn.send(i)473 low_conn.send(b'\r\n')474 low_conn.send(b'0\r\n\r\n')475476 # Receive the response from the server477 try:478 # For Python 2.7, use buffering of HTTP responses479 r = low_conn.getresponse(buffering=True)480 except TypeError:481 # For compatibility with Python 3.3+482 r = low_conn.getresponse()483484 resp = HTTPResponse.from_httplib(485 r,486 pool=conn,487 connection=low_conn,488 preload_content=False,489 decode_content=False490 )491 except:492 # If we hit any problems here, clean up the connection.493 # Then, reraise so that we can handle the actual exception.494 low_conn.close()495 raise496452 except (ProtocolError, socket.error) as err:453 raise ConnectionError(err, request=request)454455 except MaxRetryError as e:
33 unmodified lines