HEAD method

Dave Cragg dave.cragg at lacscentre.co.uk
Wed Jan 28 17:55:01 EST 2009


On 28 Jan 2009, at 19:49, Andre Garzia wrote:

> check the liburlsetcustomhttpheaders command, it will allow you to
> specify a different set of headers, you can use that to do HEAD calls
> without the need to script low level socket routines.
>
> cheers
> andre

This is possible but you will have to ignore any errors in "the  
result". Also, you should add "Connection: close" as one of the  
headers. Otherwise depending on the server, libUrl may timeout while  
waiting to read data from the socket. (libUrl will think it's handling  
a GET) And you probably want to stop redirects  
(libUrlFollowHttpRedirects).

I'm not sure that Brian's idea is much more difficult, but the script  
below should work. (But see Trevor's comment about authentication. )

Assume the url is "http://www.runrev.com/freebeer.html"

on mouseUp

   libUrlFollowHttpRedirects false
   put "HEAD" && "/freebeer.html" && "HTTP/1.1" into tRequest
   put cr & "User-Agent: Revolution" after tRequest
   put cr & "Host:" && "www.runrev.com" after tRequest
   put cr & "Connection: close" after tRequest
   libURLSetCustomHTTPHeaders tRequest
   get url "http://www.runrev.com/"

   put libUrlLastRhHeaders()
   libUrlFollowHttpRedirects true ##RESET
end mouseUp

Cheers
Dave



More information about the use-livecode mailing list