Repository: encode/httpx

Issue:
SSL handshake failed on verifying the certificate
**im using charlesproxy for debugging each requests. Proxy ip and cert is from charlesproxy**

My code:
```
import httpx
client = httpx.Client(proxies={
    "http": "http://192.168.1.78:8888",
    "https": "http://192.168.1.78:8888",

})


client_cer = r'C:\Users\localhost\Documents\123.pem'
request = client.get("http://whoer.net",verify=client_cer)


```
output
```

SSL handshake failed on verifying the certificate
protocol: <asyncio.sslproto.SSLProtocol object at 0x0000020CDCD7E470>
transport: <_SelectorSocketTransport fd=768 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 625, in _on_handshake_complete
    raise handshake_exc
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 189, in feed_ssldata
    self._sslobj.do_handshake()
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 763, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)
SSL error in data received
protocol: <asyncio.sslproto.SSLProtocol object at 0x0000020CDCD7E470>
transport: <_SelectorSocketTransport closing fd=768 read=idle write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 526, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 189, in feed_ssldata
    self._sslobj.do_handshake()
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 763, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)
Traceback (most recent call last):
  File "C:/Users/localhost/PycharmProjects/TribalW_Test_Env/Basic/tests/httpx/proxy_test.py", line 11, in <module>
    request = client.get("http://whoer.net",headers=headers,verify=client_cer)
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\client.py", line 818, in get
    proxies=proxies,
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\client.py", line 729, in request
    proxies=proxies,
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\client.py", line 760, in send
    async_response = concurrency_backend.run(coroutine, *args, **kwargs)
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\concurrency\asyncio.py", line 241, in run
    return self.loop.run_until_complete(coroutine(*args, **kwargs))
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 584, in run_until_complete
    return future.result()
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\client.py", line 230, in _get_response
    return await get_response(request)
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\middleware\redirect.py", line 41, in __call__
    return await self(next_request, get_response)
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\middleware\redirect.py", line 31, in __call__
    response = await get_response(request)
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\client.py", line 191, in get_response
    request, verify=verify, cert=cert, timeout=timeout
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\dispatch\proxy_http.py", line 243, in send
    request=request, verify=verify, cert=cert, timeout=timeout
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\dispatch\connection_pool.py", line 118, in send
    connection = await self.acquire_connection(origin=request.url.origin)
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\dispatch\proxy_http.py", line 92, in acquire_connection
    return await self.tunnel_connection(origin)
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\dispatch\proxy_http.py", line 110, in tunnel_connection
    await self.tunnel_start_tls(origin, connection)
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\dispatch\proxy_http.py", line 194, in tunnel_start_tls
    timeout=timeout,
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\site-packages\httpx\concurrency\asyncio.py", line 216, in start_tls
    timeout=timeout.connect_timeout,
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\tasks.py", line 416, in wait_for
    return fut.result()
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\base_events.py", line 1134, in start_tls
    await waiter
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 526, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\asyncio\sslproto.py", line 189, in feed_ssldata
    self._sslobj.do_handshake()
  File "C:\Users\localhost\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 763, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1056)
```








Discussion:

Patch:
diff --git a/httpx/client.py b/httpx/client.py
index 30beeb7..73b3069 100644
--- a/httpx/client.py
+++ b/httpx/client.py
@@ -107,13 +107,6 @@ class BaseClient:
         else:
             self.base_url = URL(base_url)
 
-        if proxies is None and trust_env:
-            proxies = typing.cast(ProxiesTypes, get_environment_proxies())
-
-        self.proxies: typing.Dict[str, AsyncDispatcher] = _proxies_to_dispatchers(
-            proxies
-        )
-
         if params is None:
             params = {}
 
@@ -125,6 +118,20 @@ class BaseClient:
         self.dispatch = async_dispatch
         self.concurrency_backend = backend
 
+        if proxies is None and trust_env:
+            proxies = typing.cast(ProxiesTypes, get_environment_proxies())
+
+        self.proxies: typing.Dict[str, AsyncDispatcher] = _proxies_to_dispatchers(
+            proxies,
+            verify=verify,
+            cert=cert,
+            timeout=timeout,
+            http_versions=http_versions,
+            pool_limits=pool_limits,
+            backend=backend,
+            trust_env=trust_env,
+        )
+
     @property
     def headers(self) -> Headers:
         return self._headers
