[Twisted-Python] Content length of a response in treq

Adi Roiban adi at roiban.ro
Sun Feb 10 12:36:19 MST 2019


On Sun, 10 Feb 2019 at 18:23, Mehtab Zafar <mehtab.zafar98 at gmail.com> wrote:
>
> Hi,
> I am trying to use treq for a project in which I am also going to generate a progress bar for the downloading session. But the problem I am facing is that I can't find a way to get the content length header from the response.
>
> The "response.length"  gives me "unknown size".So I there a way I can get the length for all types of content?
>
> Thanks

Hi,

Which encoding is used for your response?

Do you have Chunked encoding
https://en.wikipedia.org/wiki/Chunked_transfer_encoding
In this case, the content length is not advertised in the response headers.

Regards,
-- 
Adi Roiban




More information about the Twisted-Python mailing list