Opened 9 years ago
Closed 9 years ago
#4118 enhancement closed duplicate (duplicate)
implementation issue with t.w.http.Request
Reported by: | rikyu | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | web | Keywords: | |
Cc: | rikyu | Branch: | |
Author: |
Description
I've noticed a problem with the standard twisted.web Request object that I'd like to get some feedback on.
The issue is in the way the Request parses POST data. Basically, since the request body is parsed before the Request is handed off to any user code, it makes it impossible to implement interactive file uploads, or to prohibit large attachment sizes.
My fix was to create an UnparsedRequest subclass, and re-implement requestReceived(), but that required duplicating a lot of code. Also, it was only a solution in my case because I was parsing POST data myself, and was not relying on request.args.
As an alternative, I've attached a patch to t.w.http.Request which breaks off the body parsing into a separate function. This allows a subclass of Request to override handling of the request body, or ignore it completely, without affecting other twisted.web code that depends on pre-parsed POST data.
Attachments (1)
Change History (3)
Changed 9 years ago by
Attachment: | http_request.diff added |
---|
comment:1 Changed 9 years ago by
Resolution: | → duplicate |
---|---|
Status: | new → closed |
This is a duplicate of #288. The problem with your approach here is making sure that none of the calls to getChild
along the way rely on request.args
. As you've implemented it, the parsing is deferred, but you still have to wait for all the data in the request to be received before processing it.
comment:2 Changed 8 years ago by
Owner: | jknight deleted |
---|
http.Request patch that moves request body parsing into a separate, overridable function