Skip to content
Myr

Merge pull request #1669 from Lukasa/chunked

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

[WIP] Better chunked handling.

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 2dae61c, 9606f02 · Browse files · 1 file+30 added−17 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+30 added−17 removed

  • other:+30 added−17 removed

1 file+30 added−17 removed

modified:requests/adapters.py+30 added-17 removed
328 unmodified lines
329 if hasattr(conn, 'proxy_pool'):330 conn = conn.proxy_pool331332 low_conn = conn._get_conn(timeout=timeout)333 low_conn.putrequest(request.method, url, skip_accept_encoding=True)333335 for header, value in request.headers.items():336 low_conn.putheader(header, value)334 try:335 low_conn.putrequest(request.method,336 url,337 skip_accept_encoding=True)338338 low_conn.endheaders()339 for header, value in request.headers.items():340 low_conn.putheader(header, value)341340 for i in request.body:341 low_conn.send(hex(len(i))[2:].encode('utf-8'))342 low_conn.send(b'\r\n')343 low_conn.send(i)344 low_conn.send(b'\r\n')345 low_conn.send(b'0\r\n\r\n')342 low_conn.endheaders()343347 r = low_conn.getresponse()348 resp = HTTPResponse.from_httplib(r,349 pool=conn,350 connection=low_conn,351 preload_content=False,352 decode_content=False353 )344 for i in request.body:345 low_conn.send(hex(len(i))[2:].encode('utf-8'))346 low_conn.send(b'\r\n')347 low_conn.send(i)348 low_conn.send(b'\r\n')349 low_conn.send(b'0\r\n\r\n')350351 r = low_conn.getresponse()352 resp = HTTPResponse.from_httplib(353 r,354 pool=conn,355 connection=low_conn,356 preload_content=False,357 decode_content=False358 )359 except:360 # If we hit any problems here, clean up the connection.361 # Then, reraise so that we can handle the actual exception.362 low_conn.close()363 raise364 else:365 # All is well, return the connection to the pool.366 conn._put_conn(low_conn)367368 except socket.error as sockerr:369 raise ConnectionError(sockerr)370371 except MaxRetryError as e:
19 unmodified lines