Opened 5 years ago

Closed 5 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: Launchpad Bug:

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)

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

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by rikyu

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

comment:1 Changed 5 years ago by glyph

  • Resolution set to duplicate
  • Status changed from new to 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 3 years ago by <automation>

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