New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set response attribute length_remaining
in BaseHTTPResponse
#3317
Set response attribute length_remaining
in BaseHTTPResponse
#3317
Conversation
Changelog test is failing. I don't think a changelog is needed for this since it is invisible to users? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this!
length_remaining
needs to be passed in the __init__
method without any default value as is done for status
or version
. Then in HTTP2 response we can call super().__init__(status=status, ..., length_remaining=0)
. Does that make sense?
That does make sense. Now, in the case of urllib3/src/urllib3/response.py Line 614 in 8c8e26d
How can we handle of this? The easy way would be to simply call super with an initial length_remaining of 0 then updating it with the calculated value after super().__init__ .
|
I've now made it a parameter of BaseHTTPRequest's Also I've run the CI twice the tests seem to be failing on random network issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the proof of concept! I'm not sure what to think. Setting to 0 and then to the real value seems pretty bad, but passing all required values to init_length
seems pretty bad too. I'm sorry that I failed to see that, and for now this changed looks a like net negative to me. :/
I'll wait to see if another reviewer thinks differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding an annotation length_remaining: int | None
without any default value to BaseHTTPResponse
?
Possible. So do we still need to pass its value as an argument to |
@programmer-ke I agree with @illia-v's approach, let's type annotate |
1958c91
to
586247e
Compare
Made an update, now setting the Also, there's some flakiness in the tests I think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! LGTM.
Closes #3315
Since both HTTPResponse and HTTP2Response use the
length_remaining
, make it an attribute of the base class.