footballsoccerpainting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-09 20:50 UTC
GET and POST aren''t enough
I started toying with Prototype today. It''s been sort of a kid in the candy store, "can I really do that? Woah!" fun afternoon. The $() operator, the sublime syntax for Ajax.Request, and the promise of so much more I haven''t tried yet. I guess that''s what frustrates me so much about intentionally sending the wrong type of HTTP request instead of a DELETE or a PUT. A POST is a POST, and not a DELETE, and not a PUT. Hiding the intended message type violates the REST principle of being a self-descriptive message at the protocol level. It also blocks the consumption of web services using POST/GET/PUT/DELETE to implement CRUD methods. Has anyone forked Prototype to fix this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I was under the impression that you could use DELETE and PUT with prototype. In fact, the API indicates you can here: http://prototypejs.org/api/ajax/options (just look for the method option). That being said, I personally haven''t found the need for them but if you need them they are there. -- Dash -- footballsoccerpainting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I started toying with Prototype today. It''s been sort of a kid in the > candy store, "can I really do that? Woah!" fun afternoon. The $() > operator, the sublime syntax for Ajax.Request, and the promise of so > much more I haven''t tried yet. > > I guess that''s what frustrates me so much about intentionally sending > the wrong type of HTTP request instead of a DELETE or a PUT. A POST is > a POST, and not a DELETE, and not a PUT. Hiding the intended message > type violates the REST principle of being a self-descriptive message > at the protocol level. It also blocks the consumption of web services > using POST/GET/PUT/DELETE to implement CRUD methods. > > Has anyone forked Prototype to fix this? > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
There''s been a bit of a discussion about it, if you care to check the archives. You''re right, but Safari doesn''t recognize non GET/POST methods. It''s been fixed in WebKit, but hasn''t been distributed by Apple as an update to Safari. Rails (which I don''t use--yet) does the translation automatically, so no harm done there. There is a ticket/patch in Trac to allow to programmer the option of forcing a particular method. I don''t know what the plans are for it, but I know the devs are aware of it. http://dev.rubyonrails.org/ticket/6595 TAG On Apr 9, 2007, at 2:50 PM, footballsoccerpainting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > I started toying with Prototype today. It''s been sort of a kid in the > candy store, "can I really do that? Woah!" fun afternoon. The $() > operator, the sublime syntax for Ajax.Request, and the promise of so > much more I haven''t tried yet. > > I guess that''s what frustrates me so much about intentionally sending > the wrong type of HTTP request instead of a DELETE or a PUT. A POST is > a POST, and not a DELETE, and not a PUT. Hiding the intended message > type violates the REST principle of being a self-descriptive message > at the protocol level. It also blocks the consumption of web services > using POST/GET/PUT/DELETE to implement CRUD methods. > > Has anyone forked Prototype to fix this? > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
footballsoccerpainting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit :> I guess that''s what frustrates me so much about intentionally sending > the wrong type of HTTP request instead of a DELETE or a PUT. A POST isThat''s because most browsers WILL NOT support other HTTP verbs natively. The upcoming W3C spec mandates support for other verbs (most notably PUT and DELETE), but most browsers follow HTML guidelines, which do not support anything else than PUT or DELETE. So Prototype relies on a trick for now, which is implemented already on the server side by RoR, and can easily be supported with very little custom code on any other platform (it''s only a question of looking for the _method parameter in the POST request, after all). As soon as there is widespread support for other HTTP verbs in XHR, Prototype will use it. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Prototype doesn''t actually use those methods--it uses POST (if not POST or GET), and passes the requested method in a parameter called ''_method''. Or, to quote directly from the docs you linked: "As a Ruby On Rails special, Prototype also reacts to other verbs (such as ''put'' and ''delete'' by actually using ''post'' and putting an extra ''_method'' parameter with the originally requested method in there." TAG On Apr 9, 2007, at 2:55 PM, David Dashifen Kees wrote:> > I was under the impression that you could use DELETE and PUT with > prototype. In fact, the API indicates you can here: > http://prototypejs.org/api/ajax/options (just look for the method > option). That being said, I personally haven''t found the need for > them > but if you need them they are there. > > -- Dash -- > > footballsoccerpainting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: >> I started toying with Prototype today. It''s been sort of a kid in the >> candy store, "can I really do that? Woah!" fun afternoon. The $() >> operator, the sublime syntax for Ajax.Request, and the promise of so >> much more I haven''t tried yet. >> >> I guess that''s what frustrates me so much about intentionally sending >> the wrong type of HTTP request instead of a DELETE or a PUT. A >> POST is >> a POST, and not a DELETE, and not a PUT. Hiding the intended message >> type violates the REST principle of being a self-descriptive message >> at the protocol level. It also blocks the consumption of web services >> using POST/GET/PUT/DELETE to implement CRUD methods. >> >> Has anyone forked Prototype to fix this? >> >> >>> >> >> > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Like I said, I don''t know enough about PUT or DELETE, so what the exact difference is between using POST and then telling the server what it tried to use so that the server can handle things otherwise or actually just using the verb escapes me. I just wanted to make sure that the original poster had noticed that Prototype provided an option if it works for his needs. Speaking of which, anyone got a good document online for exactly what PUT or DELETE do? I know, I could google it, but asking for a recommendation always seems to generate a solid lead from the get go rather than having to sift through a hojillion bad links or worse explanations before finding some gold. -- Dash -- Tom Gregory wrote:> Prototype doesn''t actually use those methods--it uses POST (if not > POST or GET), and passes the requested method in a parameter called > ''_method''. > > Or, to quote directly from the docs you linked: > "As a Ruby On Rails special, Prototype also reacts to other verbs > (such as ''put'' and ''delete'' by actually using ''post'' and putting an > extra ''_method'' parameter with the originally requested method in > there." > > > > TAG > > On Apr 9, 2007, at 2:55 PM, David Dashifen Kees wrote: > > >> I was under the impression that you could use DELETE and PUT with >> prototype. In fact, the API indicates you can here: >> http://prototypejs.org/api/ajax/options (just look for the method >> option). That being said, I personally haven''t found the need for >> them >> but if you need them they are there. >> >> -- Dash -- >> >> footballsoccerpainting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: >> >>> I started toying with Prototype today. It''s been sort of a kid in the >>> candy store, "can I really do that? Woah!" fun afternoon. The $() >>> operator, the sublime syntax for Ajax.Request, and the promise of so >>> much more I haven''t tried yet. >>> >>> I guess that''s what frustrates me so much about intentionally sending >>> the wrong type of HTTP request instead of a DELETE or a PUT. A >>> POST is >>> a POST, and not a DELETE, and not a PUT. Hiding the intended message >>> type violates the REST principle of being a self-descriptive message >>> at the protocol level. It also blocks the consumption of web services >>> using POST/GET/PUT/DELETE to implement CRUD methods. >>> >>> Has anyone forked Prototype to fix this? >>> >>> >>> >>> > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
footballsoccerpainting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-09 21:38 UTC
Re: GET and POST aren''t enough
Firefox 2 supports PUT & DELETE as XHR methods. It sounds like the next version of Safari will too. I can''t test IE on my Mac, but this page would tell me how good the XHR implementation is -- WARNING the page will display many JS alerts! http://www.mnot.net/javascript/xmlhttprequest/ I''m looking forward to an official release of Prototype with this fixed. The minor problems it causes with HTTP are mostly moot (caches won''t inspect the query string for the intended req type -- but caching PUT and DELETE seems bad). It''s much worse to be incompatible with web services which use PUT & DELETE. Thank you for the feedback! On Apr 9, 5:09 pm, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> footballsoccerpaint...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org a écrit : > > > I guess that''s what frustrates me so much about intentionally sending > > the wrong type of HTTP request instead of a DELETE or a PUT. A POST is > > That''s because most browsers WILL NOT support other HTTP verbs natively. > The upcoming W3C spec mandates support for other verbs (most notably > PUT and DELETE), but most browsers follow HTML guidelines, which do not > support anything else than PUT or DELETE. > > So Prototype relies on a trick for now, which is implemented already on > the server side by RoR, and can easily be supported with very little > custom code on any other platform (it''s only a question of looking for > the _method parameter in the POST request, after all). > > As soon as there is widespread support for other HTTP verbs in XHR, > Prototype will use it. > > -- > Christophe Porteneuve a.k.a. TDD > "[They] did not know it was impossible, so they did it." --Mark Twain > Email: t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---