[REBOL] Re: read/custom and HTTP HEAD behaviour
From: carl:cybercraft at: 16-Feb-2002 0:54
On 15-Feb-02, j m wrote:
> I am trying to query a URL with HTTP HEAD but I get the full HTTP
> GET instead
> print read/custom http://www.yahoo.com reduce ['HEAD ]
> response: copy ""
> port: open tcp://www.yahoo.com:80 insert port rejoin [ "GET" newline
> "host:www.yahoo.com" newline "connection: close" newline newline ]
> while [ res: copy port ] [ append response res ] close port
> How can I just get the HTTP HEAD without the full page ?
Use "HEAD" instead of "GET" when opening the port. ie...
>> port: open tcp://www.rebol.com:80
>> insert port "HEAD / HTTP/1.0 ^/^/"
>> while [data: copy port][prin data]
HTTP/1.1 200 OK
Date: Fri, 15 Feb 2002 11:43:28 GMT
Server: Apache/1.3.20 (Unix) FrontPage/188.8.131.52
Last-Modified: Wed, 13 Feb 2002 19:01:52 GMT
>> close port
That works with rebol.com, anyway, though not with Yahoo. You may
need to supply more info in Yahoo's case, or it maybe it's just
because Yahoo refuses to supply just the header. But with a bit of
luck, it won't be Yahoo's header you're after. (: