How can I prevent Ext JS from including an entity body in DELETE requests using a restful store?

后端 未结 2 1439
醉梦人生
醉梦人生 2021-01-18 11:12

When Ext JS issues a DELETE request from a restful store, it includes an entity body. Although this doesn\'t seem to be forbidden by the HTTP spec, Google App Engine doesn\'

2条回答
  •  一生所求
    2021-01-18 11:27

    You can fix this problem, as you guessed, by overriding a method in the HttpProxy class. First, add this code:

    // Special HttpProxy that sends no body on DELETE requests
    Ext.data.GAEHttpProxy = Ext.extend(Ext.data.HttpProxy, {
    doRequest: function(action, rs, params, reader, cb, scope, arg) {
        if(this.api[action]['method'].toLowerCase() == "delete") {
            delete params.jsonData;
        }
    
        Ext.data.GAEHttpProxy.superclass.doRequest.call(this, action, rs, params, reader, cb, scope, arg);
    }
    });
    

    Then, use this new class ("GAEHttpProxy") instead of HttpProxy in the rest of your code (for instance, when you create the proxy you use in your store shown above). This worked for me, and I hope it works for you!

提交回复
热议问题