[mod_python] util.FieldStorage wrong about method restrictions

Graham Dumpleton grahamd at dscpl.com.au
Mon Aug 14 19:17:05 EDT 2006


Nic James Ferrier wrote ..
> Jim Gallacher <jpg at jgassociates.ca> writes:
> 
> > It's my understanding that PUT is used for uploading binary objects such
> > as files, without creating the MIME message usually associated with
> > POST. FieldStorage really doesn't make sense in that context.
> >
> > I might be wrong though.
> 
> PUT is used for changing the entity pointed at by the URI.
> 
> But the entity could be represented as an XML document, a binary
> object or as a list of fields.
> 
> Here is RFC2616, section 9.6, Page 55:
> 
>    The fundamental difference between the POST and PUT requests is
>    reflected in the different meaning of the Request-URI. The URI in a
>    POST request identifies the resource that will handle the enclosed
>    entity. That resource might be a data-accepting process, a gateway to
>    some other protocol, or a separate entity that accepts annotations.
>    In contrast, the URI in a PUT request identifies the entity enclosed
>    with the request -- the user agent knows what URI is intended and the
>    server MUST NOT attempt to apply the request to some other
>    resource.
> 
> Really that is the only difference. Which is why both cgi.FieldStorage
> and util.FieldStorage should allow PUT as well as POST.
> 
> Still, mod_python's wants to behave like cgi's. So I'll go talk to the
> cgi people about changing their's first.

Just because I referenced cgi.FieldStorage does not mean we are simply
following what they have done, it was just one indicator I used for trying
to work out what is regarded as common/good practice in regard to use
of POST/PUT and multipart/form data.

I also did other searching on the Internet and of the few pages of search
results I checked, I couldn't find one example of where someone was using
multipart/form data in conjunction with a PUT request. Where PUT was
used, the target of the update was included in its raw form as the content
and where content type was specified, it was an adjunct to the data just
to indicate what format the data was. For example, image/jpeg, text/xml
etc. That is, it was used in the same way that the content type of the file
would be returned as if it were a GET request for that file.

In other words, you seem to want to do something that is out of the
ordinary and not commonly accepted practice. Besides pointing at the
RFC and saying that it may allow it, can you instead point at some instances
where this is actually done in practice. If you can show that this is a
commonly accepted technique, then we might consider it a worthwhile
change. In the mean time, you can use the bit of wrapper code I posted
in the first place to make it work.

Graham


More information about the Mod_python mailing list