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

发布于 2024-09-06 13:22:54 字数 405 浏览 3 评论 0原文

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

我试过

read/custom URL [ HEAD "" ]

它返回“”而不是标题。

I Would like the get the filesize 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

泪意 2024-09-13 13:22:54
>> 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
]
>> 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
]
明媚如初 2024-09-13 13:22:54

这是针对 R2 的,但您可以检查源代码,

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

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

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

复古式 2024-09-13 13:22:54

另一种解决方案是

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

>>

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

>>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文