+ // TODO: perhaps move this interceptor elsewhere? like into DataProxy, perhaps? Placed here
+ // to satisfy initial 3.0 final release of REST features.
+ proxy.onWrite = proxy.onWrite.createInterceptor(function(action, o, response, rs) {
+ var reader = o.reader;
+ var res = new Ext.data.Response({
+ action: action,
+ raw: response
+ });
+
+ switch (response.status) {
+ case 200: // standard 200 response, send control back to HttpProxy#onWrite by returning true from this intercepted #onWrite
+ return true;
+ break;
+ case 201: // entity created but no response returned
+ if (Ext.isEmpty(res.raw.responseText)) {
+ res.success = true;
+ } else {
+ //if the response contains data, treat it like a 200
+ return true;
+ }
+ break;
+ case 204: // no-content. Create a fake response.
+ res.success = true;
+ res.data = null;
+ break;
+ default:
+ return true;
+ break;
+ }
+ if (res.success === true) {
+ this.fireEvent("write", this, action, res.data, res, rs, o.request.arg);
+ } else {
+ this.fireEvent('exception', this, 'remote', action, o, res, rs);
+ }
+ o.request.callback.call(o.request.scope, res.data, res, res.success);
+
+ return false; // <-- false to prevent intercepted function from running.
+ }, proxy);