Whilst developing a RESTful API at work, I ran into a small ‘feature’ of Symfony 1.4 which required digging into the sourcecode. I was trying to use the pecl_http HTTP class to make GET, POST, PUT and DELETE requests - the GET and POST worked fine with Symfony populating the request with the correct variables, but PUT and DELETE didn’t want to play ball leaving the request parameters empty.
Turns out Symfony requires you to specifically set a Content-Type Header and have it’s value be set to application/x-www-form-urlencoded.
So a route specified as such:
1 2 3 4 5
With an action that wants to access the content parameter:
1 2 3
Will work correctly with the following pecl_http HTTP client code:
1 2 3 4
The same also goes for a HTTP DELETE request (the client code will obviously be different but the Header needs to be set the same way). GET and POST requests don’t need anything special.