DELETE, PUT http
Dave Cragg
dave.cragg at lacscentre.co.uk
Mon Apr 4 03:53:00 EDT 2011
On 3 Apr 2011, at 08:50, Maarten Koopmans wrote:
> Hi,
>
> I there a way to have LIvecode do PUT and DELETE via http/https,
> hopefully witj digest authentication? So you can use the UI tools to
> integrate with REST services? I see great chanches here :-)
You may be able to get this to work using libUrlSetCustomHttpHeaders. This command lets you set the request line and any necessary headers in the http request.
For delete it might work something like this:
put "DELETE /path/to/resource HTTP/1.1" & cr into tRequest
put "Host: www.yourdomain.com" & cr after tRequest
// add any other headers here but above is probably minimum
get url "http://www.yourdomain.com/path/to/resource"
For PUT:
put "PUT /path/to/resource HTTP/1.1" & cr into tRequest
put "Host: www.yourdomain.com" & cr after tRequest
put "Content-length: <length of data>" & cr after tRequest
// add any other headers here
post myData to url "http://www.yourdomain.com/path/to/resource"
You should use "get" for DELETE and "post" for PUT to ensure the libUrl internals behave appropriately. I'm assuming that DELETE requires some kind of response message from the server (haven't looked at the spec for a while). If that's not the case, you may get an error, even if it worked correctly.
After using libUrlSetCustomHttpHeaders, the headers get reset (different from httpHeaders), so you should set this before each call.
I haven't tested either of these before. But worth testing perhaps before building your own from scratch.
Good luck!
Dave
More information about the use-livecode
mailing list