Hello.  I have been working with CakePHP in some capacity for about two 
years.  I have never contributed to the project, and I was considering 
doing so, but I thought I would post first, as I am apprehensive about 
whether my contribution is something useful to everyone, or if it is 
specific to my use case.

To be clear, I currently am using Cake for rendering JSON only into an 
angularJS frontend.  By default, my requests are content-type 
application/json.  PHP in general does not like this very much, and Cake no 
more so.  I propose to modify the CakeRequest Class to check for 
content-type == application/json before doing anything else, and if that is 
the case, then reading the contents of php://input into $request->data. 
 For me, this solves many problems:

1.  POST data is always contained in $controller->request->data regardless 
of whether request method is POST, PUT, DELETE, etc.
2.  For PUT in particular, Cake currently will not route application/json 
requestsin the case that it is to be overridden by the POST value _method.
3.  POST data is ALWAYS contained in $controller->request->data.

As I said, for me this is a good solution.  I was going to implement it, 
and just make a merge request (not much code), but my change breaks some of 
the existing test cases, namely Network/CakeRequestTest/testPutParsingJSON. 
 In my opinion, the test should be changed, because it does not represent a 
real world situation (Can you actually make an honest-to-god PUT request to 
PHP?).  I would think that "faking" a PUT request with POST is more common. 
 Can anyone provide me with some feedback on this, or an answer to why it 
hasn't been done already?  Thanks!

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to