Results 1 to 6 of 6

Thread: HTTP DELETE contains a request body

  1. #1
    Sencha User aatiis's Avatar
    Join Date
    Nov 2011
    Location
    Bajmok, Serbia
    Posts
    60
    Answers
    3
    Vote Rating
    3
      0  

    Default Answered: HTTP DELETE contains a request body

    Using the REST proxy to remove an item fails on some servers that drop DELETE requests that contain a request body (App Engine is a good example).

    How can I tell the REST proxy not to send any data when issuing a DELETE request?
    Last edited by aatiis; 28 Jul 2012 at 3:18 AM. Reason: typo

  2. A possible fix is to override Ext.data.Connection.setOptions:

    Code:
    Ext.override(Ext.data.Connection, {
        setOptions: function () {
            options = this.callOverridden(arguments);
            if (options.method === "DELETE") {
                options.data = null;
            }
            return options;
        }
    });

  3. #2
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335
    Answers
    124
    Vote Rating
    91
      0  

    Default

    Hi!

    i guess you need to prevent the paging params to be sent along with the requests made by your proxy.

    in that case, you may use
    Code:
    enablePagingParams:false
    check this:-
    http://docs.sencha.com/touch/2-0/#!/api/Ext.data.proxy.Rest-cfg-enablePagingParams

    i
    f the condition is not this,can you explain your condition in detail?
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  4. #3
    Sencha User aatiis's Avatar
    Join Date
    Nov 2011
    Location
    Bajmok, Serbia
    Posts
    60
    Answers
    3
    Vote Rating
    3
      0  

    Default

    Nope, that's not the case (though I know about the paging params, and I do disable them in some case.)

    I have a model that has a REST proxy defined:

    Code:
    Ext.define("MyModel", {
        extend: "Ext.data.Model",
        config: {
            proxy: {
                type: "rest",
                url: "/api",
                reader: {
                    type: "json"
                }
            }
        }
    });
    
    model = Ext.Create("MyModel");
    model.save();  // this works fine, issues a POST request.
    
    model.erase(); // this will send a DELETE request that actually contains a payload
    // what I want here is get rid of the payload

  5. #4
    Sencha User aatiis's Avatar
    Join Date
    Nov 2011
    Location
    Bajmok, Serbia
    Posts
    60
    Answers
    3
    Vote Rating
    3
      0  

    Default

    I tried overriding Ext.data.proxy.Rest.buildUrl, but it doesn't seem to help:

    Code:
    ...
        buildUrl: function (request) {
            if (request.getMethod() === "DELETE") {
                request.setJsonData(null);
            }
            return this.callOverridden(arguments);
        }
    ...

  6. #5
    Sencha User aatiis's Avatar
    Join Date
    Nov 2011
    Location
    Bajmok, Serbia
    Posts
    60
    Answers
    3
    Vote Rating
    3
      0  

    Default Solution

    A possible fix is to override Ext.data.Connection.setOptions:

    Code:
    Ext.override(Ext.data.Connection, {
        setOptions: function () {
            options = this.callOverridden(arguments);
            if (options.method === "DELETE") {
                options.data = null;
            }
            return options;
        }
    });

  7. #6

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •