|
22 | 22 | from urllib3.exceptions import ReadTimeoutError, ResponseError
|
23 | 23 | from urllib3.exceptions import SSLError as _SSLError
|
24 | 24 | from urllib3.poolmanager import PoolManager, proxy_from_url
|
25 |
| -from urllib3.response import HTTPResponse |
26 | 25 | from urllib3.util import Timeout as TimeoutSauce
|
27 | 26 | from urllib3.util import parse_url
|
28 | 27 | from urllib3.util.retry import Retry
|
@@ -485,63 +484,19 @@ def send(
|
485 | 484 | timeout = TimeoutSauce(connect=timeout, read=timeout)
|
486 | 485 |
|
487 | 486 | try:
|
488 |
| - if not chunked: |
489 |
| - resp = conn.urlopen( |
490 |
| - method=request.method, |
491 |
| - url=url, |
492 |
| - body=request.body, |
493 |
| - headers=request.headers, |
494 |
| - redirect=False, |
495 |
| - assert_same_host=False, |
496 |
| - preload_content=False, |
497 |
| - decode_content=False, |
498 |
| - retries=self.max_retries, |
499 |
| - timeout=timeout, |
500 |
| - ) |
501 |
| - |
502 |
| - # Send the request. |
503 |
| - else: |
504 |
| - if hasattr(conn, "proxy_pool"): |
505 |
| - conn = conn.proxy_pool |
506 |
| - |
507 |
| - low_conn = conn._get_conn(timeout=DEFAULT_POOL_TIMEOUT) |
508 |
| - |
509 |
| - try: |
510 |
| - skip_host = "Host" in request.headers |
511 |
| - low_conn.putrequest( |
512 |
| - request.method, |
513 |
| - url, |
514 |
| - skip_accept_encoding=True, |
515 |
| - skip_host=skip_host, |
516 |
| - ) |
517 |
| - |
518 |
| - for header, value in request.headers.items(): |
519 |
| - low_conn.putheader(header, value) |
520 |
| - |
521 |
| - low_conn.endheaders() |
522 |
| - |
523 |
| - for i in request.body: |
524 |
| - low_conn.send(hex(len(i))[2:].encode("utf-8")) |
525 |
| - low_conn.send(b"\r\n") |
526 |
| - low_conn.send(i) |
527 |
| - low_conn.send(b"\r\n") |
528 |
| - low_conn.send(b"0\r\n\r\n") |
529 |
| - |
530 |
| - # Receive the response from the server |
531 |
| - r = low_conn.getresponse() |
532 |
| - |
533 |
| - resp = HTTPResponse.from_httplib( |
534 |
| - r, |
535 |
| - pool=conn, |
536 |
| - connection=low_conn, |
537 |
| - preload_content=False, |
538 |
| - decode_content=False, |
539 |
| - ) |
540 |
| - except Exception: |
541 |
| - # If we hit any problems here, clean up the connection. |
542 |
| - # Then, raise so that we can handle the actual exception. |
543 |
| - low_conn.close() |
544 |
| - raise |
| 487 | + resp = conn.urlopen( |
| 488 | + method=request.method, |
| 489 | + url=url, |
| 490 | + body=request.body, |
| 491 | + headers=request.headers, |
| 492 | + redirect=False, |
| 493 | + assert_same_host=False, |
| 494 | + preload_content=False, |
| 495 | + decode_content=False, |
| 496 | + retries=self.max_retries, |
| 497 | + timeout=timeout, |
| 498 | + chunked=chunked, |
| 499 | + ) |
545 | 500 |
|
546 | 501 | except (ProtocolError, OSError) as err:
|
547 | 502 | raise ConnectionError(err, request=request)
|
|
0 commit comments