开发者

How to send a http head request with Rebol?

开发者 https://www.devze.com 2023-01-04 07:56 出处:网络
I Would like the get the files开发者_C百科ize of a remote file using Rebol, in a similar way to how it is done with php,

I Would like the get the files开发者_C百科ize of a remote file using Rebol, in a similar way to how it is done with php, by send an HTTP HEAD request. I can't find any example of how to do this in Rebol, but using the Prot-http module may be the right place to start?

i tried

read/custom URL [ HEAD "" ]

it returns "" and not header.


>> trace/net on
>> i: info? http://www.rebol.com/index.html
URL Parse: none none www.rebol.com none none index.html
Net-log: ["Opening" "tcp" "for" "HTTP"]
connecting to: www.rebol.com
Net-log: {HEAD /index.html HTTP/1.0
Accept: */*
Connection: close
User-Agent: REBOL View 2.7.6.3.1
Host: www.rebol.com
}
Net-log: "HTTP/1.1 200 OK"
>> probe i
make object! [
    size: 7091
    date: 11-Jun-2010/21:12:49
    type: 'file
]


This is for R2 but you can examine the source code,

http://rebol.wik.is/Protocols/Http


An other solution is

>> port: open tcp://mirror.bytemark.co.uk:80
>> insert port "HEAD /ubuntu-releases/lucid/ubuntu-10.04-desktop-i386.iso HTTP/1.1 ^/"
>> insert port "Host: mirror.bytemark.co.uk ^/^/"
>> while [data: copy port][prin data]
HTTP/1.1 200 OK
Date: Tue, 22 Jun 2010 22:36:48 GMT
Server: Apache/2.2.9 (Debian)
Last-Modified: Thu, 29 Apr 2010 12:56:31 GMT
ETag: "238046-2bb71800-4855fa7d53dc0"
Accept-Ranges: bytes
Content-Length: 733419520
Content-Type: application/x-iso9660-image

>>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号