[Python] HTTPx Response.extensions["network_stream"] not reading as much as was specified

Discussão em 'Python' iniciado por Stack, Julho 5, 2025.

  1. Stack

    Stack Membro Participativo

    Minimum reproducible example:

    from httpx import stream
    with stream('GET', 'http://127.0.0.1:5689/x86/fish/1.0.1.gmf') as req: # file length 13875362 bytes
    net_stream = req.extensions["network_stream"]
    print(len(net_stream.read(1024256))) # prints 112704?! Whaaat?


    Whenever I try to read over 112704 bytes in HTTPx via the "raw stream" that they provide, it only reads 112704 bytes, and on the server side (python -m http.server), a ConnectionResetError is thrown.

    It works if I just net_stream.read(112703) multiple times, but that's not a very great solution. Am I just looking over a part of the docs, or what?

    I'm running Python 3.12 on NixOS with httpx 0.28.1 and httpcore 1.0.9.

    Continue reading...

Compartilhe esta Página