Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4672 (closed enhancement: worksforme)

Opened 2 years ago

Last modified 2 years ago

Allow PUT requests via Prototype to have bodies

Reported by: minam Assigned to: sam@conio.net
Priority: normal Milestone:
Component: Prototype Version:
Severity: normal Keywords:
Cc:

Description

Currently, Prototype only sends a request body with POST requests. This patch makes it possible for PUT requests to also send a body (and makes it simple to identify other request methods that should also be allowed to have bodies).

Attachments

put.diff (1.3 kB) - added by minam on 04/09/06 22:20:11.
put-2.diff (1.4 kB) - added by minam on 04/10/06 01:41:31.

Change History

04/09/06 22:20:11 changed by minam

  • attachment put.diff added.

04/10/06 00:38:51 changed by devslashnull@gmail.com

I think you've been using Ruby too much recently, as you left out the 'return' in your hasContent method.

04/10/06 01:41:31 changed by minam

  • attachment put-2.diff added.

04/10/06 01:41:54 changed by minam

*sigh*

Good catch. Thanks for pointing that out. I've updated the patch.

10/09/06 10:00:56 changed by mislav

This ticket is now superseded by #6366.

11/04/06 19:52:00 changed by mislav

  • status changed from new to closed.
  • resolution set to worksforme.

Apart from this fix being superseded, testing options.method for "put" makes no sense because PUT and DELETE are emulated over POST (so at that point options.method will be "post" in any case)

(follow-up: ↓ 6 ) 11/07/06 13:58:56 changed by mislav

A thing just came into my mind. This is for all those who would think this is a bug and stumble upon this ticket.

You can't use the postBody option and PUT. If you try that, it will result in a POST. This is because most browsers don't support PUT at all and Prototype simulates PUT over POST by adding "_method=put" to params. Rails, for instance, looks for the "_method" parameter and obeys it.

The postBody option, if supplied, takes precedence over params. That means if you use postBody, the server will never receive "_method=put" and will treat the request as an ordinary POST.

But this shouldn't cause worries. The postBody options is advanced usage, and an advanced user will manually simulate PUT if they need it.

(in reply to: ↑ 5 ) 11/09/06 18:17:39 changed by tomg

Replying to mislav:

This is because most browsers don't support PUT at all...

Uh, no. Some Apache configurations may be set to disallow anything that's not GET or POST, but that's not a browser issue. I use PUT (and DELETE) successfully in IE 6+, Firefox (1.0.6+), and Safari (2.0). I haven't tested earlier versions as I haven't needed to.

As a non-rails user, I'd like to be able to pass valid request types without prototype mangling 'em.