Re: Why PUT and DELETE?
Posted: Dec 30, 2006 11:00 AM
> > > If you don't think that's a good idea, then you don't
> > > really have an objection to PUT and DELETE anymore.
> > >
> > I don't have an objection to PUT and DELETE. I just
> > see much added value. I interviewed Rusty Harold to see
> > I could glean some insights, and I'm still not very
> > convinced. They exist, and aren't going away, but I
> > see much need to use them in anything I'm designing.
> I beg to differ, it's rather that they don't exist anymore
> because they have already gone away -- or can you tell a
> HTML form to PUT something? Can you mark a link such that
> it does a DELETE?
They were not included in browsers, and I think support was poor at times in some web servers too. But my impression is that in practice I could use PUT and DELETE by merely handling them in my servlet.
doDelete methods, and I imagine Tomcat and Jetty and such will call them.
> ERH merely tries to resurrect some of the HTTP protocol
> which is out there as a spec, somewhat dominated by WWW
> use and browser implementors.
Well it is a common complaint among REST-enthusiasts, that browsers should support PUT and DELETE, that this would make the world a better place, but I still can't figure out how I'd use them if they did. I just updated the article based on some edit suggestions from Rusty, and one of the sentences I updated was:
The key difference between PUT and POST for update is that POST merely adds to an existing resource while PUT replaces it entirely.
Well, I'd never have a client completely replace a web page of Artima. Because then you'd rely on them decorating it with site wide look and feel, headers, footers, ads, etc. I'm using a form right now that will POST to this forum, and that updates a part of the page. So in a CMS kind of system like Artima, you'd never submit pages whole cloth, just content that gets wrapped and presented as web page resources. One thing Rusty told me to check out was Atom, and I haven't yet had time to understand how Atom would use PUT and DELETE. Pointers would be welcome. But even in the case of RSS or Atom feeds that we provide to the world, they would basically be made up of content that was POSTed to Artima, and later wrapped and presented in XML.
> Of course, one can provide a service interface that "puts"
> and "deletes" without using anything from the protocol
> level -- but there is a fair share of people that simply
> don't know that they have the option of using the
> protocol. If you have something REST style that really
> ties resources to URIs, why not use PUT and DELETE (other
> networking code?)
That's actually kind of what my point is. I can see I may come up with a use for PUT and DELETE if I design a web service, i.e., if the client is autonomous software (as opposed to user-facing browser software). But I still don't see how adding PUT and DELETE support to browsers would buy us much for the human-facing web. In the case of a non-browser software client, I think GET, PUT, DELETE kind of makes a web server act like a file system. When you write a file to a file system, you (the client or writer) pick the file name. The files have permissions associated with them. File systems are certainly useful. But even then, I could also design a web-based file system service that just operates using GET and POST.