-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
raise 413 from request.post() not ValueError #3093
Conversation
by the way, when I run
This seems to be new, I wasn't getting it before. |
Perhaps you didn't compile cython extensions. |
|
aiohttp/web_request.py
Outdated
@@ -605,8 +604,7 @@ def body_exists(self) -> bool: | |||
out.add(field.name, value) | |||
size += len(value) | |||
if 0 < max_size < size: | |||
raise ValueError( | |||
'Maximum request body size exceeded') | |||
raise HTTPRequestEntityTooLarge |
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.
May be add some message like what size was expected and which one is actual? That's good for debug.
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.
Makes sense.
We do it for too large headers already.
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.
Ok, so something like Maximum request body size exceeded: 1234 > 123
?
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.
Or perhaps clearer Maximum request body size 123 exceeded, actual body size 1234
?
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.
I like the second
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.
👍 the second. A bit verbose, but that wouldn't hurt.
Codecov Report
@@ Coverage Diff @@
## master #3093 +/- ##
=========================================
+ Coverage 98.01% 98.2% +0.19%
=========================================
Files 43 43
Lines 7807 8199 +392
Branches 1352 1525 +173
=========================================
+ Hits 7652 8052 +400
+ Misses 56 53 -3
+ Partials 99 94 -5
Continue to review full report at Codecov.
|
aiohttp/web_request.py
Outdated
raise ValueError( | ||
'Maximum request body size exceeded') | ||
raise HTTPRequestEntityTooLarge( | ||
max_size=max_size, actual_size=size) |
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.
That style is a bit different from above:
+ if self._client_max_size:
+ body_size = len(body)
+ if body_size >= self._client_max_size:
+ raise HTTPRequestEntityTooLarge(
+ max_size=self._client_max_size,
+ actual_size=body_size
+ )
Let's be consistent.
thanks! |
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. |
What do these changes do?
Raise 413 "Payload Too Large" rather than raising ValueError in request.post()
Are there changes in behavior for the user?
post will raise
HTTPRequestEntityTooLarge
rather than ValueErrorRelated issue number
fix #3087
Checklist
CHANGES
folder<issue_id>.<type>
for example (588.bugfix)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.