Skip to content

Client hangs on 206 Partial Content response with Content-Encoding: gzip #3123

Closed
@pauleikis

Description

Long story short

When server responds with 206 to range request - response.read() hangs.
Also requests library handles the same scenarios successfully.

Expected behaviour

Partial content is a valid content when responding to a range request. The client should not hang and just decode as much as possible.

Actual behaviour

The response.read() hangs indefinitely if Content-Encoding: gzip. Does not hang when Content-Encoding is deflate or brotli.

Steps to reproduce

import asyncio

import aiohttp
import aiohttp.web
import requests

async def client():
    async with aiohttp.ClientSession(headers={"Range": "bytes=0-1000"}) as session:
        # async with session.get("https://www.airbnb.com") as response:
        async with session.get("https://www.tripadvisor.com") as response:
            await response.read()
            print("Never reached")

print(requests.get("https://www.tripadvisor.com", headers={"Range": "bytes=0-1000"}).text)
print(requests.get("https://www.airbnb.com", headers={"Range": "bytes=0-1000"}).text)

asyncio.get_event_loop().run_until_complete(client())

Your environment

aiohttp==3.3.2
requests==2.19.1
macOS 10.13.5
no proxy
aiohttp client

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions