如何使用Rebol发送http头请求?

时间:2010-06-21 05:32:44

标签: rebol

我想使用Rebol获取远程文件的文件大小,其方式与done with php类似, 通过发送HTTP HEAD请求。 我在Rebol中找不到任何如何执行此操作的示例,但使用Prot-http模块可能是正确的起点?

我试过

read/custom URL [ HEAD "" ]

它返回“”而不是标题。

3 个答案:

答案 0 :(得分:1)

这适用于R2,但您可以检查源代码

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

答案 1 :(得分:1)

>> 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
]

答案 2 :(得分:1)

另一个解决方案是

>> 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

>>