-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
BaseRequest: misleading name of has_body
attribute
#2005
Comments
Oops. IIRC many ages ago the attribute behavior was exactly that its name means. |
Is there a use case that validates the existence of |
Sorry, no. I like the name too but aiohttp is open source project. For example I prefer |
|
Agree. That actually makes sense and I didn't realize this when I proposed
the behavior modification.
In that case `.can_read_body` sounds to me as a proper attribute name for
tue functionality.
I will try to make a PR.
…On Fri, 23 Jun 2017 at 17:27, Andrew Svetlov ***@***.***> wrote:
.can_read_body name is not used by our API and we could start switching
from .has_body to .can_read_body.
And we free to make a new attribute with proper .has_body functionality
but under different name.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2005 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF5ecLkAm28c6sZy0THXTSrFnHXIPe8lks5sG9lggaJpZM4ODbBx>
.
|
Please do. Thank you. |
Any thoughts on what to call the new attribute with proper |
… (#2169) * Deprecated BaseRequest.has_body, replaced with 2 new attributes * Test obsolete BaseRequest.has_body attr
…libs#2005) (aio-libs#2169) * Deprecated BaseRequest.has_body, replaced with 2 new attributes * Test obsolete BaseRequest.has_body attr
Is there anything else for this issue or can we close it? |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
Long story short
class BaseRequest
has attributehas_body
that has an unfortunate name as it checks if there are more bytes to read from its body. And when the body is read it changes its value toFalse
. This fact is not obvious from attribute name neither documentation and it causes confusion and bugs.Expected behavior
has_body
should stay static over a lifetime of a request. Or the attribute name and a related documentation should be more specific about the fact that once a body of a request is read, the value has changed.Actual behavior
has_body
returnFalse
if a request has a body but was read by another method such asawait request.json()
.Steps to reproduce
Simple handler that shows this behavior.
Your environment
Not an environment specific.
The text was updated successfully, but these errors were encountered: