#37681 [Fbk->Opn]: PUT and DELETE superglobals support

From: Date: Sat, 03 Jun 2006 13:43:51 +0000
Subject: #37681 [Fbk->Opn]: PUT and DELETE superglobals support
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-98000@lists.php.net to get a copy of this message
ID: 37681 User updated by: f_kereki at cs dot com dot uy Reported By: f_kereki at cs dot com dot uy -Status: Feedback +Status: Open Bug Type: cURL related Operating System: SUSE 10.0 PHP Version: 5.1.4 New Comment: I'm coding a Service Oriented system, and according to REST principles, I should be able to call a service with a PUT or DELETE method. For example, using AJAX, in JavaScript I would write something like: objeto= new XMLHttpRequest(); objeto.open("PUT", "my_own_service.php", true); objeto.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); objeto.onreadystatechange= some_function_of_mine; objeto.send("a_string_like_field=value&field2=value2"); but then, my_own_service.php would have no way of getting to the PUT parameters! With POST or GET methods, you can use the $_POST and $_GET (and even $_REQUEST) arrays, but there are no $_PUT or $_DELETE equivalent arrays. Note, however, that this is *not* just an AJAX problem; if you require a PHP service from within another PHP service, you would code something like: $ch= curl_init(); curl_setopt($ch, CURLOPT_URL, "my_own_service.php"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_POSTFIELDS, "a_string_like_field=value&field2=value2"); $result= curl_exec($ch); curl_close($ch); Of course, this points out yet ANOTHER problem... there is no CURLOPT_PUTFIELDS! Since the format is the same, I assume my way should work, but I cannot even get to test it until I have a way of getting to the PUT parameters from within PHP. So, to resume it all, it seems to me: * there should be $_PUT and $_DELETE arrays * curl should support CURLOPT_PUTFIELDS, *or* make it clearer that CURLOPT_POSTFIELDS is to be used. Hope I was clearer this time! Best regards, Federico Kereki Previous Comments: ------------------------------------------------------------------------ [2006-06-02 19:28:33] mike@php.net Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PHP. ------------------------------------------------------------------------ [2006-06-02 17:12:29] f_kereki at cs dot com dot uy Description: ------------ When coding Web Services according to REST ideas, there is no way to get PUT or DELETE parameters -- something like $_GET or $_POST is needed. You can invoke a service using curl, but only GET and POST can be used; if you use PUT or DELETE you cannot get the parameters in PHP. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37681&edit=1

« previous php.bugs (#98000) next »