-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
- The bug is reproducible against the latest release and/or
master. - There are no similar issues or pull requests to fix it yet.
Currently both async and sync client requests are succeptible to low-and-slow "attacks" unless explicitly handled. In other words when request is being streamed as long as 1 byte every 2 seconds (or aprox.) is being generated the connection will not close or timeout with none of the current available settings.
It's possible for the server to serve single html page almost idefinitely and hang the client thread.
Maybe httpx should introduce some optional or even default handlers for this? Maybe it's already possible to hook something like this in easily?
To reproduce
resp = httpx.get(
"http://httpbin.org/drip?duration=30&numbytes=30&code=200&delay=2",
timeout=Timeout(connect=3, read=3, write=3, pool=3, timeout=3),
)
The above code snippet will take 30+ seconds to complete (though this could be practically infinity) disregarding any timeout settings. The only way to avoid this is to explitictly wrap everything in either asyncio.wait_for() for async code and for sync code seems to be much more complicated (?).