Skip to content

Error when opening zipfiles requests. zipfile.BadZipFile: File is not a zip file #2212

@Tyarel8

Description

@Tyarel8

After attempting to donwload and extract a zipfile using httpx

rz = httpx.get(url)
with zipfile.ZipFile(BytesIO(rz.content)) as z:
         z.extractall(DOWNLOAD_PATH)

it throws the following error zipfile.BadZipFile: File is not a zip file

However, using the exact same code but with the requests module works as intended

rz = requests.get(url)
with zipfile.ZipFile(BytesIO(rz.content)) as z:
         z.extractall(DOWNLOAD_PATH)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions