Opened 13 years ago

Closed 13 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:


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)

http_request.diff (1.2 KB) - added by rikyu 13 years ago.
http.Request patch that moves request body parsing into a separate, overridable function

Download all attachments as: .zip

Change History (3)

Changed 13 years ago by rikyu

Attachment: http_request.diff added

http.Request patch that moves request body parsing into a separate, overridable function

comment:1 Changed 13 years ago by Glyph

Resolution: duplicate
Status: newclosed

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 11 years ago by <automation>

Owner: jknight deleted
Note: See TracTickets for help on using tickets.