Hi, I’m working on a REST API where I use the methods PUT and DELETE to update or delete a objects created in the server end.
What I discovered after a couple of hours of debugging is that http.request sends out a empty body request when using a “PUT” method. I’ve tried the same with curl and php and there it works as it should. I’ve also tried to replicated the headers sent out by the curl request and used it in the Defold http.request, but this didn’t help either.
I remember @sicher mentioning that the only verbs that are supported are GET and POST. Anything else will become a GET. I can verify this tomorrow, unless @sicher can chime in now.
In any case, this is something that needs to be fixed. In the meantime it’s possible to use the http.lua module that comes bundled with LuaSocket.
I dug a bit deeper and for a PUT the body will be ignored and the request will work the same way as a GET but with the PUT as verb in the request header. A DELETE should work as expected. In any case, this needs to be fixed.
Thank you, I checked out the http lua module but have decided to wait for a fix for this issue instead. Do you know if this is something that will be fixed shortly or if it will take a couple of months? I don’t mean to be impatient, but it would help me prioritize my workload if I knew
Yes. I’ve updated the code to support PUT and HEAD. DELETE should already be supported. The code is in review and should hopefully make it into Defold 1.2.104.
And does your DELETE request contain a body or do you specify what to delete in the request URI? It seems to be debated wether a DELETE may contain a body or not, and in the Defold case any request body will be ignored when doing a DELETE.
I specify what to delete in the body. Not in the URI. From what I have read online it should be perfectly acceptable to make a DELETE request with a body. But I can change it so that I use the URI instead. But in my own opinion it should be up to the user to decide whether to do a body request. In my case I will have different game engines (not only Defold) that will speak to the server. And this forces me to change all the game engines to fit defolds DELETE request requirements. It is not that much work, but it could be a issue for someone else in the future.
Yeah, I read the debate link before making my last post. That was my source for when saying that it should be acceptable. Either way it’s okay by me whether you decide to keep it with no body.