@@ -196,16 +203,11 @@ class BaseClient:
         cert: CertTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> AsyncResponse:
         if request.url.scheme not in ("http", "https"):
             raise InvalidURL('URL scheme must be "http" or "https".')
 
-        if proxies is not None:
-            dispatch_proxies = _proxies_to_dispatchers(proxies)
-        else:
-            dispatch_proxies = self.proxies
-        dispatch = self._dispatcher_for_request(request, dispatch_proxies)
+        dispatch = self._dispatcher_for_request(request, self.proxies)
 
         async def get_response(request: AsyncRequest) -> AsyncResponse:
             try:
@@ -351,7 +353,6 @@ class AsyncClient(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> AsyncResponse:
         return await self.request(
             "GET",
@@ -366,7 +367,6 @@ class AsyncClient(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     async def options(
@@ -383,7 +383,6 @@ class AsyncClient(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> AsyncResponse:
         return await self.request(
             "OPTIONS",
@@ -398,7 +397,6 @@ class AsyncClient(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     async def head(
@@ -415,7 +413,6 @@ class AsyncClient(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> AsyncResponse:
         return await self.request(
             "HEAD",
@@ -430,7 +427,6 @@ class AsyncClient(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     async def post(
@@ -450,7 +446,6 @@ class AsyncClient(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> AsyncResponse:
         return await self.request(
             "POST",
@@ -468,7 +463,6 @@ class AsyncClient(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     async def put(
@@ -488,7 +482,6 @@ class AsyncClient(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> AsyncResponse:
         return await self.request(
             "PUT",
@@ -506,7 +499,6 @@ class AsyncClient(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     async def patch(
@@ -526,7 +518,6 @@ class AsyncClient(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> AsyncResponse:
         return await self.request(
             "PATCH",
@@ -544,7 +535,6 @@ class AsyncClient(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     async def delete(
@@ -564,7 +554,6 @@ class AsyncClient(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> AsyncResponse:
         return await self.request(
             "DELETE",
@@ -582,7 +571,6 @@ class AsyncClient(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     async def request(
@@ -603,7 +591,6 @@ class AsyncClient(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> AsyncResponse:
         request = self.build_request(
             method=method,
@@ -624,7 +611,6 @@ class AsyncClient(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
         return response
 
@@ -639,7 +625,6 @@ class AsyncClient(BaseClient):
         cert: CertTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> AsyncResponse:
         return await self._get_response(
             request=request,
@@ -650,7 +635,6 @@ class AsyncClient(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     async def close(self) -> None:
@@ -729,7 +713,6 @@ class Client(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> Response:
         request = self.build_request(
             method=method,
@@ -750,7 +733,6 @@ class Client(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
         return response
 
@@ -765,7 +747,6 @@ class Client(BaseClient):
         cert: CertTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> Response:
         concurrency_backend = self.concurrency_backend
 
@@ -779,7 +760,6 @@ class Client(BaseClient):
             "cert": cert,
             "timeout": timeout,
             "trust_env": trust_env,
-            "proxies": proxies,
         }
         async_response = concurrency_backend.run(coroutine, *args, **kwargs)
 
@@ -824,7 +804,6 @@ class Client(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> Response:
         return self.request(
             "GET",
@@ -839,7 +818,6 @@ class Client(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     def options(
@@ -856,7 +834,6 @@ class Client(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> Response:
         return self.request(
             "OPTIONS",
@@ -871,7 +848,6 @@ class Client(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     def head(
@@ -888,7 +864,6 @@ class Client(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> Response:
         return self.request(
             "HEAD",
@@ -903,7 +878,6 @@ class Client(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     def post(
@@ -923,7 +897,6 @@ class Client(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> Response:
         return self.request(
             "POST",
@@ -941,7 +914,6 @@ class Client(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     def put(
@@ -961,7 +933,6 @@ class Client(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> Response:
         return self.request(
             "PUT",
@@ -979,7 +950,6 @@ class Client(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     def patch(
@@ -999,7 +969,6 @@ class Client(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> Response:
         return self.request(
             "PATCH",
@@ -1017,7 +986,6 @@ class Client(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     def delete(
@@ -1037,7 +1005,6 @@ class Client(BaseClient):
         verify: VerifyTypes = None,
         timeout: TimeoutTypes = None,
         trust_env: bool = None,
-        proxies: ProxiesTypes = None,
     ) -> Response:
         return self.request(
             "DELETE",
@@ -1055,7 +1022,6 @@ class Client(BaseClient):
             cert=cert,
             timeout=timeout,
             trust_env=trust_env,
-            proxies=proxies,
         )
 
     def close(self) -> None:
@@ -1074,16 +1040,32 @@ class Client(BaseClient):
         self.close()
 
 
-def _proxy_from_url(url: URLTypes) -> AsyncDispatcher:
-    url = URL(url)
-    if url.scheme in ("http", "https"):
-        return HTTPProxy(url)
-    raise ValueError(f"Unknown proxy for {url!r}")
-
-
 def _proxies_to_dispatchers(
-    proxies: typing.Optional[ProxiesTypes]
+    proxies: typing.Optional[ProxiesTypes],
+    verify: VerifyTypes,
+    cert: typing.Optional[CertTypes],
+    timeout: TimeoutTypes,
+    http_versions: typing.Optional[HTTPVersionTypes],
+    pool_limits: PoolLimits,
+    backend: ConcurrencyBackend,
+    trust_env: bool,
 ) -> typing.Dict[str, AsyncDispatcher]:
+    def _proxy_from_url(url: URLTypes) -> AsyncDispatcher:
+        nonlocal verify, cert, timeout, http_versions, pool_limits, backend, trust_env
+        url = URL(url)
+        if url.scheme in ("http", "https"):
+            return HTTPProxy(
+                url,
+                verify=verify,
+                cert=cert,
+                timeout=timeout,
+                pool_limits=pool_limits,
+                backend=backend,
+                trust_env=trust_env,
+                http_versions=http_versions,
+            )
+        raise ValueError(f"Unknown proxy for {url!r}")
+
     if proxies is None:
         return {}
     elif isinstance(proxies, (str, URL)):
diff --git a/httpx/concurrency/asyncio.py b/httpx/concurrency/asyncio.py
index 696e32c..5d35014 100644
--- a/httpx/concurrency/asyncio.py
+++ b/httpx/concurrency/asyncio.py
@@ -81,6 +81,12 @@ class TCPStream(BaseTCPStream):
             except asyncio.TimeoutError:
                 if should_raise:
                     raise ReadTimeout() from None
+                # FIX(py3.6): yield control back to the event loop to give it a chance
+                # to cancel `.read(n)` before we retry.
+                # This prevents concurrent `.read()` calls, which asyncio
+                # doesn't seem to allow on 3.6.
+                # See: https://github.com/encode/httpx/issues/382
+                await asyncio.sleep(0)
 
         return data
 
diff --git a/httpx/config.py b/httpx/config.py
index b7c5ee6..f0f694f 100644
--- a/httpx/config.py
+++ b/httpx/config.py
@@ -6,7 +6,7 @@ from pathlib import Path
 import certifi
 
 from .__version__ import __version__
-from .utils import get_ca_bundle_from_env
+from .utils import get_ca_bundle_from_env, get_logger
 
 CertTypes = typing.Union[str, typing.Tuple[str, str], typing.Tuple[str, str, str]]
 VerifyTypes = typing.Union[str, bool, ssl.SSLContext]
@@ -40,6 +40,9 @@ DEFAULT_CIPHERS = ":".join(
 )
 
 
+logger = get_logger(__name__)
+
+
 class SSLConfig:
     """
     SSL Configuration.
@@ -91,6 +94,14 @@ class SSLConfig:
     ) -> ssl.SSLContext:
         http_versions = HTTPVersionConfig() if http_versions is None else http_versions
 
+        logger.debug(
+            f"load_ssl_context "
+            f"verify={self.verify!r} "
+            f"cert={self.cert!r} "
+            f"trust_env={self.trust_env!r} "
+            f"http_versions={http_versions!r}"
+        )
+
         if self.ssl_context is None:
             self.ssl_context = (
                 self.load_ssl_context_verify(http_versions=http_versions)
@@ -152,8 +163,10 @@ class SSLConfig:
             pass
 
         if ca_bundle_path.is_file():
+            logger.debug(f"load_verify_locations cafile={ca_bundle_path!s}")
             context.load_verify_locations(cafile=str(ca_bundle_path))
         elif ca_bundle_path.is_dir():
+            logger.debug(f"load_verify_locations capath={ca_bundle_path!s}")
             context.load_verify_locations(capath=str(ca_bundle_path))
 
         self._load_client_certs(context)
diff --git a/httpx/dispatch/proxy_http.py b/httpx/dispatch/proxy_http.py
index fe8bbd3..be2e289 100644
--- a/httpx/dispatch/proxy_http.py
+++ b/httpx/dispatch/proxy_http.py
@@ -7,6 +7,7 @@ from ..config import (
     DEFAULT_POOL_LIMITS,
     DEFAULT_TIMEOUT_CONFIG,
     CertTypes,
+    HTTPVersionTypes,
     PoolLimits,
     SSLConfig,
     TimeoutTypes,
@@ -51,8 +52,10 @@ class HTTPProxy(ConnectionPool):
         proxy_mode: HTTPProxyMode = HTTPProxyMode.DEFAULT,
         verify: VerifyTypes = True,
         cert: CertTypes = None,
+        trust_env: bool = None,
         timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,
         pool_limits: PoolLimits = DEFAULT_POOL_LIMITS,
+        http_versions: HTTPVersionTypes = None,
         backend: ConcurrencyBackend = None,
     ):
 
@@ -62,6 +65,8 @@ class HTTPProxy(ConnectionPool):
             timeout=timeout,
             pool_limits=pool_limits,
             backend=backend,
+            trust_env=trust_env,
+            http_versions=http_versions,
         )
 
         self.proxy_url = URL(proxy_url)
diff --git a/noxfile.py b/noxfile.py
index 64dae62..c7ada4f 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -20,12 +20,15 @@ def lint(session):
 @nox.session(reuse_venv=True)
 def check(session):
     session.install(
-        "black", "flake8", "flake8-bugbear", "flake8-comprehensions", "mypy"
+        "black", "flake8", "flake8-bugbear", "flake8-comprehensions", "isort", "mypy"
     )
 
     session.run("black", "--check", "--diff", "--target-version=py36", *source_files)
     session.run("flake8", *source_files)
     session.run("mypy", "httpx")
+    session.run(
+        "isort", "--check", "--diff", "--project=httpx", "--recursive", *source_files
+    )
 
 
 @nox.session(reuse_venv=True)


Test patch:
diff --git a/tests/client/test_proxies.py b/tests/client/test_proxies.py
index 19521b7..ba59677 100644
--- a/tests/client/test_proxies.py
+++ b/tests/client/test_proxies.py
@@ -27,3 +27,22 @@ def test_proxies_parameter(proxies, expected_proxies):
         assert client.proxies[proxy_key].proxy_url == url
 
     assert len(expected_proxies) == len(client.proxies)
+
+
+def test_proxies_has_same_properties_as_dispatch():
+    client = httpx.AsyncClient(proxies="http://127.0.0.1")
+    pool = client.dispatch
+    proxy = client.proxies["all"]
+
+    assert isinstance(pool, httpx.ConnectionPool)
+    assert isinstance(proxy, httpx.HTTPProxy)
+
+    for prop in [
+        "verify",
+        "cert",
+        "timeout",
+        "pool_limits",
+        "http_versions",
+        "backend",
+    ]:
+        assert getattr(pool, prop) == getattr(proxy, prop)
diff --git a/tests/test_timeouts.py b/tests/test_timeouts.py
index 8dc1e08..ff5273b 100644
--- a/tests/test_timeouts.py
+++ b/tests/test_timeouts.py
@@ -2,6 +2,7 @@ import pytest
 
 from httpx import (
     AsyncClient,
+    Client,
     ConnectTimeout,
     PoolLimits,
     PoolTimeout,
@@ -47,3 +48,13 @@ async def test_pool_timeout(server, backend):
             await client.get("http://localhost:8000/")
 
         await response.read()
+
+
+def test_sync_infinite_timeout(server):
+    """Regression test for a bug that occurred under Python 3.6.
+
+    See: https://github.com/encode/httpx/issues/382
+    """
+    no_timeout = TimeoutConfig()
+    with Client(timeout=no_timeout) as client:
+        client.get(server.url.copy_with(path="/slow_response/50"))