Error posting HTTP DELETE from server side


I’m trying to make an HTTP DELETE call server side but I’m getting two errors which is prohibiting this. First, when II try to set the content length to zero I get:

(STDERR) Refused to set unsafe header “Content-length”

Then when I send the DELETE, the callback comes back with a 411 error indicating that no Content-length set on the DELETE. The code is below. Is there a better way to attempt this?

xmlhttp = Meteor.npmRequire('xmlhttprequest').XMLHttpRequest;
var xhrDelete = new xmlhttp();'DELETE', msgURL, true);
xhrDelete.setRequestHeader('Content-length', '0');
xhrDelete.onreadystatechange =
   function () {
      if (xhrDelete.readyState == 4) {
         var serverResponse = xhrDelete.responseText;
         var status = xhrDelete.status;
         if (status != 200) {
            console.log("MEF Msg DELETE error: " + status + " Message: " + serverResponse);
         console.log("DELETE Msg status: " + status);


Just curious - why the npm method and not Meteor’s inbuilt HTTP methods?


I didn’t know there was one at the time of the posting. I’ve since found it, but it too is giving me trouble. The response callback is receiving a getaddrinfo ENOTFOUND error. The server I’m trying to hit is running as a virtual machine on the same computer meteor is running on. Note that the xmlhttprequest and EventSource modules that I use have no trouble reaching the address, and I can ping it from my meteor machine.

Here’s the HTTP code I’m using:

   var msgURL = 'http://mef.ons.pnet/myapp/messages/' + msgId;
   var results = HTTP.del(msgURL , function (error, result) {
        if (error) {



When you say that you can ping it etc., is this with a valid msgId appended to the base address as your code uses? Have you confirmed that this is correctly set in your code?


Yes. e.g. putting this:


in my browser (which was taken directly from my meteor debugger as the URL I’m using in the call) nets me this in the resulting page:


Which is the expected return value for a get. I’m not sure how to do a DELETE from the browser though so haven’t test that.