Can't get PUT data with Code Igniter, REST, Lighttpd url-rewrite and Backbone.js

I am using CodeIgniter with REST API and Backbone.js. The web server is lighttpd. I also have lighttpd.conf modified to rewrite urls to remove index.php from urls like this: -

url.rewrite-once = (
 "/(.*)\.(.*)" => "$0",
 "/(css|files|img|js|stats)/" => "$0",
 "^/([^.]+)$" => "/index.php/$1"
)

      

The call from js reaches the Codeigniter Put function, but the value for $ this-> put () is empty. Please help me in tracking down why the value for PUT data is empty.

Note. This works great when I don't rewrite the urls. Also this works for Apache web server.

While debugging the REST_Controller.php file in the "protected function _parse_put ()" I found that the content of the "php: // input" file is also empty

Following are the request headers and payload, made from the Chrome Web inspector, with a PUT Call: -

**Request Headers**
PUT http://10.82.0.160/cav_settings/api/2 HTTP/1.1
Pragma: no-cache
Origin: http://10.82.0.160
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56 Safari/537.17
Content-Type: application/json
Accept: application/json, text/javascript, */*; q=0.01
Referer: http://10.82.0.160/settings/2
X-Requested-With: XMLHttpRequest
**Request Payload**
{"aggregation":{"enabled":"false","mode":""},"dns":{"auto":"false","servers":["10.0.0.5","10.20.0.20"]},"id":"2","dhcp":"false","ip":"10.82.0.160","netmask":"255.255.255.0","default_gw":"","mtu":"1500"}

      

+3


source to share


1 answer


you can use Backbone.emulateJSON = true;

This is the best answer to your doubts :)



Backbone.js PUT / DELETE problems with Codeigniter REST server

0


source







All Articles